Repository navigation
refactor(chat): keep the composer text-and-files predicate internal - #14728
bolichen97 merged 1 commit into
Conversation
`hasComposerTextOrFiles` landed in kirodotdev#10926 as a second exported spelling of the inline `composerHasDraft` in `ChatInput.tsx` (`!!value.trim() || pendingFiles.length > 0`). The first-principles review on that PR flagged it: two definitions of "the composer has something in it" on the tree at once, free to drift apart, in a module whose whole premise is that there is exactly one. Dropping the `export` removes the duplicate public surface without touching behaviour -- `hasUnsentComposerWork` still calls it. Collapsing the two spellings for real is the job of the stack PR that rewires `ChatInput` onto this module, which can then delete the inline copy in the same change that adds the consumer. The three assertions that called it directly now go through `hasUnsentComposerWork`, which reaches the same branch for text and for files, so per-file coverage of `composerWork.ts` stays at 100%.
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 9ef1998 |
UX Review (Fable 5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 9ef1998 |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The Goal's "exactly one definition on the tree" overstates: The description declares that residual honestly ("The PR that rewires What this change shipsInventory (3 items) — 3 justifiedIntent: stop offering a second importable spelling of "the composer has text or files" while its intended consumer PR is unmerged — a FIX (subtraction of speculative surface).
[FIRST-PRINCIPLES-REVIEWED] 9ef1998 |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-09-28): readiness passed, required checks green on 9ef1998, no blocking review threads, security posture unchanged. Approving and merging.
Problem / Motivation
Goal: Leave exactly one definition of "the composer has text or files" on the tree, so the two copies cannot drift apart while the composer-work helpers wait for their consumers.
#10926 landed
composerWork.tswithhasComposerTextOrFilesexported.ChatInput.tsxalready spells the same two terms inline as
const composerHasDraft = !!value.trim() || pendingFiles.length > 0. TheFirst Principles review on that PR flagged it as a duplicate ("both spellings now live
on the tree and can diverge") and offered two dispositions: rewire
ChatInputonto theexport, or drop the export. #10926 merged before either was applied, so main carries
both spellings today.
Why it matters
Two independent definitions of the same predicate is precisely the failure
composerWork.tsexists to prevent -- its own header states the module's premise is thatthere is only one. While both live on the tree, a later fix to one (say, treating a
whitespace-only paste as empty) silently does not reach the other, and the two seams
disagree about whether the composer holds work. The module has no production consumer
yet, so this is the cheapest moment to collapse the surface: nothing depends on the
export, and no caller has to change.
Not a goal
ChatInputontohasUnsentComposerWorkorhasComposerTextOrFiles. Thatbelongs to the stack feat(chat): render zero-turn option action chips in the follow-up bar #6823 PR that adds the consumer, which can delete the inline
copy in the same change that makes the helper reachable.
What changed (motivation → approach → change)
Symptom: two spellings of the same boolean on the tree, one exported from
composerWork.tsand one inline inChatInput.tsx:3340.Root cause: the sub-predicate was exported in anticipation of
ChatInputimporting it,but the wiring PR has not landed, so the export bought nothing and cost a second
definition.
Change: drop the
exportkeyword.hasComposerTextOrFilesstays exactly where it is andkeeps doing exactly what it did --
hasUnsentComposerWorkstill calls it atcomposerWork.ts:97-- it is simply no longer part of the module's public surface. Itsheader now says so, and names the wiring PR as the change that gets to collapse the two
spellings for real.
The alternative (rewire
ChatInputhere) was rejected: it pulls a component into a PRwhose whole purpose is leaf helpers, trips the screenshot gate on a change with no
visual delta, and pre-empts a design decision that the consuming PR's review should make.
Backwards compatibility
Compatible. This REMOVES a public export, so here is the sweep.
Writer sweep on
origin/main@dc326be85f8243a2424bc63f04bc1afba093e420: arepo-wide grep for
hasComposerTextOrFiles(all.ts/.tsx/.js/.md, excludingnode_modules) finds it in exactly two places -- its own definition incomposerWork.tsand the direct assertions incomposerWorkRecoverability.test.ts.There are zero importers in production code and zero outside that one test file, which
this PR updates. The symbol has never been consumed, so nothing that works today stops
working.
Tests
website/src/test/composerWorkRecoverability.test.tsno longer imports the symbol. Itsthree direct assertions move onto the public
hasUnsentComposerWork, which reaches thesame branch:
hasUnsentComposerWork(EMPTY)call on the line above it, so it is dropped as redundant.
text at all", asserting
{ text: 'hi' }and{ text: '', files: ['a'] }throughhasUnsentComposerWork-- the text term and the files term of the internal predicaterespectively.
Per-file coverage of
composerWork.tsstays at 100% of lines (7/7), measured from thecobertura report the CI gate reads; the internal function is still fully exercised through
its caller. The other three modules from #10926 are untouched and also still read 100%
(
sideComposerDrafts.ts53/53,slotSuccession.ts45/45,draftMigration.ts5/5).Local run on this branch: 6 suites / 60 tests pass,
tsc --noEmitexits 0, andeslint --max-warnings 0on both changed files exits 0.Manual verification
N/A — no runtime behaviour changes. The predicate's inputs, outputs and its one call site
are identical before and after; the diff removes a keyword and rewrites a doc comment and
three test assertions. Unit coverage of the predicate is complete (100% of lines), so
there is no uncovered path a manual step could exercise.
Related Issues
Follows up the First Principles review finding on #10926 (duplicate of
website/src/components/ChatInput.tsx:3340). Part of the stack #6823 split.Pattern harvest
Rule candidate: review-prompt
Pattern: a helper PR exports a sub-predicate that an existing call site already spells
inline, creating a second definition that no consumer justifies yet -- when a module
lands ahead of its wiring, its public surface should be only what a consumer will
actually import.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)