Skip to content

fix(acp): recover chat history after reconnect - #3063

Open
athanzxyt wants to merge 2 commits into
generalaction:mainfrom
athanzxyt:fix/acp-history-reconnect
Open

fix(acp): recover chat history after reconnect#3063
athanzxyt wants to merge 2 commits into
generalaction:mainfrom
athanzxyt:fix/acp-history-reconnect

Conversation

@athanzxyt

@athanzxyt athanzxyt commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Description

Restore authoritative ACP chat history when live turn updates are missed during a disconnect.

  • refresh history after an accepted prompt settles and whenever Host availability returns
  • give optimistic submissions unique sequence IDs and reconcile them against distinct user turns in submission order
  • preserve consecutive identical prompts until each prompt's authoritative turn exists

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

  • focused ACP browser suite (26 tests)
  • focused ACP store and live-session node tests (7 tests)
  • pnpm --filter @emdash/emdash-desktop format:check
  • pnpm --filter @emdash/emdash-desktop lint
  • pnpm --filter @emdash/emdash-desktop typecheck
  • full desktop suite: 3,617 tests passed and 1 skipped. Two unrelated browser tests failed: the untouched workspace-settings-section.browser.test.tsx fixture omits workspaceOptions, 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
  • I kept this PR small and focused
  • I ran a self-review before opening this PR
  • I ran the relevant local checks or explained why not
  • I updated docs when behavior or setup changed
  • I added or updated tests when behavior changed, or explained why not
  • I only added comments where the logic is not obvious
  • I used Conventional Commits for the commit message and PR title

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR refreshes authoritative ACP history after accepted prompts and Host recovery, then reconciles optimistic prompts against newer committed user turns.

  • Adds a submission-sequence baseline to avoid matching identical prompts from older history.
  • Requests history refreshes after prompt acceptance and Host recovery.
  • Adds browser tests for disconnect recovery, repeated prompt text, and Host availability transitions.
  • Updates ACP runtime architecture documentation.

Confidence Score: 4/5

The 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

Important Files Changed

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
Loading
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

Comment thread apps/emdash-desktop/src/core/features/conversations/browser/acp/acp-chat-store.ts Outdated
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