feat(cli_chat): unified agent panel 2a — ConversationBackend core + history migration#205
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements Phase 2a’s shared conversation core for cli_chat by introducing a backend discriminator (Cli vs Daemon) into the conversation model, persisting it in sqlite via a schema v2 migration, and adding a non-destructive daemon history import helper (not yet wired into UI startup).
Changes:
- Introduce
ConversationBackendand migrateChatConversationfromagent: AgentKindtobackend: ConversationBackend. - Bump sqlite schema to v2 by adding
chat_conversation.backendwith a default backfill tocli, and update store read/write paths accordingly. - Add an idempotent helper to migrate
~/.coven/stream-history.jsoninto sqlite asDaemon { harness: "coven-code" }conversations, plus targeted tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/cli_chat/view/model_picker.rs | Switch model-picker labeling to read agent/model from ConversationBackend. |
| app/src/cli_chat/view/conversation_list.rs | Render conversation titles/subtitles using ConversationBackend display naming. |
| app/src/cli_chat/store.rs | Persist/load backend alongside legacy agent (now “name”) column; reconstruct backend from both. |
| app/src/cli_chat/store_tests.rs | Update store tests for ConversationBackend and validate round-trips. |
| app/src/cli_chat/store_schema.rs | Schema v2: add backend column with default 'cli'. |
| app/src/cli_chat/store_schema_tests.rs | Add coverage ensuring v1→v2 migration backfills backend = 'cli'. |
| app/src/cli_chat/model.rs | Update conversation creation to wrap CLI agents in ConversationBackend::Cli. |
| app/src/cli_chat/mod.rs | Expose new history_migration module. |
| app/src/cli_chat/history_migration.rs | Add daemon stream-history.json → sqlite migration helper + tests. |
| app/src/cli_chat/conversation.rs | Add ConversationBackend and parsing helpers; move conversation ownership to backend. |
| app/src/cli_chat/conversation_tests.rs | Add tests for backend persistence round-trip and unknown-agent fallback behavior. |
Comments suppressed due to low confidence (1)
app/src/cli_chat/store.rs:51
upsert_conversationdoes not update the persistedagent/backendcolumns on conflict. If asession_idever collides across backends (e.g. daemon history migration ID matches an existing CLI session, or a conversation is re-created with a different backend), the row will retain the old discriminator and be reconstructed as the wrong backend on read.
ON CONFLICT(session_id) DO UPDATE SET
title = excluded.title,
cwd = excluded.cwd,
project = excluded.project,
updated_at = excluded.updated_at,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| Some(r) => r, | ||
| None => { | ||
| log::warn!("cast_agent: stream-history.json unreadable/malformed; skipping migration"); |
| } | ||
| }; | ||
| if let Err(e) = migrate_history_records(store, &records, now) { | ||
| log::warn!("cast_agent: stream-history migration failed: {e}; leaving file in place"); |
This was referenced Jul 18, 2026
This was referenced Jul 18, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What: Sub-phase 2a of the Coven agent-surface reconciliation (design in #204). This lands the shared conversation core + persistence migration that a unified agent panel will sit on — no UI yet, and fully behavior-preserving for the existing
cli_chatpanel.Why: CastCodes still has two AI-conversation surfaces (the shipped
ai_assistant/Familiar daemon panel and the feature-flaggedcli_chatCLI panel). Phase 1 (#201) unified their rendering viaagent_transcript. 2a unifies the data model so a single panel (2b–2d) can list, persist, and restore conversations from both backends.How:
ConversationBackend { Cli(AgentKind) | Daemon { harness } };ChatConversationcarries abackendinstead of a bareAgentKind.chat_conversation.backendcolumn (cli|daemon) via the existing versioned migration; legacy rows backfill tocli.Cli/Daemonconversations.~/.coven/stream-history.jsonintocoven-codeDaemonconversations (one text blob → oneAssistantResponseentry; source file renamed.migrated, never deleted).Reuses Phase 1's
agent_transcriptChatEntryrender model. The unified panel view, composer routing, daemon conversation source, entry point, and deprecation are out of scope here — they are 2b–2d (separate plans).Linked Issue
Continues the reconciliation roadmap (design/spec in #204; Phase 1 shipped in #201). No separate tracking issue, per the #204 precedent.
Testing
cargo nextest run -p warp-app --features cast-agent -E 'test(cli_chat::)'→ 36/36 pass — the full pre-existingcli_chatsuite is unchanged (proves the generalization is behavior-preserving), plus new tests:ConversationBackendround-trip, unknown-agent fallback, v1→v2backendbackfill, and history-migration insert + idempotency.cargo clippy -p warp-app --features cast-agent --all-targets -- -D warningsclean;cargo fmt -p warp-app -- --checkclean../script/check_ai_attribution,./script/check_rebrand,./script/check_cli_chat_boundarypass../script/run— no user-visible surface in 2a (data layer only).Agent Mode