Repository navigation
Description
Overview
Implement opt-in session capture for PTY agent sessions. When enabled, nodespaced creates an ai-chat node at session end containing configurable levels of session content: metadata only, a summary, or the full transcript. Capture is off by default, controlled by user settings, and the session ID is never synced externally.
Problem Statement
PTY sessions produce valuable context — decisions made, code written, problems solved. Without capture, this context is lost when the terminal closes. Users who want to preserve session context in their knowledge graph need an opt-in mechanism that respects privacy (off by default, configurable content level) and stays within NodeSpace's data model (ai-chat node type).
Proposed Solution
PtySession accumulates output chunks in a circular buffer (capped to avoid unbounded memory). On session end (natural exit or terminate), if capture is enabled in settings, nodespaced assembles the content per the configured level and creates an ai-chat node via the NodeService ops layer. The agent_session_id (UUID) is stored as a local-only node property, never synced.
Acceptance Criteria
Settings
- Three capture settings stored in NodeSpace user config:
capture.enabled(bool, default:false)capture.sync(bool, default:false— session nodes excluded from sync)capture.content(enum:metadata_only|summary|full, default:metadata_only)
- Settings readable and writable via a
GetSettings/UpdateSettingsgRPC call (or existing settings mechanism) - Settings UI in the desktop app (toggle + content level selector)
Session capture
- When
capture.enabled = false: no node is created at session end (default behavior) - When
capture.enabled = true, content = metadata_only:ai-chatnode created with: agent type, start time, end time, exit code, session ID - When
capture.enabled = true, content = summary: as above plus a brief summary (first 500 chars of output or agent's final response if detectable) - When
capture.enabled = true, content = full: as above plus full transcript (all output chunks concatenated) -
ai-chatnode created using the existingai-chatschema viaNodeService.CreateNode -
agent_session_idstored as a node property; not included in sync payload - Session capture happens after the PTY process exits; it does not block session termination
- Failed capture (e.g., ops error) is logged but does not surface as an error to the user
-
capture.sync = false(default): sync service excludes nodes withagent_session_idproperty
UI
-
AgentLaunchPanel.svelteshows capture settings (enabled toggle, content level selector) before launch - After a captured session, a link to the created
ai-chatnode is shown in the sessions panel
Testing
- Unit test:
metadata_onlycapture creates a node with correct fields and no transcript - Unit test:
fullcapture creates a node with the full output buffer - Unit test: capture disabled → no node created
- All frontend tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Files to create/modify
packages/agent/src/pty/capture.rs(NEW) —SessionCapturestruct: output ring buffer,finalize()method that assembles the ai-chat node payloadpackages/agent/src/pty/session.rs— integrateSessionCapture: accumulate output chunks; callcapture.finalize()on exitpackages/daemon/src/capture_service.rs(NEW) — after session exit, callsNodeServiceops to create the ai-chat nodepackages/desktop-app/src/lib/components/agent/AgentLaunchPanel.svelte— add capture settings controlspackages/desktop-app/src/lib/components/agent/SessionsPanel.svelte— show link to captured node after session end
ai-chat node schema
The ai-chat node type already exists in the schema. The capture creates a node with:
node_type: "ai-chat"
content: "<agent_type> session — <start_time>"
properties:
agent_type: "claude_code" | "codex" | "gemini" | "pi" | "opencode"
started_at: ISO 8601 timestamp
ended_at: ISO 8601 timestamp
exit_code: integer
agent_session_id: UUID string (local-only, excluded from sync)
transcript: string (only present when content = "full")
summary: string (only present when content = "summary" or "full")
Output ring buffer
pub struct SessionCapture {
buffer: VecDeque<OutputChunk>,
max_bytes: usize,
current_bytes: usize,
}
impl SessionCapture {
pub fn push(&mut self, chunk: OutputChunk) { ... } // evicts oldest on overflow
pub fn transcript(&self) -> String { ... } // all chunks concatenated
pub fn summary(&self) -> String { ... } // first 500 chars
}Max buffer size: 1 MB (configurable constant). Older chunks are evicted when the buffer is full.
Sync exclusion
The sync service checks for the agent_session_id property and excludes matching nodes from sync payloads when capture.sync = false. This is implemented as a filter in the sync service, not by using a separate node type.
Reference files
packages/agent/src/pty/session.rs— PtySession (from Implement PtySessionManager and PtySession in packages/agent #1118)packages/core/src/ops/— NodeService ops layer for creating the ai-chat nodepackages/desktop-app/src/lib/components/agent/AgentLaunchPanel.svelte— launch panel (from Add Tauri commands and xterm.js terminal UI for PTY agent sessions #1120)
Dependencies
- Implement PtySessionManager and PtySession in packages/agent #1118
- Implement AgentSessionService gRPC handler in nodespaced #1119
- Add Tauri commands and xterm.js terminal UI for PTY agent sessions #1120
Non-Goals
- Automatic summarization via LLM (summary is a text truncation, not an AI-generated summary)
- Streaming capture to the node during the session (capture happens only at end)
- Exporting transcripts to formats other than the ai-chat node (future)
- Capture of stdin (only stdout/stderr is captured)
Activity
malibio commentedon May 18, 2026
Frontend baseline: 128 test files, 3916 tests passed
Implement opt-in session capture: create ai-chat node at PTY session …
Implement opt-in session capture: create ai-chat node at PTY session …
Implement opt-in session capture: create ai-chat node at PTY session …