mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 01:50:13 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The task chat shows each native runner turn while it streams, while it settles, and after it settles. > - During the onboarding interview, the agent streams a reply, posts a question card, and ends its turn as `yielded`. > - The live tail hides that reply when the card's pending interaction arrives. The settled turn also hides it, because a yielded turn never fills the final-response slot. > - The user sees the reply appear and then disappear. The reply is still in run history, so this is a rendering regression, not data loss. > - This pull request hides only the control-plane wait stub of a yielded turn. It keeps prose that the agent wrote for the user. > - The benefit is a stable conversation while responses stream and finish. ## Linked Issues or Issue Description **Bug description** During a hands-on onboarding test on staging, interview messages in the first-task chat appeared and then disappeared. **Steps to reproduce** 1. Start onboarding and pick "Interview me and propose a plan". 2. Watch the agent's turn. It streams a reply that describes the question card, for example "I've posted a question card on this task that asks four things...". 3. The question card appears. The reply disappears and does not come back after the run settles or after a reload. **Expected behavior** The conversation stays stable while responses stream and finish. **Related** Refs #18977. That PR changes server-side final-response selection for native standing conversations and leaves yielded waits and cards in control. This PR changes only how the task chat renders a yielded turn's authored reply. The two PRs do not overlap. **Evidence and root cause** - Persisted history is complete. The run's events contain the `agentMessage` `item.completed` with `channel: "final"` and the full reply text. The `run.result.accepted` result has `reportedWorkDisposition: "yielded"` with a `response_wake` continuation. Its summary is different from the reply. - The rendered thread does not contain that reply, also after "More messages" expands the history. - Classification: rendering/replacement, not persistence. Three gates drop the reply. `TaskChatThread` sets `suppressFinal` on the live tail when a pending interaction for that run exists. `TaskChatRunnerTurn` then clears the latched final. `paperclipRunnerFinalResponse` and the settled-turn path (`!sourceYielded`) return no final response for yielded turns. - Those gates were added on purpose so the mechanical "Waiting for <card>." prose that some providers echo does not show as an answer. This change keeps that behavior. ## What Changed - `transcript-adapter.ts`: add `isYieldedWaitStub`. A wait stub is text that echoes the yielded result summary, or a single-line "Waiting for ..." text. For a yielded turn, `paperclipRunnerFinalResponse` now returns the last authored final-channel message. It still returns nothing for a wait stub. New `yielded` and `waitSummary` options let callers state the yield from run metadata. - `TaskChatRunnerTurn.tsx`: `suppressFinal` hides only a wait stub. It no longer hides the agent's authored reply. A new `waitSummary` prop carries the accepted summary. - `TaskChatThread.tsx`: a settled yielded turn renders the authored reply once, in the last populated segment. The reply also counts as a native response for the "no user-facing response" marker and for progress de-duplication. The live tail passes the accepted summary to the runner turn. - Review round 1 (commitc134d72620): a run that posted a question card stays out of the accepted response-wake path while the card is pending and after it is answered. Before, an answered card let the wait summary replace the reply. The backward scan now skips wait stubs, so a stub echoed after the reply does not hide it. The accepted response-wake summary still has precedence for runs that posted no card. The existing contract test for that still passes. - Review round 2 (commit4f300fbb3e): when a steering anchor splits a yielded turn, the reply renders in the segment that contains it. The settled final-response choice moves from a nested ternary into a helper. `TaskChatRunnerTurn`'s `suppressFinal` prop is renamed `awaitingContinuation`. - Tests: a `TaskChatThread` red/green test feeds native run events through the three states: live stream, live with the pending card, and settled as yielded. An adapter unit test covers authored prose versus the two wait-stub forms. ## Verification Red (current `master` source with the new test). The reply disappears while the run is still live, at the moment the question card arrives: ``` RUN v5.0.3 /Users/dotta/paperclipai/paperclip/.claude/worktrees/fix-bug02-vanishing-messages-3e49c5/ui ❯ src/components/TaskChatThread.test.tsx (365 tests | 1 failed | 364 skipped) 664ms ❯ TaskChatThread runtime transcript selection (169) × keeps a streamed interview reply visible after its run yields to a question card 662ms ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ FAIL src/components/TaskChatThread.test.tsx > TaskChatThread runtime transcript selection > keeps a streamed interview reply visible after its run yields to a question card AssertionError: expected 'Unanswered questionWhat does your org…' to contain 'I\'ve posted a question card' Expected: "I've posted a question card" Received: "Unanswered questionWhat does your organization do?RunnerWorking for 103767m 18sThinkingWhat does your organization do?What does your organization do?YesNoOther CancelSubmit answers" ❯ src/components/TaskChatThread.test.tsx:3215:35 3213| linkedRuns: [linkedRun("running")], 3214| }); 3215| expect(container.textContent).toContain("I've posted a question ca… | ^ 3216| 3217| // 3. Settled: the run yielded to the question card it posted. ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ Test Files 1 failed (1) Tests 1 failed | 364 skipped (365) Start at 13:26:47 Duration 31.59s (transform 71%, import 19%, environment 8%, tests 2%) ``` The first red run failed one step later, at the settled step (before I added the live-with-card step). Both steps fail on `master`: ``` AssertionError: expected 'RunnerWorked for 30sUnanswered questi…' to contain 'I\'ve posted a question card' Received: "RunnerWorked for 30sUnanswered questionWhat does your organization do?...Submit answers" ``` Green (same test, with the fix): ``` Test Files 2 passed (2) Tests 2 passed | 479 skipped (481) ``` Neighbouring suites (`TaskChatThread*`, all of `src/components/task-chat/`, `IssueChatThread`, `issue-chat-messages`): ``` Test Files 59 passed (59) Tests 1411 passed | 1 skipped (1412) ``` This includes the existing tests "keeps a yielded question turn out of the final-response slot", "keeps a yielded run-result and provider wait prose out of the durable final slot", and every "renders only an authorized terminal response-wake answer" mode. They still pass, so wait stubs stay hidden. Review round 1 red/green. I added a fourth test step that answers the card. With the old pending-only check, that step fails: ``` × keeps a streamed interview reply visible after its run yields to a question card Received: "RunnerWorked for 30sWaiting for user answers on the interview question card.Questions answered..." ``` Withc134d72620, the step passes. The neighbouring suites pass again: `Test Files 59 passed (59)`, `Tests 1411 passed | 1 skipped (1412)`. Review round 2 red/green. A new steered-yielded test fails with the old last-segment placement (`expected 163 to be less than 52`: the reply rendered after the steering message). It passes with the fix. Neighbouring suites, now including `design-sandbox`: `Test Files 61 passed (61)`, `Tests 1426 passed | 1 skipped (1427)`. Other checks: - `node scripts/check-token-gates.mjs`: all gates clean. The change has no styling edits. - `ui` `tsc --noEmit`: no errors in the changed files. The remaining errors are already on `master` in this worktree: missing generated storybook catalog JSON, and workspace packages that are not built. - I did not run the full `pnpm -r typecheck`, `pnpm test:run`, or `pnpm build` locally. CI runs them. ## Risks - A yielded turn can now show a final reply above its question card. This is the text that the user already saw while the turn streamed. The text now stays instead of flashing away. - The wait-stub check is heuristic. A one-line authored reply that starts with "Waiting for" stays hidden, as before. A multi-line provider stub that does not match the summary now shows. - No data, API, or schema changes. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with tool use (shell, file edit, browser inspection of the staging run history). ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>