Skip to content

Let the team switch the long-document card off (#3114) - #3185

Merged
Birfy merged 1 commit into
mainfrom
dev/3114-document-cards-switch
Nov 18, 2026
Merged

Birfy merged 1 commit into
mainfrom
dev/3114-document-cards-switch

Conversation

@Birfy

@Birfy Birfy commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Written-by: Dev

Fixes #3184
Part of #3114

Owner: Dev
Reviewer: Reviewer
Tier: T3

What changed

Settings → General keeps a Document cards switch in its Message folding section, beside the folding picker and drawn like In other chats. It is on by default and leaves every bubble exactly as it was drawn before the switch existed; switched off, a long document is no longer a card and Show message text goes with it — the reply folds by the chosen mode (compact / standard / none) like any other long message. The choice is written through set-prefs and stored as the top-level state.prefs.documentCards: false, beside prefs.folding and not inside it, so writing a folding mode never clears it. On is the default, so an explicit true is read as "clear the record" and stores nothing; null does the same, and any other value is refused with Document cards must be on or off and stores nothing. A locked (read-only) window draws no switch and keeps the choice as text. The switch reaches the bubble at one point only: showsDocumentCard answers false when the switch is off. The thresholds, the preview, FoldedContent, shouldFold, previewOf and the streaming-first order in foldBody are untouched.

Checkpoint

{
  "pr": 3185,
  "claim": "Dev",
  "issue": 3184,
  "summary": "Settings → General gains a Document cards switch beside the folding picker, on by default. Off stores the top-level state.prefs.documentCards = false so a folding-mode write cannot clear it, and makes showsDocumentCard answer false: a long document folds like any other reply, with no card and no Show message text. On is the default, an explicit true clears the record, and any other value is refused without storing anything. A locked window draws no switch and keeps the choice as text.",
  "files": [
    "core/src/host/channel.js",
    "core/src/client/message-fold.js",
    "core/src/client/settings.js",
    "core/src/client/i18n.js",
    "core/test/install.test.js",
    "core/test/message-fold.test.js",
    "core/test/settings-readonly-pages.test.js",
    "docs/subsystems/core-host.md",
    "docs/subsystems/core-client.md",
    "changelog.d/3114-document-cards-switch.added.md"
  ],
  "checks": { "ran": "TZ=UTC TMPDIR=/data/flybot-tmp npm run verify", "result": "green", "at": "a503ee01a6217d5418b138467cf7da9a91c4c61f" },
  "next": "none — ready for review"
}

Verification at the tip a503ee0

Ran:

  • cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/install.test.js → # tests 6 / # pass 6 / # fail 0.
  • cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/settings-readonly-pages.test.js → # tests 15 / # pass 15 / # fail 0.
  • cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/message-fold.test.js → # tests 10 / # pass 10 / # fail 0.
  • The same three files with the source reverted to the base and only the tests added: install 6 / 5 / 1 (expected: false / actual: undefined), settings 15 / 13 / 2 (9 !== 8, 1 !== 0), message-fold 10 / 8 / 2 (undefined !== true, 0 !== 1). With the host contract, the UI and the foldingOf read side in place but showsDocumentCard still untouched: settings 15/15, install 6/6, message-fold 9/10, the one red still no card when the switch is off and compact (0 !== 1). The showsDocumentCard short-circuit alone takes it to 10/10.
  • cd core && TZ=UTC node --import ./test/harness-resolve.mjs --test test/tool-cells.test.js test/empty-message-cell.test.js test/earlier-message-actions.test.js test/palette-preview.test.js test/bot-browsers.test.js test/client-bundle.test.js test/i18n.test.js test/i18n-missing-entries.test.js → # tests 79 / # pass 79 / # fail 0 (19, 3, 6, 15, 14, 2, 3, 17).
  • cd core && npm run build, then from the root node core/scripts/build-client.mjs --check → exit 0 and git diff --exit-code -- core/client.js → exit 0.
  • node scripts/ds-bot-patches.mjs generate → check ends ok 10 patches apply cleanly in order / ok core/ equals ds-bot/ + patches/ds-bot/; canonical → generate is a no-op; patches/ds-bot/topics.json, ds-bot.pin.json and ds-bot/** unchanged.
  • npm --prefix core run arch-docs → arch-docs: OK (18 changed file(s)).
  • TZ=UTC TMPDIR=/data/flybot-tmp npm run verify → exit 0.
  • 18 changed files: the 10 hand-written ones (+106 / −7 lines) and the 8 generated ones (core/client.js, 0001, 0005, 0008, 0014 and the three patches/ds-bot/files/ mirrors). No gate file, no core/src/shared/, no plugins/, no authz.js, no panel file, no package file.

Not run:

  • No browser click-through of the switch: the Settings page and the bubble are driven through the two node harnesses (a stateful React mock that runs the real onClick/onChange), not a real page. The manual gate — wide window with a two-heading document draws a card, General off turns the same message into Show more, a refresh keeps it off, switching back returns the card and Show message text — is what a reader should press once; the host side of it is set-prefs and the client side is foldingOf reading prefs.documentCards.
  • No npm ci in the plugin packages: their tests resolve DSH from core/dev/harness/, and npm run verify ran them all.
  • No smoke test: no core/index.js and no host runtime path changed.
  • git fetch is unavailable (only api.github.com is reachable), so origin/main is a local ref at the base commit and the branch is pushed through the Git data API; is a no-op above was run against that same base.

On a deployment with more than one member, set-prefs is refused as bot/blocked-shared — the existing behaviour of every team preference (theme, folding), not this switch.

Settings → General gains a Document cards switch beside the folding mode. Off
stores state.prefs.documentCards = false at the top of prefs — beside the
folding record, so rewriting a mode never clears it — and makes
showsDocumentCard answer false, so a long document folds like any other reply
with no card and no Show message text. On is the default, so a team that never
touches the switch draws exactly what it drew before.

Fixes #3184
Part of #3114
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 18, 2026
@Birfy Birfy self-assigned this Nov 18, 2026
@Birfy

Birfy commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at a503ee0
Written-by: Reviewer
Attestation: a503ee0 role=Reviewer

Ran at this tip:

$ cd core && TZ=UTC TMPDIR=/data/flybot-tmp node --import ./test/harness-resolve.mjs --test test/install.test.js test/settings-readonly-pages.test.js test/message-fold.test.js
# tests 31  # pass 31  # fail 0
$ git checkout f6167844 -- core/src/client/message-fold.js && cd core && TZ=UTC TMPDIR=/data/flybot-tmp node --import ./test/harness-resolve.mjs --test test/message-fold.test.js
# tests 10  # pass 8  # fail 2
$ git checkout . && git checkout f6167844 -- core/src/host/channel.js && cd core && TZ=UTC TMPDIR=/data/flybot-tmp node --import ./test/harness-resolve.mjs --test test/install.test.js
# tests 6  # pass 5  # fail 1
$ node core/scripts/build-client.mjs --check && git diff --exit-code -- core/client.js
# exit 0
$ node scripts/ds-bot-patches.mjs check; node scripts/ds-bot-patches.mjs canonical; npm --prefix core run arch-docs
# ok 10 patches apply cleanly in order / ok core/ equals ds-bot/ + patches/ds-bot/ / generate is a no-op / arch-docs: OK (18 changed file(s))
$ TZ=UTC TMPDIR=/data/flybot-tmp npm run verify
# exit 0  # not ok 0  # core 715/715  plane 149/149  plugins 172/172 538/538 151/151 686/686 37/37 34/34

f6167844 is the local commit whose tree 62cefbf31a760ae5436df63e74432f1919a48b30 is the PR base 11702f1888e6 tree; the checked-out tree hash is 02e6e6832a83ea304666374d61e556b78a26f7e7, the tip tree. Git here comes from tools/git/bin with GIT_EXEC_PATH=tools/git/libexec/git-core (the two fetch-base cases in the first verify run failed only because the sandbox default git has no git-upload-pack; they pass 3/3 with the exec path set).

What I checked

  • Contract (core/src/host/channel.js:325-331): false stores the top-level state.prefs.documentCards = false; true/null delete the key; 'off', 0, ['false'], {on:false} answer bot/invalid + Document cards must be on or off. I also drove the installed host directly: after documentCards:false, a later set-prefs {folding:{mode:'none'}} leaves documentCards:false in the response and in state.json, and an invalid value leaves the stored off in place. The folding branch only rewrites state.prefs.folding, so the switch cannot be wiped by a folding write — the design point holds.
  • One touch point (core/src/client/message-fold.js): showsDocumentCard short-circuits on folding?.documentCards === false as its first line; DEFAULT_FOLDING gains documentCards: true; foldingOf reads the top-level prefs.documentCards !== false. Diff has three hunks only — thresholds (12/800), foldBody's streaming-first order, FoldedContent, shouldFold and previewOf are untouched.
  • Matrix is pinned by the added test: off×compact/standard = no card, no Show message text, still folds with Show more; off×none = whole text; on×standard/compact = the card of the ninth slice; on×none = whole text; streaming = no card either way; a long reply with no headings/sections stays Show more in every combination. The two red lines I reproduced on the base blobs are exactly the switch's own (message-fold 10/8/2, install 6/5/1).
  • Read-only window: the locked General page draws no switch (0 controls) and keeps Document cards / On / Off as text (SetRow); the writable page writes through set-prefs {documentCards: on}.
  • Assertions not weakened: the existing folding cases and the ninth-slice card cases are unchanged; settings-readonly-pages.test.js changes only its count 8→9 and its sentence. No .only(/.skip(; the added-line scan for the T3 words is 0.
  • Generated: build-client --check exit 0 and core/client.js in sync; ds-bot-patches check ends with the two ok lines and canonical says generate is a no-op; git diff --name-only <base>...HEAD -- ds-bot/ patches/ds-bot/topics.json ds-bot.pin.json is empty. The 0008 hunk-header churn is generate output and core/ equals ds-bot/ + patches/ confirms it rebuilds core/.
  • Scope: 18 files = 10 hand-written (+106/−7) + 8 generated; no gate, core/src/shared/, plugins/, panel or package path; both docs/subsystems/core-host.md and docs/subsystems/core-client.md say what the switch does.
  • Checks on the tip: all terminal; the only failure is enqueue-guard (no Verifier report names the tip a503ee01a621), which this report is what clears.

@github-actions github-actions Bot added the pass label Nov 18, 2026
@Birfy
Birfy added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit e5e0311 Nov 18, 2026
18 of 20 checks passed
@Birfy
Birfy deleted the dev/3114-document-cards-switch branch November 18, 2026 20:36
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#3114] 文档卡开关:General 里能关掉长文档卡片

1 participant