Skip to content

refactor(chat): keep the composer text-and-files predicate internal - #14728

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
rnoack1:fix/dedupe-composer-text-or-files-predicate
Sep 28, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
rnoack1:fix/dedupe-composer-text-or-files-predicate

Conversation

@rnoack1

@rnoack1 rnoack1 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

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.ts with hasComposerTextOrFiles exported. ChatInput.tsx
already spells the same two terms inline as
const composerHasDraft = !!value.trim() || pendingFiles.length > 0. The
First 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 ChatInput onto the
export, 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.ts exists to prevent -- its own header states the module's premise is that
there 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

What changed (motivation → approach → change)

Symptom: two spellings of the same boolean on the tree, one exported from
composerWork.ts and one inline in ChatInput.tsx:3340.

Root cause: the sub-predicate was exported in anticipation of ChatInput importing it,
but the wiring PR has not landed, so the export bought nothing and cost a second
definition.

Change: drop the export keyword. hasComposerTextOrFiles stays exactly where it is and
keeps doing exactly what it did -- hasUnsentComposerWork still calls it at
composerWork.ts:97 -- it is simply no longer part of the module's public surface. Its
header now says so, and names the wiring PR as the change that gets to collapse the two
spellings for real.

The alternative (rewire ChatInput here) was rejected: it pulls a component into a PR
whose 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: a
repo-wide grep for hasComposerTextOrFiles (all .ts/.tsx/.js/.md, excluding
node_modules) finds it in exactly two places -- its own definition in
composerWork.ts and the direct assertions in composerWorkRecoverability.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.ts no longer imports the symbol. Its
three direct assertions move onto the public hasUnsentComposerWork, which reaches the
same branch:

  • The empty-composer assertion was already covered by the hasUnsentComposerWork(EMPTY)
    call on the line above it, so it is dropped as redundant.
  • "counts real text through both predicates" becomes "counts real text, and files with no
    text at all", asserting { text: 'hi' } and { text: '', files: ['a'] } through
    hasUnsentComposerWork -- the text term and the files term of the internal predicate
    respectively.

Per-file coverage of composerWork.ts stays at 100% of lines (7/7), measured from the
cobertura 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.ts 53/53, slotSuccession.ts 45/45, draftMigration.ts 5/5).

Local run on this branch: 6 suites / 60 tests pass, tsc --noEmit exits 0, and
eslint --max-warnings 0 on 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

`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%.
@rnoack1
rnoack1 requested a review from a team September 28, 2026 15:49
@rnoack1
rnoack1 requested a review from a team as a code owner September 28, 2026 15:49
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 9ef19988460f1336e7b1e227323f13533726aba4 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9ef1998

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 9ef19988460f1336e7b1e227323f13533726aba4 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 9ef1998

@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — ✅ PASS

UX-level review of 9ef19988460f1336e7b1e227323f13533726aba4 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Nothing to check.

[UX-REVIEWED] 9ef1998

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 9ef19988460f1336e7b1e227323f13533726aba4 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9ef1998

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 9ef19988460f1336e7b1e227323f13533726aba4 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

The Goal's "exactly one definition on the tree" overstates: ChatInput.tsx:3341 and the now-internal function both remain; only the #6823 wiring PR collapses them.

The description declares that residual honestly ("The PR that rewires ChatInput onto this module is the one that gets to collapse the two"), so the deferral is stated, not hidden. Counted on base: grep hasComposerTextOrFiles finds 6 hits — the definition, its one internal caller at composerWork.ts:97, and four test lines. Zero production importers, so the export was zero-consumer surface and removing it is a pure subtraction. Before merge, a human should confirm the #6823 stack really carries the rewiring change, since until it lands the drift the Goal names is still possible between the inline copy and the internal one.

What this change ships

Inventory (3 items) — 3 justified

Intent: 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).

  1. Other modules can no longer import hasComposerTextOrFiles; it stays as a private helper — justified
  2. The test's three direct assertions on the sub-predicate now route through hasUnsentComposerWork; one redundant empty-composer assertion dropped — justified
  3. The helper's doc comment now explains the non-export instead of the old shared-terms rationale — justified

[FIRST-PRINCIPLES-REVIEWED] 9ef1998

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 28, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bolichen97
bolichen97 merged commit 69646f0 into kirodotdev:main Sep 28, 2026
99 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 29, 2026
@rnoack1
rnoack1 deleted the fix/dedupe-composer-text-or-files-predicate branch October 12, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants