Skip to content

feat(agent-plan): persist plan blocks in history#1817

Merged
zerob13 merged 1 commit into
devfrom
feat/agent-plan-persistence
Jun 25, 2026
Merged

feat(agent-plan): persist plan blocks in history#1817
zerob13 merged 1 commit into
devfrom
feat/agent-plan-persistence

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator
  • add persisted inline plan blocks for agent-mode history
  • propagate terminal plan reasons for abort, error, and max-steps exits
  • rehydrate live plan state from persisted assistant message blocks
  • fix turn-scoped dismiss/collapse behavior for auto-drained queued turns

Summary by CodeRabbit

  • New Features

    • Plan progress is now restored after reloading or switching conversations.
    • Plan steps can now show terminal states like interrupted, aborted, or max steps reached.
  • Bug Fixes

    • Prevented plan progress from spinning indefinitely when a turn ends unexpectedly.
    • Improved handling so plan updates stay in sync across message history, retries, and stops.
  • Style

    • Updated plan progress text, counts, and accessibility so the UI is clearer and easier to use.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

The PR adds shared agent-plan schemas, plan stream events, terminal-reason stamping, per-session plan rehydration, and updated plan rendering plus locale strings.

Changes

Agent Plan Refactor

Layer / File(s) Summary
Docs
docs/architecture/agent-plan-task-refactor/{acp-plan-reachability.md,plan.md,spec.md,tasks.md}
The v4 plan-refactor docs add the ACP reachability audit, architecture decisions, task list, and success criteria.
Shared plan contracts and helpers
src/shared/types/agent-plan.ts, src/shared/types/agent-plan-block.ts, src/shared/types/core/llm-events.ts, src/shared/types/core/chat.ts, src/shared/types/agent-interface.d.ts, src/shared/chat/agentPlanBlock.ts, src/shared/chat.d.ts, src/shared/contracts/events/chat.events.ts, test/main/shared/agentPlanBlock.test.ts
The shared plan schemas, block helpers, and event contracts add normalized step items, terminal reasons, plan stream events, and plan-block hydration/upsert/stamp utilities.
Plan stream and terminal stamping
src/main/presenter/agentRuntimePresenter/{types.ts,accumulator.ts,dispatch.ts,process.ts}, src/main/presenter/llmProviderPresenter/acp/acpContentMapper.ts, test/main/presenter/agentRuntimePresenter/{accumulator.test.ts,dispatch.test.ts,process.test.ts}, test/main/presenter/llmProviderPresenter/acpContentMapper.test.ts
ACP mapping and main-presenter runtime flow now convert plan updates into type:'plan' blocks and stamp terminal reasons during finalize, error, and abort exits.
Tool reset wiring
src/shared/types/presenters/tool.presenter.d.ts, src/main/presenter/toolPresenter/index.ts, src/main/presenter/toolPresenter/agentTools/*, src/main/presenter/agentRuntimePresenter/index.ts, test/main/presenter/agentRuntimePresenter/agentRuntimePresenter.test.ts, test/main/presenter/toolPresenter/*
The plan tool and presenter add per-conversation reset APIs, require toolCallId for progress snapshots, and clear agent-plan state after creating a new assistant turn.
Renderer state rehydration and lifecycle
src/renderer/src/stores/ui/*, src/renderer/src/pages/ChatPage.vue, test/renderer/stores/agentPlanStore.test.ts, test/renderer/components/ChatPage.test.ts
The chat page and agent-plan store rehydrate persisted plan snapshots from messages, persist per-session view state, and reset or purge plan state across turns and session removal.
Renderer presentation and locale text
src/renderer/src/composables/useAgentPlanStatus.ts, src/renderer/src/components/chat/*, src/renderer/src/components/message/MessageBlockPlan.vue, src/renderer/src/i18n/*/chat.json, test/renderer/components/{AgentProgressFloat.test.ts,message/MessageBlockBasics.test.ts}
The plan components and locale files switch to normalized step entries, interrupted terminal presentation, and updated completed-count and aria-label strings.

Sequence Diagram(s)

sequenceDiagram
  participant ChatPage
  participant messageStore
  participant snapshotFromAgentPlanBlock
  participant agentPlanStore
  ChatPage->>messageStore: loadMessages(sessionId)
  messageStore-->>ChatPage: restored messages
  ChatPage->>snapshotFromAgentPlanBlock: scan restored assistant blocks
  snapshotFromAgentPlanBlock-->>ChatPage: hydrated plan snapshot
  ChatPage->>agentPlanStore: clearSnapshot(sessionId)
  ChatPage->>agentPlanStore: applySnapshot(snapshot)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90+ minutes

Possibly related PRs

  • ThinkInAIXYZ/deepchat#1156: Both PRs touch ACP plan mapping and the structured plan-block shape used by the renderer.
  • ThinkInAIXYZ/deepchat#1635: This PR extends the same update_plan / chat.plan.updated flow with terminal-reason stamping and plan-state rehydration changes.

Poem

I hop through plan blocks, bright and new,
With interrupted steps that see me through.
The burrow reloads what the messages say,
And every turn finds its tidy way.
🐰 Thumpity-thump, the checklist rests today!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: persisting agent-plan blocks in history.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-plan-persistence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zerob13 zerob13 merged commit 3f4b96d into dev Jun 25, 2026
3 checks passed
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.

2 participants