Skip to content

feat(cli_chat): unified agent panel 2a — ConversationBackend core + history migration#205

Merged
BunsDev merged 4 commits into
mainfrom
feat/unified-agent-panel-2a
Jul 18, 2026
Merged

feat(cli_chat): unified agent panel 2a — ConversationBackend core + history migration#205
BunsDev merged 4 commits into
mainfrom
feat/unified-agent-panel-2a

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 18, 2026

Copy link
Copy Markdown
Member

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_chat panel.

Why: CastCodes still has two AI-conversation surfaces (the shipped ai_assistant/Familiar daemon panel and the feature-flagged cli_chat CLI panel). Phase 1 (#201) unified their rendering via agent_transcript. 2a unifies the data model so a single panel (2b–2d) can list, persist, and restore conversations from both backends.

How:

  • New ConversationBackend { Cli(AgentKind) | Daemon { harness } }; ChatConversation carries a backend instead of a bare AgentKind.
  • sqlite schema v2 adds a chat_conversation.backend column (cli | daemon) via the existing versioned migration; legacy rows backfill to cli.
  • Store reads/writes both columns and round-trips Cli/Daemon conversations.
  • Non-destructive, idempotent migration of the daemon panel's ~/.coven/stream-history.json into coven-code Daemon conversations (one text blob → one AssistantResponse entry; source file renamed .migrated, never deleted).

Reuses Phase 1's agent_transcript ChatEntry render 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-existing cli_chat suite is unchanged (proves the generalization is behavior-preserving), plus new tests: ConversationBackend round-trip, unknown-agent fallback, v1→v2 backend backfill, and history-migration insert + idempotency.
  • cargo clippy -p warp-app --features cast-agent --all-targets -- -D warnings clean; cargo fmt -p warp-app -- --check clean.
  • ./script/check_ai_attribution, ./script/check_rebrand, ./script/check_cli_chat_boundary pass.
  • Not manually run with ./script/run — no user-visible surface in 2a (data layer only).

Agent Mode

@BunsDev
BunsDev marked this pull request as ready for review July 18, 2026 06:08
Copilot AI review requested due to automatic review settings July 18, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConversationBackend and migrate ChatConversation from agent: AgentKind to backend: ConversationBackend.
  • Bump sqlite schema to v2 by adding chat_conversation.backend with a default backfill to cli, and update store read/write paths accordingly.
  • Add an idempotent helper to migrate ~/.coven/stream-history.json into sqlite as Daemon { 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_conversation does not update the persisted agent/backend columns on conflict. If a session_id ever 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");
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