fix(acp): recover chat history after reconnect - #3063
Conversation
Greptile SummaryThe PR refreshes authoritative ACP history after accepted prompts and Host recovery, then reconciles optimistic prompts against newer committed user turns.
Confidence Score: 4/5The repeated-submission reconciliation defect should be fixed before merging because one accepted prompt can remove a later identical optimistic prompt. The new sequence-and-text predicate does not identify a specific submission, so rapid consecutive prompts with the same text can cause the first committed turn to clear the second prompt's optimistic state. Files Needing Attention: apps/emdash-desktop/src/core/features/conversations/browser/acp/acp-chat-store.ts; apps/emdash-desktop/src/renderer/tests/browser/acp-chat-store-submission.test.ts
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/core/features/conversations/browser/acp/acp-chat-store.ts | Adds recovery refreshes and baseline-based optimistic reconciliation, but equal consecutive submissions can be associated with the wrong committed turn. |
| apps/emdash-desktop/src/renderer/tests/browser/acp-chat-store-submission.test.ts | Covers stale identical history and reconnect recovery but omits consecutive identical submissions sharing the same baseline. |
| agents/architecture/acp-runtime.md | Documents the new renderer-side authoritative-history refresh behavior. |
Sequence Diagram
sequenceDiagram
participant User
participant Store as ACP chat store
participant Host as ACP Host
participant History as Authoritative history
User->>Store: Submit prompt
Store->>Store: Record baseline and optimistic prompt
Store->>Host: sendPrompt()
Host-->>Store: Accepted
Store->>History: Refresh history
History-->>Store: Committed turns
Store->>Store: Match newer user turn and reconcile
Host-->>Store: Host ready after reconnect
Store->>History: Refresh missed committed turns
Prompt To Fix All With AI
### Issue 1
apps/emdash-desktop/src/core/features/conversations/browser/acp/acp-chat-store.ts:866-875
**Text matching clears wrong prompt**
When identical text is submitted twice before the first submission publishes its working state, the first committed turn satisfies this shared baseline-and-text predicate and clears the second optimistic prompt before its authoritative turn exists, causing the later submission to disappear temporarily from the transcript and message count.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(acp): recover chat history after rec..." | Re-trigger Greptile
Description
Restore authoritative ACP chat history when live turn updates are missed during a disconnect.
The change stays in the renderer projection layer; it does not alter the ACP protocol, runtime state machine, provider processes, or dependencies.
Related issues
Complements #3062, which makes transient SSH/Wire disconnects publish the Host recovery edge used here.
Testing
pnpm --filter @emdash/emdash-desktop format:checkpnpm --filter @emdash/emdash-desktop lintpnpm --filter @emdash/emdash-desktop typecheckworkspace-settings-section.browser.test.tsxfixture omitsworkspaceOptions, and an agent-selector hover test timed out under suite load but passed immediately in isolation (2 tests).Screenshot/Recording (if applicable)
Not applicable; this restores transcript state without changing layout or styling.
Checklist