Skip to content

fix(decopilot): stop dropping the auto-title on fast runs - #4446

Merged
pedrofrxncx merged 2 commits into
mainfrom
fix/projector-title-race
Jul 11, 2026
Merged

pedrofrxncx merged 2 commits into
mainfrom
fix/projector-title-race

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Chat threads were stuck on "New chat" on fast turns (e.g. sending "hi"), even with the OpenRouter provider. Root cause: the durable projector closed its chunk stream the instant it saw the assistant finish chunk.

Background title generation (genTitle) runs the title LLM in parallel and emits its transient data-title-result chunk after the main finish chunk whenever the assistant response finishes first — which is exactly what happens on short turns. The projector's early close (if (ev.chunk.type === "finish") { … controller.close() }, added in #4179) dropped that trailing chunk before interceptTitleChunkStream could persist it. Slower/longer turns resolved the title before finish, so the bug looked intermittent (older threads got titles, recent short ones didn't).

Fix

Terminate the projector stream only on the fenced done marker, never on finish. The producer (ingestRun) assigns every chunk a seq — including the post-finish title chunk — and publishes done with finalSeq covering it, so reading through to done picks the title up cleanly. The existing StreamIdleTimeoutError remains the backstop for a producer that dies before publishing its done.

One line changed in nats-chunk-source.ts (removed the finish-triggered close); the finish-close was the sole cause.

Sidebar "All" view (second ask)

This same fix restores live title updates for teammates' threads in the sidebar's "All" view. Persisting the title fires onTitleUpdated (app.ts), which emits the org-wide decopilot.thread.status SSE event carrying the title — already consumed by thread-manager-store and applied to any thread in the list. The path was fully wired; it was starved only because the title chunk never reached the projector. No sidebar code change needed.

Testing

  • Updated projector-chunk-stream.test.ts: the projector now reads past finish to the fenced done, and a trailing data-title-result chunk survives. Adjusted two idle-window tests that relied on the old finish-close terminal.
  • Verified end-to-end against a fast-run message sequence (start → text → finish → data-title-result → done) piped through the real projector stream into the real interceptTitleChunkStream: persistTitle now fires with the generated title. Pre-fix, the chunk was dropped and no title was persisted.

🤖 Generated with Claude Code


Summary by cubic

Stops dropping auto-generated chat titles on fast runs by keeping the projector stream open until the fenced done instead of closing on finish. Restores live title updates in the sidebar "All" view.

  • Bug Fixes
    • Projector now runs until the fenced done, preserving post-finish data-title-result chunks.
    • Honors finalSeq; idle-timeout remains the safety net for stuck producers.
    • Tests updated across nats-chunk-source and projector streams to read past finish, include fenced done, and ignore legacy unfenced done.

Written for commit 455ff21. Summary will update on new commits.

Review in cubic

The durable projector closed its chunk stream the moment it saw the
assistant `finish` chunk. Background title generation emits its transient
`data-title-result` chunk *after* `finish` on fast runs (the title LLM
resolves later than a short response), so the projector closed and dropped
it before `interceptTitleChunkStream` could persist it — the thread stayed
on "New chat". Slower runs happened to resolve the title before `finish`,
which is why the bug looked intermittent.

Terminate only on the fenced `done` marker instead. The producer assigns
the title chunk a seq and the done's `finalSeq` already covers it, so
reading through to `done` picks the title up; the existing idle-timeout
remains the backstop for a producer that dies before publishing its done.

This also restores live title updates for teammates' threads in the sidebar
"All" view: persisting the title fires `onTitleUpdated`, which emits the
org-wide `decopilot.thread.status` SSE the sidebar already consumes.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 11, 2026 00:39
@pedrofrxncx
pedrofrxncx merged commit 86dd5c9 into main Jul 11, 2026
15 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/projector-title-race branch July 11, 2026 00:42
decocms Bot pushed a commit that referenced this pull request Jul 11, 2026
PR: #4446 fix(decopilot): stop dropping the auto-title on fast runs
Bump type: patch

- decocms (apps/mesh/package.json): 4.5.0 -> 4.5.1

Deploy-Scope: server
tlgimenes pushed a commit that referenced this pull request Jul 16, 2026
…TS.md (#4475)

Mined ~300 merged PRs for the delta between the first PR proposal and the
work added before merge. The dominant shape: a first draft ships the happy
path, then a hardening pass (often a different engineer who takes over the
branch and merges — the vibecoder→engineer handoff) adds the same categories
every time. Encoded those 9 categories as an actionable first-pass checklist,
each citing a real PR (#4008, #4230, #4365, #4409, #4426, #4445, #4357, #4355,
#4449, #4350, #4373, #4416, #4446, #4461, #4134, #4469).

Covers: variant/edge-case handling, tenant/permission scoping, concurrency &
silent-data-loss, test-per-fix + invert-bug-tests + real-PG, dead-code/knip,
lifecycle symmetry + state reset, kill-switch/GC/git-exclude for risky infra,
input validation vs over-engineering, compile-time type-safety.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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