Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat: show compaction summaries and handoff cards in every app

leepokaic8f88ddb6410
diff --git a/apps/desktop/src/renderer/store/bot-store.ts b/apps/desktop/src/renderer/store/bot-store.ts
index 07f8c780..43a6de6a 100644
--- a/apps/desktop/src/renderer/store/bot-store.ts
+++ b/apps/desktop/src/renderer/store/bot-store.ts
@@ -217,6 +217,34 @@ export class BotStore extends BotSync {
})()
}
+ /** Saves the user's version of a handoff that hasn't been sent; whether it did. */
+ async editHandoff(entry: Entry, text: string) {
+ try {
+ await this.withLink((c) => c.call('editHandoff', { entryId: entry.id, text }), true)
+ return true
+ } catch (error) {
+ this.lastError = error instanceof Error ? error.message : String(error)
+ this.changed()
+ return false
+ }
+ }
+
+ /** Carries on with the bot's current conversation instead of the handoff. */
+ keepConversation(entry: Entry) {
+ if (this.answering.has(entry.id)) return
+ this.answering.set(entry.id, 'handoff')
+ this.changed()
+ void (async () => {
+ try {
+ await this.withLink((c) => c.call('keepConversation', { entryId: entry.id }), true)
+ } catch (error) {
+ this.lastError = error instanceof Error ? error.message : String(error)
+ }
+ this.answering.delete(entry.id)
+ this.changed()
+ })()
+ }
+
/** The roster's "Mark as read": the chat and all its threads. */
markAllRead(botId: string) {
const bot = this.bots.get(botId)
diff --git a/apps/desktop/src/renderer/views/thread/ChatRows.tsx b/apps/desktop/src/renderer/views/thread/ChatRows.tsx
index 5a609be1..5e9ee56c 100644
--- a/apps/desktop/src/renderer/views/thread/ChatRows.tsx
+++ b/apps/desktop/src/renderer/views/thread/ChatRows.tsx
@@ -16,6 +16,7 @@ import { MarkdownText } from './Markdown'
import { PermissionCard } from './PermissionCard'
import { ConnectionRequestCard } from '../marketplace/ConnectionRequestCard'
import { MemoryNotice } from './MemoryNotice'
+import { CompactionNotice, HandoffNotice } from './HandoffNotice'
export function reactionPick(store: BotStore, entry: Entry): ReactionPick {
return { emoji: QUICK_REACTIONS, chosen: entry.data.reactions ?? [], toggle: (e) => store.react(entry, e) }
@@ -62,6 +63,8 @@ export const ChatRow = memo(function ChatRow({ entry, groupStart, chat, openTrac
default:
if (entry.data.connectionRequest) return <div style={{ paddingTop: 12 }}><ConnectionRequestCard entry={entry} /></div>
if (entry.data.memory) return <div style={{ paddingTop: 10 }}><MemoryNotice entry={entry} /></div>
+ if (entry.data.handoff) return <div style={{ paddingTop: 10 }}><HandoffNotice entry={entry} card={entry.data.handoff} /></div>
+ if (entry.data.compaction) return <div style={{ paddingTop: 10 }}><CompactionNotice entry={entry} compaction={entry.data.compaction} /></div>
return <div style={{ paddingTop: 10 }}><NoticeRow entry={entry} /></div>
}
})
diff --git a/apps/desktop/src/renderer/views/thread/HandoffNotice.tsx b/apps/desktop/src/renderer/views/thread/HandoffNotice.tsx
new file mode 100644
index 00000000..66d27ccf
--- /dev/null
+++ b/apps/desktop/src/renderer/views/thread/HandoffNotice.tsx
@@ -0,0 +1,83 @@
+import { useState } from 'react'
+import type { Compaction, Entry, HandoffCard } from '@shared/models'
+import { Button, CardForm, CardSection, Disclosure, IconButton, Spinner } from '../../components/Controls'
+import { Icon } from '../../components/Icon'
+import { ModalHeader, Sheet } from '../../components/Overlay'
+import { font } from '../../lib/fonts'
+import { useStore as useLiveStore } from '../../store/context'
+import { Field } from '../marketplace/pieces'
+import './handoff.css'
+
+function Line({ icon, text }: { icon: string; text?: string }) {
+ return (
+ <span className="handoff-line">
+ <Icon name={icon} size={11} />
+ <span>{text}</span>
+ </span>
+ )
+}
+
+/** "Earlier context was summarized to make room." The harness's summary unfolds under it when there is one. */
+export function CompactionNotice({ entry, compaction }: { entry: Entry; compaction: Compaction }) {
+ const [expanded, setExpanded] = useState(false)
+ const line = <Line icon="arrow.down.right.and.arrow.up.left" text={entry.data.text} />
+ if (!compaction.summary) return <div className="handoff-center">{line}</div>
+ return (
+ <div className="handoff-folded">
+ <Disclosure expanded={expanded} onToggle={() => setExpanded(!expanded)} label={line}>
+ <p className="handoff-text">{compaction.summary}</p>
+ </Disclosure>
+ </div>
+ )
+}
+
+/** The bot's chat starts over: what the new conversation carries, which the user can edit, or turn down to carry on. */
+export function HandoffNotice({ entry, card }: { entry: Entry; card: HandoffCard }) {
+ const store = useLiveStore()
+ const [expanded, setExpanded] = useState(false)
+ const [draft, setDraft] = useState<string | null>(null)
+ const [saving, setSaving] = useState(false)
+ const carried = <pre className="handoff-text handoff-carried">{card.text}</pre>
+ if (card.status !== 'draft') {
+ return (
+ <div className="handoff-folded">
+ <Disclosure expanded={expanded} onToggle={() => setExpanded(!expanded)} label={<Line icon="arrow.triangle.branch" text={entry.data.text} />}>
+ {carried}
+ </Disclosure>
+ </div>
+ )
+ }
+ const save = async () => {
+ if (draft === null || !draft.trim()) return
+ setSaving(true)
+ if (await store.editHandoff(entry, draft.trim())) setDraft(null)
+ setSaving(false)
+ }
+ return (
+ <div className="handoff-card">
+ <Line icon="arrow.triangle.branch" text={entry.data.text} />
+ <Disclosure expanded={expanded} onToggle={() => setExpanded(!expanded)} label={<span style={{ ...font('footnote'), fontWeight: 500 }}>What it carries</span>}>
+ {carried}
+ </Disclosure>
+ <div className="handoff-actions">
+ {store.answering.has(entry.id) ? <Spinner /> : <>
+ <Button kind="secondary" onClick={() => store.keepConversation(entry)}>Keep this conversation</Button>
+ <IconButton title="Edit what it carries" icon="pencil" onClick={() => setDraft(card.text ?? '')} />
+ </>}
+ </div>
+ <Sheet open={draft !== null} onClose={() => setDraft(null)} width={620}>
+ {draft !== null && <div className="handoff-editor">
+ <ModalHeader
+ title="Edit the handoff"
+ trailing={saving ? <Spinner /> : <IconButton title="Save" icon="checkmark" disabled={!draft.trim()} onClick={() => { void save() }} />}
+ />
+ <CardForm>
+ <CardSection footer="Your next message starts a fresh conversation that begins with this.">
+ <Field value={draft} onChange={setDraft} label="Handoff" lines={[10, 24]} mono />
+ </CardSection>
+ </CardForm>
+ </div>}
+ </Sheet>
+ </div>
+ )
+}
diff --git a/apps/desktop/src/renderer/views/thread/handoff.css b/apps/desktop/src/renderer/views/thread/handoff.css
new file mode 100644
index 00000000..0062c2ec
--- /dev/null
+++ b/apps/desktop/src/renderer/views/thread/handoff.css
@@ -0,0 +1,9 @@
+.handoff-line { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--secondary); min-width: 0; }
+.handoff-line span { overflow-wrap: anywhere; }
+.handoff-center { display: flex; justify-content: center; }
+.handoff-folded { max-width: 620px; margin: 0 auto; padding: 0 12px; }
+.handoff-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; background: var(--bubble-agent); max-width: 560px; }
+.handoff-actions { display: flex; align-items: center; gap: 8px; }
+.handoff-text { margin: 0; font-size: 12px; color: var(--secondary); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; line-height: 1.45; }
+.handoff-carried { font-family: var(--mono, ui-monospace, monospace); max-height: 320px; overflow: auto; }
+.handoff-editor { display: flex; flex-direction: column; height: 100%; background: var(--background); }
diff --git a/apps/desktop/src/shared/models.ts b/apps/desktop/src/shared/models.ts
index d2e04f8d..01b01000 100644
--- a/apps/desktop/src/shared/models.ts
+++ b/apps/desktop/src/shared/models.ts
@@ -171,9 +171,29 @@ export interface MemoryWrite {
error?: string
}
+/** "Earlier context was summarized": the harness's summary, when it gave one. */
+export interface Compaction {
+ summary?: string | null
+ /** The host started it ahead of time; otherwise the harness did when its context filled. */
+ byHost?: boolean
+}
+
+/** What a new conversation carries when the bot's own chat starts over; editable until the next message sends it. */
+export interface HandoffCard {
+ /** draft · sent · kept */
+ status: string
+ /** cold · away · full */
+ reason?: string
+ text?: string
+}
+
export interface EntryData {
/** Structured conversation data added to the existing team-tool notice. */
botMessage?: BotMessage
+ /** notice: the agent summarized its context (see `CompactionNotice`). */
+ compaction?: Compaction
+ /** notice: the bot's chat starts over with this handoff (see `HandoffNotice`). */
+ handoff?: HandoffCard
heading?: string
delegationId?: string
sourceBotId?: string
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/Compaction.swift b/apps/ios/Kit/Sources/CodyncKit/Models/Compaction.swift
new file mode 100644
index 00000000..a4fa7e98
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/Compaction.swift
@@ -0,0 +1,34 @@
+import Foundation
+
+/// "Earlier context was summarized": the harness's summary, when it gave one. Every field is optional so a newer
+/// host's line still decodes.
+public struct Compaction: Codable, Hashable, Sendable {
+ public var summary: String?
+ /// The host started it, ahead of time; otherwise the harness did when its context filled.
+ public var byHost: Bool?
+}
+
+/// What a new conversation carries when the bot's own chat starts over: editable until the user's next message
+/// there sends it.
+public struct HandoffCard: Codable, Hashable, Sendable {
+ /// draft · sent · kept
+ public var status: String?
+ /// cold · away · full
+ public var reason: String?
+ public var text: String?
+
+ public var isDraft: Bool { status == "draft" }
+}
+
+extension HostClient {
+ /// Saves the user's version of a handoff that hasn't been sent.
+ public func editHandoff(entryId: String, text: String) async throws {
+ struct Body: Encodable { var entryId: String; var text: String }
+ let _: Empty = try await call("editHandoff", Body(entryId: entryId, text: text))
+ }
+
+ /// Carries on with the old conversation instead of starting over.
+ public func keepConversation(entryId: String) async throws {
+ let _: Empty = try await call("keepConversation", ["entryId": entryId])
+ }
+}
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/EntryData.swift b/apps/ios/Kit/Sources/CodyncKit/Models/EntryData.swift
index 03616db9..48571c07 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Models/EntryData.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/EntryData.swift
@@ -4,6 +4,10 @@ public struct EntryData: Codable, Hashable, Sendable {
public var connectionRequest: ConnectionRequest?
/// A bot's memory write shown in the chat.
public var memory: MemoryWrite?
+ /// notice: the agent summarized its context.
+ public var compaction: Compaction?
+ /// notice: the bot's chat starts over with this handoff.
+ public var handoff: HandoffCard?
public var routineId: String?
public var runId: String?
public var text: String?
diff --git a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
index fafe7638..10690be3 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Store/BotStore+Actions.swift
@@ -200,6 +200,31 @@ extension BotStore {
}
}
+ /// Saves the user's version of a handoff that hasn't been sent. Whether it did.
+ public func editHandoff(_ entry: Entry, text: String) async -> Bool {
+ do {
+ try await withLink(replay: true) { try await $0.editHandoff(entryId: entry.id, text: text) }
+ return true
+ } catch {
+ lastError = error.localizedDescription
+ return false
+ }
+ }
+
+ /// Carries on with the bot's current conversation instead of the handoff.
+ public func keepConversation(_ entry: Entry) {
+ guard answering[entry.id] == nil else { return }
+ Motion.animate { answering[entry.id] = "handoff" }
+ Task {
+ do {
+ try await withLink(replay: true) { try await $0.keepConversation(entryId: entry.id) }
+ } catch {
+ lastError = error.localizedDescription
+ }
+ Motion.animate { answering[entry.id] = nil }
+ }
+ }
+
public func setFastMode(_ bot: Bot, _ fastMode: Bool) {
var d = BotDraft(bot)
d.fastMode = fastMode
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
index 04f9bba8..1c21c207 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
@@ -51,6 +51,10 @@ struct ChatRow: View {
ConnectionRequestCard(entry: entry, request: request).padding(.top, 12)
} else if let card = entry.data.memory {
MemoryNoticeRow(entry: entry, card: card).padding(.top, 10)
+ } else if let card = entry.data.handoff {
+ HandoffCardRow(entry: entry, card: card).padding(.top, 10)
+ } else if let compaction = entry.data.compaction {
+ CompactionRow(entry: entry, compaction: compaction).padding(.top, 10)
} else {
NoticeRow(entry: entry).padding(.top, 10)
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/HandoffRows.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/HandoffRows.swift
new file mode 100644
index 00000000..0597c125
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/HandoffRows.swift
@@ -0,0 +1,132 @@
+import CodyncKit
+import SwiftUI
+
+/// "Earlier context was summarized to make room." The harness's summary unfolds under it when there is one.
+struct CompactionRow: View {
+ let entry: Entry
+ let compaction: Compaction
+ @State private var expanded = false
+
+ var body: some View {
+ if let summary = compaction.summary, !summary.isEmpty {
+ Disclosure(isExpanded: $expanded) {
+ Text(summary)
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ .textSelection(.enabled)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ } label: {
+ line
+ }
+ .padding(.horizontal, 12)
+ } else {
+ line.frame(maxWidth: .infinity)
+ }
+ }
+
+ private var line: some View {
+ Label(entry.data.text ?? "", systemImage: "arrow.down.right.and.arrow.up.left")
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ }
+}
+
+/// The bot's chat starts over: what the new conversation carries, which the user can edit, or turn down to carry on.
+struct HandoffCardRow: View {
+ let entry: Entry
+ let card: HandoffCard
+ @Environment(BotStore.self) private var model
+ @State private var expanded = false
+ @State private var editing = false
+
+ var body: some View {
+ if card.isDraft {
+ VStack(alignment: .leading, spacing: 10) {
+ Label(entry.data.text ?? "", systemImage: "arrow.triangle.branch")
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ Disclosure(isExpanded: $expanded) {
+ carried
+ } label: {
+ Text("What it carries").font(.footnote.weight(.medium)).foregroundStyle(Palette.text)
+ }
+ HStack(spacing: 8) {
+ if model.answering[entry.id] != nil {
+ Spinner()
+ } else {
+ Button("Keep this conversation") { model.keepConversation(entry) }
+ .buttonStyle(SecondaryButtonStyle())
+ IconButton("Edit what it carries", systemImage: "pencil") {
+ withAnimation(Motion.layout) { editing = true }
+ }
+ }
+ }
+ }
+ .padding(12)
+ .background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 14))
+ .padding(.trailing, 40)
+ .codyncSheet(isPresented: $editing) { HandoffEditorView(entry: entry, text: card.text ?? "") }
+ } else {
+ Disclosure(isExpanded: $expanded) {
+ carried
+ } label: {
+ Label(entry.data.text ?? "", systemImage: "arrow.triangle.branch")
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ }
+ .padding(.horizontal, 12)
+ }
+ }
+
+ private var carried: some View {
+ Text(card.text ?? "")
+ .font(.footnote.monospaced())
+ .foregroundStyle(Palette.secondary)
+ .textSelection(.enabled)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+}
+
+/// Edits what the next conversation starts with.
+struct HandoffEditorView: View {
+ let entry: Entry
+ @State private var text: String
+ @State private var saving = false
+ @Environment(BotStore.self) private var model
+ @Environment(\.dismissModal) private var dismiss
+
+ init(entry: Entry, text: String) {
+ self.entry = entry
+ _text = State(initialValue: text)
+ }
+
+ var body: some View {
+ VStack(spacing: 0) {
+ ModalHeader("Edit the handoff") {
+ if saving {
+ Spinner()
+ } else {
+ IconButton("Save", systemImage: "checkmark") {
+ saving = true
+ Task {
+ if await model.editHandoff(entry, text: trimmed) { dismiss() }
+ saving = false
+ }
+ }
+ .disabled(trimmed.isEmpty)
+ }
+ }
+ CardForm {
+ CardSection(footer: "Your next message starts a fresh conversation that begins with this.") {
+ TextField("What the new conversation should know", text: $text, axis: .vertical)
+ .lineLimit(10...24)
+ .font(.footnote.monospaced())
+ }
+ }
+ .textFieldStyle(.plain)
+ }
+ .background(Palette.background)
+ }
+
+ private var trimmed: String { text.trimmingCharacters(in: .whitespacesAndNewlines) }
+}
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/MemoryTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/MemoryTests.swift
index fb6baf0a..0424503b 100644
--- a/apps/ios/Kit/Tests/CodyncKitTests/MemoryTests.swift
+++ b/apps/ios/Kit/Tests/CodyncKitTests/MemoryTests.swift
@@ -36,3 +36,12 @@ import Testing
#expect(try decode("declined")?.choice == nil)
#expect(try decode("something-newer")?.choice == nil)
}
+
+@Test func compactionLinesAndHandoffCardsDecode() throws {
+ let decode = { (json: String) in try JSONDecoder().decode(EntryData.self, from: Data(json.utf8)) }
+ let line = try decode(#"{"text": "Earlier context was summarized.", "compaction": {"summary": "Planned a trip.", "byHost": true}}"#)
+ #expect(line.compaction?.summary == "Planned a trip.")
+ let card = try decode(#"{"text": "…", "handoff": {"status": "draft", "reason": "cold", "text": "<handoff>…</handoff>"}}"#)
+ #expect(card.handoff?.isDraft == true)
+ #expect(try decode(#"{"handoff": {"status": "sent"}}"#).handoff?.isDraft == false)
+}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 9470e656..d84f7ba5 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -13,6 +13,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
- bot 記下一件事時,聊天裡會顯示出來,一鍵就能復原;設定成「先問我」的 bot 會改用卡片詢問,由你決定要不要記。
- bot 會在空檔時整理記憶,只採用你親口打的字,貼上或引用的內容不算;每次整理都列在 Dreams 裡,可以復原。
- 原本的記憶會自動搬過來。
+- 對話太長時,bot 會先摘要較早的內容,摘要可以在聊天裡展開;摘要也不夠用時,會改用一張卡片開新對話,你可以先編輯它要帶過去的內容,或選擇保留原本的對話。
### en-US
@@ -20,6 +21,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
- When a bot remembers something, the chat shows it with a one-tap undo. A bot set to ask first shows a card instead, and you decide.
- Between chats, bots tidy their memory using only words you typed yourself, not pasted or quoted text. Every run is listed under Dreams and can be undone.
- Your existing memory moves over automatically.
+- When a chat runs long, the bot summarizes the earlier part, and you can open the summary in the chat. When that's no longer enough, a card offers a fresh conversation: edit what it carries over, or keep the current one.
## 2.17.5
diff --git a/docs/features/context-and-memory.md b/docs/features/context-and-memory.md
index 5417dc51..c7b46998 100644
--- a/docs/features/context-and-memory.md
+++ b/docs/features/context-and-memory.md
@@ -104,6 +104,9 @@ the `codync-mem` crate; `chat/memory` runs them in the host.
a new session that begins with it.
- **After every compaction** the chat shows "Earlier context was summarized to make room." Its `compaction`
field carries Claude's summary, which the apps show when expanded, and which the next handoff starts from.
+- **In the apps:** the iPhone and desktop show the draft card with *Keep this conversation* and a pencil that
+ opens the editor sheet; once sent or kept it folds to one line. In the terminal, pick the line (`v`, `j`/`k`),
+ then `o` unfolds it, `e` edits and `K` keeps the chat.
## Turns
diff --git a/host/src/tui/app/mod.rs b/host/src/tui/app/mod.rs
index 25b89ce7..8959e6f7 100644
--- a/host/src/tui/app/mod.rs
+++ b/host/src/tui/app/mod.rs
@@ -89,6 +89,8 @@ pub struct App {
pub thread: Option<String>,
/// A main-chat message picked to reply to in its thread (`r`, then j/k and ↵).
pub pick: Option<String>,
+ /// Chat lines showing their full text: a compaction's summary, a handoff (`o` on the picked line).
+ pub unfolded: HashSet<String>,
pub market: (Vec<Toggle>, Vec<Toggle>),
/// Installed connectors and skills as the host lists them.
pub plugins: (Vec<Value>, Vec<Value>),
@@ -158,6 +160,7 @@ impl App {
chat_top: false,
thread: None,
pick: None,
+ unfolded: HashSet::new(),
market: (vec![], vec![]),
plugins: (vec![], vec![]),
models: HashMap::new(),
diff --git a/host/src/tui/app/model.rs b/host/src/tui/app/model.rs
index 60649791..e3448a41 100644
--- a/host/src/tui/app/model.rs
+++ b/host/src/tui/app/model.rs
@@ -340,6 +340,11 @@ impl Entry {
|| self.data["memory"].is_object()
}
+ /// A line that folds away a longer text: a compaction's summary, or a handoff (`o` shows it).
+ pub fn unfolds(&self) -> bool {
+ crate::tui::view::unfoldable(self).is_some()
+ }
+
/// A notice for a bot-to-bot message or request (`chat::team`).
pub fn is_bot_message(&self) -> bool {
self.kind == Kind::Notice
diff --git a/host/src/tui/app/navigate.rs b/host/src/tui/app/navigate.rs
index 900e2d6c..694e868b 100644
--- a/host/src/tui/app/navigate.rs
+++ b/host/src/tui/app/navigate.rs
@@ -134,7 +134,9 @@ impl App {
let picks: Vec<(String, bool)> = group(&id, &lane, self.thread.is_none())
.into_iter()
.filter_map(|item| match item {
- Item::Entry(e) if e.is_message() || e.is_bot_message() => Some((e.id.clone(), e.is_message())),
+ Item::Entry(e) if e.is_message() || e.is_bot_message() || e.unfolds() => {
+ Some((e.id.clone(), e.is_message()))
+ }
Item::Group(g) => Some((g.first.id.clone(), false)),
Item::Entry(_) => None,
})
@@ -204,6 +206,23 @@ impl App {
self.call("undoMemory", json!({"entryId": e.id}), After::Answered(e.id.clone()));
}
}
+ KeyCode::Char('o') if picked.as_ref().is_some_and(super::Entry::unfolds) => {
+ if let Some(e) = picked
+ && !self.unfolded.remove(&e.id)
+ {
+ self.unfolded.insert(e.id);
+ }
+ }
+ KeyCode::Char('e') if picked.as_ref().is_some_and(|e| e.data["handoff"]["status"] == "draft") => {
+ if let Some(e) = picked {
+ self.overlays.push(super::Overlay::Fields(Box::new(crate::tui::manage::handoff_fields(&e))));
+ }
+ }
+ KeyCode::Char('K') if picked.as_ref().is_some_and(|e| e.data["handoff"]["status"] == "draft") => {
+ if let Some(e) = picked {
+ self.call("keepConversation", json!({"entryId": e.id}), After::Answered(e.id.clone()));
+ }
+ }
KeyCode::Enter | KeyCode::Char('r') if self.thread.is_some() => {
self.pick = None;
self.start_typing();
diff --git a/host/src/tui/manage/fields.rs b/host/src/tui/manage/fields.rs
index 6487531a..452b97af 100644
--- a/host/src/tui/manage/fields.rs
+++ b/host/src/tui/manage/fields.rs
@@ -1,11 +1,11 @@
-//! The labeled text fields sheet: keys, connector setup, a pasted MCP config.
+//! The labeled text fields sheet: keys, connector setup, a pasted MCP config, a handoff.
use crossterm::event::{KeyCode, KeyEvent};
use serde_json::{Value, json};
-use super::super::app::{App, Overlay};
+use super::super::app::{App, Editor, Entry, Overlay};
use super::market::connector_inputs;
-use super::{Fields, Reply, Submit, ctrl, newline};
+use super::{Fields, Input, Reply, Submit, ctrl, newline};
impl App {
pub(in crate::tui) fn fields_key(&mut self, mut f: Box<Fields>, k: KeyEvent) -> Option<Overlay> {
@@ -75,6 +75,32 @@ impl App {
);
}
Submit::Import => self.sheet("importConnectors", json!({"config": values["config"]}), Reply::FieldsSaved),
+ Submit::Handoff(entry) => {
+ self.sheet("editHandoff", json!({"entryId": entry, "text": values["text"]}), Reply::FieldsSaved);
+ }
}
}
}
+
+/// Edits what a handoff card carries into the next conversation.
+pub fn handoff_fields(entry: &Entry) -> Fields {
+ Fields {
+ title: "Edit the handoff".into(),
+ note: "Your next message starts a fresh conversation that begins with this. ⇧↵ new line, ↵ saves.".into(),
+ choices: vec![],
+ choice: 0,
+ inputs: vec![Input {
+ name: "text".into(),
+ label: "What it carries".into(),
+ secret: false,
+ required: true,
+ multiline: true,
+ placeholder: String::new(),
+ ed: Editor::with(entry.data["handoff"]["text"].as_str().unwrap_or_default()),
+ }],
+ cursor: 0,
+ error: None,
+ saving: false,
+ submit: Submit::Handoff(entry.id.clone()),
+ }
+}
diff --git a/host/src/tui/manage/mod.rs b/host/src/tui/manage/mod.rs
index a8a322b9..fcc5a5d5 100644
--- a/host/src/tui/manage/mod.rs
+++ b/host/src/tui/manage/mod.rs
@@ -16,6 +16,7 @@ mod routines;
mod skill;
pub use analytics::AnalyticsSheet;
+pub use fields::handoff_fields;
pub use memory::{MemoryMode, MemorySheet, Section};
pub use routines::local_zone;
pub use skill::SkillSheet;
@@ -166,6 +167,8 @@ pub enum Submit {
Connection(Box<super::connections::Connection>),
Connector(Value),
Import,
+ /// A handoff card's text (the card's entry id).
+ Handoff(String),
}
/// A few labeled text fields: an agent's keys, a connector's setup, a pasted MCP config.
diff --git a/host/src/tui/view/help.rs b/host/src/tui/view/help.rs
index c3c495bd..2af7004d 100644
--- a/host/src/tui/view/help.rs
+++ b/host/src/tui/view/help.rs
@@ -9,7 +9,7 @@ use super::buffer::{centered, frame_box, put, u};
use super::overlay::field_line;
use super::style::theme;
-const HELP: [(&str, &str, &str); 57] = [
+const HELP: [(&str, &str, &str); 59] = [
("MOVE", "j k ↑ ↓", "next / previous bot"),
("MOVE", "[ ]", "previous / next bot"),
("MOVE", "1…9", "jump to bot 1–9"),
@@ -34,6 +34,8 @@ const HELP: [(&str, &str, &str); 57] = [
("CHAT", "j k ↵", "picking: move / open"),
("CHAT", "1…6", "picking: react"),
("CHAT", "f", "picking: save its files"),
+ ("CHAT", "o", "picking: show a summary or handoff"),
+ ("CHAT", "e K", "picking a handoff: edit / keep the chat"),
("CHAT", "↵", "picking a bot message: open its conversation"),
("CHAT", "esc", "close the thread"),
("TYPE", "↵", "send"),
diff --git a/host/src/tui/view/mod.rs b/host/src/tui/view/mod.rs
index 9f7c69dd..9cdc4612 100644
--- a/host/src/tui/view/mod.rs
+++ b/host/src/tui/view/mod.rs
@@ -30,6 +30,7 @@ pub(super) use chat::composer_lines;
pub(super) use overlay::{field_line, input_line};
pub(super) use style::theme;
pub(super) use time::when;
+pub(super) use transcript::unfoldable;
pub(super) use usage::when_future;
use ratatui::Frame;
diff --git a/host/src/tui/view/transcript.rs b/host/src/tui/view/transcript.rs
index cb3e6723..b17a8320 100644
--- a/host/src/tui/view/transcript.rs
+++ b/host/src/tui/view/transcript.rs
@@ -303,6 +303,13 @@ fn entry_lines(
_ => "",
};
format!("{}{hint}", e.notice_text())
+ } else if let Some(status) = e.data["handoff"]["status"].as_str() {
+ // The chat starts over with a handoff: read it, edit it or keep the conversation while it's a draft.
+ let hint =
+ if status == "draft" { " · o shows it · e edits · K keeps this chat" } else { " · o shows it" };
+ format!("{}{hint}", e.notice_text())
+ } else if e.data["compaction"]["summary"].is_string() {
+ format!("{} · o shows the summary", e.notice_text())
} else {
e.notice_text()
};
@@ -326,7 +333,18 @@ fn entry_lines(
&[Span::raw(" ")],
)),
}
- if e.data["connectionRequest"].is_object() || e.data["memory"].is_object() {
+ let folded = unfoldable(e);
+ if app.unfolded.contains(&e.id)
+ && let Some(full) = folded
+ {
+ out.lines.extend(md::wrap(
+ &[Span::styled(full.to_owned(), t.dim)],
+ width,
+ &[Span::raw(" │ ")],
+ &[Span::raw(" │ ")],
+ ));
+ }
+ if e.data["connectionRequest"].is_object() || e.data["memory"].is_object() || folded.is_some() {
out.messages.push((e.id.clone(), from, out.lines.len()));
}
}
@@ -334,6 +352,11 @@ fn entry_lines(
}
}
+/// The full text a chat line folds away: a compaction's summary, or what a handoff carries.
+pub(in crate::tui) fn unfoldable(e: &Entry) -> Option<&str> {
+ e.data["handoff"]["text"].as_str().or_else(|| e.data["compaction"]["summary"].as_str()).filter(|t| !t.is_empty())
+}
+
/// A bot-to-bot exchange, or a run of them, as one compact line ("· Messaged ▌O▐ Owen",
/// "· 3 messages with ▌O▐ Owen"); click opens the conversation with `peer`.
/// Only a failure is marked: its text lives in the conversation sheet.