Skip to content

feat(skill-reco): lock the composer for the wait, and give it 3 s - #807

Merged
huichen merged 1 commit into
mainfrom
feat/skill-reco-pending
Sep 23, 2026
Merged

huichen merged 1 commit into
mainfrom
feat/skill-reco-pending

Conversation

@huichen

@huichen huichen commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

feat(skill-reco): lock the composer for the wait, and give it 3 s

Two halves of the same complaint: the recommendation looked like it wasn't
firing at all.

The budget was too tight. Jev's measured latency is p50 ≈0.5 s but
p95 ≈1.4 s (docs/internals/skill_reco/evaluation.md), so a 1.5 s deadline
discarded one answer in twenty — and a discarded answer is indistinguishable
from "no skill fits" on screen: no card, no message, the draft just sends. Live
evidence from tonight's agent log: two calls answered in 1691 ms and 1551 ms for
the same question, both past the deadline, both thrown away. The budget is now
3 s on all three clients.

The wait was invisible. The desktop already refused to submit while the
recommender was being asked, but only through a ref: the input stayed editable,
the send button kept its normal look, and pressing it did nothing. Now the wait
is shown, on every client:

  • desktop: the editor is locked (so the text that goes out is the text that was
    evaluated) and the send button is disabled with a spinner and a
    「正在匹配技能…」 status line, mirroring how manual compaction already reports
    itself.
  • mobile: the hook exposes evaluating; the dock turns the send button into an
    ActivityIndicator, refuses the submit, and closes the input for the same
    window.
  • TUI: the prompt line spins (⠋ Looking for a skill that fits…) and the box is
    locked — typing, paste and Escape all leave the held draft alone. This also
    fixes a real bug: a second Enter used to fall through to the normal send path,
    so the message the answer belonged to went out while the answer was still in
    flight, and a card for it could land afterwards.

The lock covers the network wait only — the local daily-budget and candidate
reads before it are fast and must not flash the input disabled. It ends as soon
as the answer does, so a declined recommendation still sends the draft
unchanged.

Tests: desktop Composer.skillRecommend.test.tsx drives the pending window
(editor not editable, send disabled + labelled, nothing sent) and the follow-up
send — verified to fail against the previous Composer.tsx. Hook suites cover
the 3 s budget (fake-timer timeout at RECOMMEND_TIMEOUT_MS) and the mobile
evaluating flag; mobile ComposerDock.test.ts covers the locked dock and was
likewise checked to fail without the change. TUI: the pending line spins, and
a_pending_recommendation_locks_the_input_box covers Enter/typing/paste/Escape.
Green locally: desktop 144 files / 1250 tests, mobile 123 / 1870, TUI 2090 lib +
8 + 5 integration tests, clippy clean.

Not changed: the shown-card state (Suggested) stays editable on all three —
the card is actionable there, and only then does the draft wait on a human.

Two halves of the same complaint: the recommendation looked like it wasn't
firing at all.

**The budget was too tight.** Jev's measured latency is p50 ≈0.5 s but
p95 ≈1.4 s (`docs/internals/skill_reco/evaluation.md`), so a 1.5 s deadline
discarded one answer in twenty — and a discarded answer is indistinguishable
from "no skill fits" on screen: no card, no message, the draft just sends. Live
evidence from tonight's agent log: two calls answered in 1691 ms and 1551 ms for
the same question, both past the deadline, both thrown away. The budget is now
**3 s** on all three clients.

**The wait was invisible.** The desktop already refused to submit while the
recommender was being asked, but only through a ref: the input stayed editable,
the send button kept its normal look, and pressing it did nothing. Now the wait
is shown, on every client:

- desktop: the editor is locked (so the text that goes out is the text that was
  evaluated) and the send button is disabled with a spinner and a
  「正在匹配技能…」 status line, mirroring how manual compaction already reports
  itself.
- mobile: the hook exposes `evaluating`; the dock turns the send button into an
  `ActivityIndicator`, refuses the submit, and closes the input for the same
  window.
- TUI: the prompt line spins (`⠋ Looking for a skill that fits…`) and the box is
  locked — typing, paste and Escape all leave the held draft alone. This also
  fixes a real bug: a second Enter used to fall through to the normal send path,
  so the message the answer belonged to went out while the answer was still in
  flight, and a card for it could land afterwards.

The lock covers the network wait only — the local daily-budget and candidate
reads before it are fast and must not flash the input disabled. It ends as soon
as the answer does, so a declined recommendation still sends the draft
unchanged.

Tests: desktop `Composer.skillRecommend.test.tsx` drives the pending window
(editor not editable, send disabled + labelled, nothing sent) and the follow-up
send — verified to fail against the previous `Composer.tsx`. Hook suites cover
the 3 s budget (fake-timer timeout at `RECOMMEND_TIMEOUT_MS`) and the mobile
`evaluating` flag; mobile `ComposerDock.test.ts` covers the locked dock and was
likewise checked to fail without the change. TUI: the pending line spins, and
`a_pending_recommendation_locks_the_input_box` covers Enter/typing/paste/Escape.
Green locally: desktop 144 files / 1250 tests, mobile 123 / 1870, TUI 2090 lib +
8 + 5 integration tests, clippy clean.

Not changed: the shown-card state (`Suggested`) stays editable on all three —
the card is actionable there, and only then does the draft wait on a human.
@huichen
huichen enabled auto-merge (squash) September 23, 2026 14:52
@huichen
huichen merged commit 19555d8 into main Sep 23, 2026
12 checks passed
@huichen
huichen deleted the feat/skill-reco-pending branch September 23, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant