Skip to content

Make PTY capture store a prose summary and the harness's own session id #3454

Closed

Description

@malibio

Overview

ADR-061 §7 says a terminal (PTY) chat's summary is the cross-device artefact: locally derived prose with ANSI stripped, not raw output. §6 says its session id names the harness's own state (~/.claude/…, ~/.codex/sessions/…), marked local_only. Capture currently does neither.

Problem Statement

  • The summary is raw output. SessionCapture::summary() (packages/agent/src/pty/capture.rs) returns the first 500 bytes of the raw transcript (SUMMARY_MAX_BYTES), including ANSI escapes and TUI repaints. Once a long session overflows the 1 MiB ring buffer, those bytes are an arbitrary mid-session fragment. The summary isn't local_only, so it's the one piece of raw scrollback allowed to leave the device, which ADR-061 §7 rules out.
  • The stored id isn't resumable. Capture stores the daemon's PTY session id (session.id, packages/daemon/src/services/capture_service.rs). It can re-attach to a live terminal, but a harness can't resume from it.

Proposed Solution

  1. Summary: strip ANSI and terminal control sequences from the transcript, then derive a short prose summary locally. Use the native model when it's available. When no summarizer is available, store no summary, which is ADR-061 §7's metadata-only fallback, rather than raw bytes.
  2. Session id: record the harness's own resumable session id for the harnesses that expose one (Claude Code, Codex), discovered from the harness's session store after it exits, as a local_only field of ai-chat-pty. Keep the daemon PTY id only if re-attaching to a live session needs it after restart; otherwise drop it.
  3. Both fields are written through the validated update (see Split ai-chat into an abstract base with ai-chat-native and ai-chat-pty subtypes #3446).

Architecture Impact

Brings the code in line with ADR-061 §6 and §7 (decisions/061-ai-chat-private-by-default-and-machine-bound-properties.md) and ADR-088 (ai-chat-pty fields). No ADR change. The resume feature itself (relaunching a harness with its resume flag, and a Resume button) is separate work.

Acceptance Criteria

  • Follows development/node-type-sequence.md; the ai-chat-pty sheet in components/node-types.md stays accurate
  • A stored summary contains no ANSI or control sequences and is prose, or is absent (tests with a transcript that has escapes, and one that overflowed the buffer)
  • For Claude Code and Codex sessions, the harness's resumable session id is stored local_only (tests with fixture session stores)
  • bun run test:changed passes; bun run quality:fix clean

Technical Specifications

Reference Files

  • packages/agent/src/pty/capture.rs (SessionCapture, summary, transcript)
  • packages/daemon/src/services/capture_service.rs (build_capture_properties, finalize_capture)
  • packages/daemon/src/services/agent_session_service.rs
  • packages/desktop-app/src/lib/components/viewers/ai-chat-pty-session.svelte

Dependencies

Non-Goals

  • Resuming a harness session from the UI
  • Embedding summaries (future work under ADR-061 §4)

Activity

  1. malibio commented on Oct 2, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 303 test files, 5559 tests passed

  2. self-assigned this
    on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions