Skip to content

feat: open existing sessions, continue by default, fast picker (#245, #235) - #247

Merged
JAORMX merged 9 commits into
mainfrom
feat/session-open-245
Jul 13, 2026
Merged

JAORMX merged 9 commits into
mainfrom
feat/session-open-245

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #245. Closes #235.

Open an existing session by ID and continue it live — end-to-end: a public event-replay RPC over the existing durable port.EventLog, client wrappers, a /sessions picker with Sessions and Children tabs, transcript rendering, and a #235 jump-to-fire-transcript shortcut from the schedule inspect view.

The design follows the cloud-native discipline (ADR 0027): the loop stays storage-agnostic (it only emits; the relay persists), the replay RPC is a server-only read over port.EventLog.Read, the log records already-redacted events (gauntlet #7), and a nil EventLog is the byte-identical default (UNIMPLEMENTED).

What shipped (this branch)

Continue by default (the operator-directive change)

Opening a top-level agent session from /sessions goes straight to live/interactive (phaseIdle, textarea focused) — the read-only phaseReplay mode is eliminated for top-level sessions. The prior conversation loads into the scrollback via the replay stream before the live handoff (on stream close, the transcript carries into m.conv and the phase goes to phaseIdle). Empty/erroring logs still continue (the server holds the history regardless). The old continueSession func and the bare c key are removed as dead code. Children (subagent/team/parallel, identified by id prefix) stay read-only (phaseReplay) from the Children tab — continuing a child as a top-level live session is incoherent.

The confirm-overlay step is gone: Enter on a picker row opens the session directly (the isSessionOpenable gate stays — running/awaiting sessions warn and stay on the picker).

Sessions | Children tabs + type badges

The picker has a tab bar (tab switches): Sessions (top-level agent sessions only, the default tab) and Children (subagent/team/parallel, each row badged [subagent]/[team]/[parallel]). The child-id prefix is the classifier — pure string-prefix matching on the id (the prefix is a stable wire-side contract from engine/agent/childregistry.go, mirrored as local constants because cmd/mecatui/ui must not import engine/agent).

port.MetaLister — fast picker listing

ListSessions used to call full Store.Load per session (scanning the whole .session.jsonl + unmarshaling the messages array) — O(N × filesize), visibly slow. Added an optional port.MetaLister interface (MetaList(ctx) ([]SessionMeta, error)) discovered by type assertion (the same pattern as PrunableStore); SessionStore (Save/Load) is unchanged. jsonlstore implements MetaList via a tail-read (readLastLine seeks the last 64KiB, scans backward) decoding into a small struct that skips messages — O(N × last-line-read). Service.ListSessions prefers MetaLister, falls back to Load-per-row for stores that don't implement it (memstore/redisstore/grpcdriver).

Replay render coalescing

updateReplayMsg now uses markDirtyReplay (the 16ms coalesced flush, like the live path) instead of refreshView() per event — O(N) not O(N²). onRenderTick's phase gate widened to phaseRunning || phaseReplay. Terminal arms (StreamClosed/StreamErr) still force-flush.

Server: StreamSessionEvents + ListSessions RPCs

  • StreamSessionEvents(session_id) server-streaming gRPC + SSE HTTP, backed by port.EventLog.Read. Replays the full durable timeline including the three log-only kinds (EvApproval/EvCompactionArchive/EvUserPrompt) the live Converse relay skips — a transcript viewer wants the verdicts and user prompts. The proto Event gained fields 16/17/18 + four new messages.
  • ListSessions unary, backed by PrunableStore.List (+ the MetaLister fast path).
  • SessionSnapshot gained State.

Client: StreamSessionEvents + ListSessions wrappers

The readEventLoop extraction: the live Converse stream and the replay both feed the SAME EventToMsg translation (projection equivalence — a replayed event renders identically to a live event).

#235 jump-to-fire-transcript

The schedule inspect view has a fire cursor (↑/↓) + enter/t to jump directly to the fire's session, reusing the continue-by-default path (a fire is top-level → continues live).

Session.Title — set-once label

Session.Title is a human-readable session label seeded ONCE from the first genuine user prompt (clamped to 120 runes), persisted in the snapshot (additive omitempty), with a lazy display-time fallback (DeriveTitle). Wire: proto Session + SessionSummary gain title; the picker row leads with the title, falling back to the id. Engine API: task api:update (engine/api/session.txt); engine/CHANGELOG.md ### Added (minor).

Panel-review fixes (commits bdc25fa + b81dd0a)

  • Sanitized s.State on the confirm card (sanitizeTerminal).
  • Fixed stale "open read-only" wording.
  • Deleted dead childTypeBadge.
  • Extracted scanLastNonBlankLine across Load/decodeSessionID/MetaList (one scan discipline — the picker fast path can't drift from Load's truth).
  • Reuse shrinks: collapsed redundant head decode + metaCounters; replaced hand-rolled trimTrailingNewline/lastIndexNewline with bytes stdlib.
  • Three drift tripwires: TestMetaSnapshotTagsAreSessnapSubset, TestKnownStatesMatchSessionPackage, TestChildIDPrefixesMatchEngine (test-only engine/agent import asserting the TUI prefix constants match the engine byte-for-byte).
  • Direct-open (no confirm step) + load-history-on-continue.

Verification

  • task lint — 0 issues.
  • task test — full suite green (root + engine + GOWORK=off standalone, -race).
  • task api:check — green.
  • task docs — 0 broken links/anchors/orphans; llms.txt regenerated.
  • go run ./cmd/mecademo — full offline session still prints.

Notes

  • Child-session event logs are often empty (children run in-process, not through the relay's log writer). InspectSubagent/InspectMember (which read the snapshot) remain the richer read path for child transcripts. /sessions Children tab shows them read-only with type badges.
  • v1 limitation: m.effectiveModel/m.caps are left stale-but-benign on continue (the header may show the create-time model; the server re-validates caps on the live turn).

jhrozek added a commit that referenced this pull request Jul 7, 2026
Fixes found reviewing PR #247, three of them only surfaced by driving the
feature end-to-end (mock provider) rather than reading the diff:

- H1 (HIGH): replayed compaction archives silently dropped — EventToMsg matched
  the literal "compaction_archive" but the wire type is "compaction.archive"
  (server relays string(ev.Type) verbatim). Fixed the client case label + a
  second dormant instance in eventlog_test.go whose switch never matched.
- H2 (HIGH): closeSessionsTranscript left the adopted session id set (resetSession
  never clears sessionID), so a prompt typed after esc ran a live turn against the
  read-only-inspected session. Clear it on teardown, matching the sibling handoffs.
- P1 (MED): /sessions was missing from the command palette — the wiredCollaborators
  literal was hand-copied in 3 sites and the palette copy omitted Sessions. Extract
  one wiredCollaborators() method so the 3 sites can't drift again.
- P2 (MED): the picker listed the current freshly-created empty session and sorted
  it to the top; exclude the current adopted session id from the list.
- M1 (MED): ListSessions reported the default model for non-live sessions; use the
  persisted sess.ModelID instead of ResolvedModel's default-engine fallback.

Each fix carries a genuine regression test (several previously passed by encoding
the bug). task lint + task test + api:check + golden all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@jhrozek

jhrozek commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Reviewed this end-to-end (split into server / client / UI layers since the diff is large, then drove the feature with the --mock provider). Found and fixed 5 issues — pushed as eea9b751. Notably 3 of them were invisible to a pure diff review and only showed up when actually running /sessions.

🔴 HIGH

H1 — replayed compaction archives were silently dropped.
EventToMsg matched the literal "compaction_archive", but the canonical wire type is "compaction.archive" (dot — the server relays string(ev.Type) verbatim). Every replayed archive fell through to default → nil, so the pre-compaction history the feature exists to recover never rendered. Confirmed live on the wire. Fixed the client case label + a second dormant instance in eventlog_test.go whose switch never matched the real string (so it passed while asserting nothing). Kept it a string literal — cmd/mecatui/client must not import engine/session.

H2 — the adopted session id survived esc from a read-only replay.
closeSessionsTranscript called resetSession(), whose comment claims it drops the adopted id — but resetSession never clears m.sessionID (the two sibling handoffs in models.go/worktrees.go each set it explicitly). Result: open a session read-only → esc → type a prompt, and it starts a live run against the session you only meant to inspect. One-line fix + a real assertion in the teardown test.

🟡 MED

P1 — /sessions never appeared in command autocomplete.
The wiredCollaborators{} literal was hand-copied in 3 sites and the palette.go copy omitted Sessions, so the command was runnable but hidden from the palette. Root-caused it: extracted one wiredCollaborators() method as the single construction site so the 3 can't drift again. (This one lived in a file the PR never touched — a diff-scoped review structurally can't see it.)

P2 — the picker listed the current empty session and sorted it to the top.
isSessionOpenable blocks running/awaiting, but a freshly-created idle 0-turn session passes, and newest-first sort puts it first — so the obvious thing to click is always the empty current session (this is what made it look like "sessions have no content"). Now excludes the current adopted session id from the list.

M1 — ListSessions reported the default model for non-live sessions.
It used ResolvedModel(id), which falls back to the shared default engine for any session not currently in memory — misreporting every session that ran on a non-default model. Switched to the persisted sess.ModelID that's already loaded. Made the fixtures set distinct model ids so the tests actually guard it.

Several existing tests were passing by encoding the bug (the wrong literal, the default fallback) — those are now honest regression guards.

task lint + task test (both modules, -race) + task api:check + goldens all green, verified by an independent pass. The server RPC layer (replay including the log-only EvApproval/EvUserPrompt/EvCompactionArchive, nil EventLog → UNIMPLEMENTED, gauntlet-#7 metadata-only, proto wire-compat) all checked out clean.

JAORMX and others added 6 commits July 8, 2026 08:59
…ase 1)

The durable event log (port.EventLog, cloud-native Phase 3a) was writable
but not publicly readable: only the driver-protocol EventLogService.Read
exposed it, which mecatui does not consume. This adds the client-tier
read-back surface over the existing port — the loop stays storage-agnostic
(it only emits; the relay persists).

StreamSessionEvents(session_id) — server-streaming gRPC + SSE HTTP,
backed by port.EventLog.Read (iter.Seq2). Replays the full durable
timeline, INCLUDING the three log-only kinds (EvApproval,
EvCompactionArchive, EvUserPrompt) the live Converse relay skips on the
client wire: a transcript viewer wants the verdicts and user prompts,
which ARE the transcript. Those payloads are metadata-only by
construction (gauntlet #7 — ApprovalPayload carries tool NAME + verdict
string, never raw args), so the replay adds NO new redaction. The live
relay's skip filter stays unchanged (pinned by TestLiveConverseRelay-
SkipsLogOnlyKinds); only the replay path relays them.

The proto Event gains fields 16/17/18 (approval/user_prompt/
compaction_archive) + four new messages (Approval, UserPrompt,
CompactionArchive, ConversationMessage — the message-slice type the
archive carries, which had no wire surface before). toProto projects all
three; the live relay filter decides what to SEND (toProto is now total).

ListSessions — unary, backed by PrunableStore.List (type-asserted off
the configured SessionStore, the same discovery pattern as EventLog/
lease). Returns picker metadata (id, modified_at, state, turns, model id,
created_at) enriched per row via a best-effort Store.Load. A backend that
does not implement PrunableStore (ErrPruneUnsupported) yields an empty
list — degrade honestly, never an error. No ServerCapabilities bit (the
capability is RPC-discoverable: UNIMPLEMENTED / empty-list).

SessionSnapshot (cmd/mecatui/client) gains State — the proto Session.state
field already existed and was already populated server-side; this is the
one-field client read the picker needs.

A nil EventLog (the in-process default, mecatequi) returns ErrNoEventLog
→ UNIMPLEMENTED / HTTP 501, the EventLog analogue of ErrNoScheduleStore.
The engine module API is unchanged (server-only RPCs over existing
ports) — task api:check stays green, no api:update or engine/CHANGELOG.

Cloud-native discipline (ADR 0027): these RPCs add no outlives-a-call
resource (no goroutine/LRU/map on Service) — a stateless read over the
existing port.EventLog (List-1 row 8) and PrunableStore.List. A one-line
note in the Phase 3a section records that the log is now publicly
readable; no new inventory row.

Tests: round-trip replay over a fixture session (asserts verdict + user-
prompt payloads survive the wire, not just the type tag), unknown-id-
empty, nil-EventLog-unimplemented (Service + gRPC + HTTP 501),
empty-session-id InvalidArgument, ListSessions over jsonlstore (sort,
corrupt-row survival), prune-unsupported-empty, ListSessions error-
propagation (ErrInternal at Service + gRPC Internal + HTTP 500), the
live-relay-still-skips-log-only-kinds regression guard, and
SessionSnapshot.State. Offline; mecademo still prints the full gauntlet.

Part of #245.
… Phase 2)

The client surface the Phase-3 ui will call to open an existing session by
ID and replay its transcript. Phase 1 shipped the server RPCs; this wires
the gRPC client side, with the projection-equivalence discipline at its
core: a replayed event renders identically to a live event because both
feed the SAME EventToMsg translation.

stream.go: extracted Stream.ReadLoop's body into a shared readEventLoop
over a func() (*Event, error) source. The live Converse stream delegates
via a closure that strips the ConverseResponse envelope (byte-identical
behaviour — the existing TestReadLoop* tests are the proof). The replay
path (EventStream) delegates with its EventRecver.Recv directly. A new
EventRecver interface is the Event-replay analogue of Recver (one fewer
wrapping layer — the replay yields *Event, not *ConverseResponse).

events.go: EventStream (read-only — no Send side, unlike the bidi
Stream) + Client.StreamSessionEvents (opens the replay RPC) +
StreamSessionEventsCmd (the (ch, stop) Cmd-lifetime pattern mirroring
OpenConverse + ReadLoop + WaitForMsg, but read-only; stop() cancels an
in-flight ReadLoop, proven by TestStreamSessionEventsCmdStopCancels-
InProgress).

sessions_list.go: SessionListItem (proto-free picker row) +
Client.ListSessions + ListSessionsCmd, mirroring the Worktree/
ListWorktreesCmd pattern exactly.

msgs.go: EventToMsg gained three cases (approval/user_prompt/
compaction_archive) so the replay-only log kinds become first-class
tea.Msgs (ApprovalMsg/UserPromptMsg/CompactionArchiveMsg). These are the
verdicts and user prompts a transcript viewer wants — metadata-only by
construction (gauntlet #7). ConversationMessage/ConvToolCall/ConvToolResult
are proto-free mirrors of the message-slice the CompactionArchive carries
(deliberately NOT overloading ToolCallMsg/ToolResultMsg — events vs
persisted-message-parts have different lifecycles). A parallel
contentPartsFromProto maps UserPrompt's []*Content (distinct from
ContentBlock) — two 6-line mappers over different proto types, not
duplicate code.

Tests: projection-equivalence (replay msg sequence byte-identical to live
over shared kinds), log-only kinds (payload fields asserted, not just
type), Cmd lifecycle (open-error, mid-stream-error, EOF, stop-cancels-
in-flight, idempotent stop), ListSessions nil-safe + error arm, the
existing TestReadLoop* regression guards. Offline; mecademo unaffected.

Part of #245.
…Phase 3a)

The /sessions overlay is a third "selecting" picker (after /models and
/worktrees): a cursor + type-to-filter list of stored sessions (via
client.ListSessionsCmd), and on Enter a confirm → open handoff that
ADOPTS the selected session id and opens the replay stream read-only.
This is Slice 3a of the merged Phase 3+4 — the picker + handoff + replay
channel wiring + a phaseReplay skeleton. The transcript RENDERING (block
projection of replayed events into the view) is Slice 3b.

sessions.go: the overlay (sessionsPanel/sessionsConfirm/sessionsTranscript),
mirroring worktrees.go's shape. switchToSession is the switchToWorktree
analogue: endRun + resetSession + adopt id + open ReplayStreamCmd + enter
phaseReplay. closeSessionsTranscript is the esc-teardown (stop replay,
clear replay state, resetSession, return to idle honestly — read-only
inspection ends, no live session survives). stateBadge (▶ ✓ ✗ ⏸ ·) +
relativeTime (Nd/Nm ago) are pure helpers.

model.go: Deps gains Sessions (SessionLister) + Replayer
(SessionReplayer); Model gains sessions sessionsState + phaseReplay.
resetSession deliberately does NOT clear sessionsState (picker/inventory
state, like models/worktrees) — only the replay-derived fields clear in
the esc-teardown.

update.go: replayMsg{gen, msg} + updateReplayMsg (gen-guards stale
readers, mirrors onStreamMsg) + waitReplayCmd (the WaitForMsg fan-in the
live stream uses). For 3a the replay drains honestly (gen-guard, channel
close, no leak) but projects nothing into the transcript yet — the
loading/loaded/error card renders. dispatchPhaseKey extracted from onKey
to stay under the gocyclo cap (behaviour-preserving). onSessionsKey
returns handled=false for the transcript view so esc falls through to
onReplayKey→closeSessionsTranscript (a bug the teardown test caught:
esc was being intercepted and leaking the replay stream).

client: SessionReplayer interface (the narrow test-injectable surface
*Client satisfies) + ReplayStreamCmd (the interface variant of
StreamSessionEventsCmd) + eventstream_testing.go exporting
NewFakeEventStream so the ui tests stay proto-free (no mecatlv1 import
in ui/ — the boundary holds even in tests).

builtins: /sessions registered (gated on the lister being wired — NO
ServerCapabilities bit, deliberate per the proto: the capability is
RPC-discoverable via UNIMPLEMENTED/empty-list). help.go + the help
goldens updated.

Tests: handoff (phaseReplay + sessionID + replayCh + replayer-called),
gen-guard, stream-err/closed, esc-on-transcript teardown (the bug fix),
stateBadge/relativeTime tables, 5 picker goldens + 3 transcript-arm
goldens. Offline; mecademo unaffected.

Part of #245.
… 3b)

Slice 3b completes the merged Phase 3+4: the replayed events now RENDER
as a transcript. Slice 3a shipped the picker + handoff + replay channel
wiring + a loading-card skeleton; this makes the drained events project
into a conversation view so a past session's transcript looks like a
live session's scrollback (projection equivalence).

update.go: applyReplayEvent/applyReplayEventSecondary — a SEPARATE
reducer that delegates to the SAME conv.add* mutators the live
updateStreamEvent uses, targeting &m.sessions.transcript. The live
updateStreamEvent is untouched (the existing stream tests are the
regression net — green, incl. -race); the replay gets projection
equivalence without a risky full-parameterization. The delegation
projections (Subagent/Parallel/Team) were extracted into pure
apply*To(c *conversation, msg) helpers that BOTH the live Model methods
AND applyReplayEvent call — behaviour-preserving for the live path.

The three log-only msgs render: UserPromptMsg → addUser (the user's
prompt); ApprovalMsg → a muted verdict notice ("✓ allowed once: Bash");
CompactionArchiveMsg → a bounded notice ("history compacted — N turns
archived"), NOT the verbatim archive (huge). PermissionAsk/Retract/
ToolProgress/SessionInit are intentionally no-projection (the replay has
no live ask modal; a retract leaves no trace — a cosmetic edge case,
non-blocking).

refreshView: the phaseReplay arm renders &m.sessions.transcript via the
SAME block renderers the live path uses (renderConversationLines), so a
replayed session renders identically to one watched live. The transcript
viewport is static (read-only, bounded batch — no auto-follow).

sessions.go: renderSessionsTranscript now renders the actual transcript
(header "session <id> · read-only transcript" + blocks + "esc: back")
with loading/error fallbacks.

Tests: TestReplayProjectionEquivalence (asserts block SHAPE — user/
assistant/tool/turnStat/approval-notice, not just non-empty),
TestReplayCompactionArchiveNotice, TestReplayApprovalVerdictNotices,
TestReplayStreamClosedKeepsTranscript (now asserts full render), a
rendered-transcript golden. The existing live updateStreamEvent tests
stay green. Offline; mecademo unaffected.

Part of #245.
… Phase 5, #235)

Two focused changes completing the session-open feature:

State gate (sessions.go): isSessionOpenable blocks opening a running/
awaiting session read-only. The replay RPC is a pure log read (no
live-tail), so opening a running session would show a partial transcript
with no terminal EvResult. The gate is client-side/best-effort: a session
that becomes running between the ListSessions call and the open will
still replay successfully (partial transcript ending at the log's current
tail) — documented in the isSessionOpenable doc-comment. The confirm
overlay stays open on block so the user can esc back to the picker.

#235 jump-to-fire-transcript (schedule.go): the schedule inspect view now
has a fire cursor (↑/↓, clamped) and an enter/t action that jumps
directly to the selected fire's transcript, reusing the entire Phase 3+4
switchToSession path — no new transcript machinery. A fire is just a
top-level session with a sched-- id; fire records are always terminal,
so the state gate naturally passes. Guards: Replayer nil → no-op (footer
hint hides the transcript action); empty SessionID → statusMsg, stay in
inspect. The footer hint adapts to whether a replayer is wired.

Closes #235 (the mecatui-side shortcut; the server-side StreamSessionEvents/
ListSessions already shipped in Phases 1-2 of #245).

Tests: state gate (blocks running + awaiting, phase stays idle, confirm
stays open, replayer uncalled), jump-to-fire (phaseReplay + sessionID +
replayer-called), no-session-id, no-replayer, cursor nav clamping. Offline;
mecademo unaffected. docs/tui.md updated.

Part of #245. Closes #235.
Fixes found reviewing PR #247, three of them only surfaced by driving the
feature end-to-end (mock provider) rather than reading the diff:

- H1 (HIGH): replayed compaction archives silently dropped — EventToMsg matched
  the literal "compaction_archive" but the wire type is "compaction.archive"
  (server relays string(ev.Type) verbatim). Fixed the client case label + a
  second dormant instance in eventlog_test.go whose switch never matched.
- H2 (HIGH): closeSessionsTranscript left the adopted session id set (resetSession
  never clears sessionID), so a prompt typed after esc ran a live turn against the
  read-only-inspected session. Clear it on teardown, matching the sibling handoffs.
- P1 (MED): /sessions was missing from the command palette — the wiredCollaborators
  literal was hand-copied in 3 sites and the palette copy omitted Sessions. Extract
  one wiredCollaborators() method so the 3 sites can't drift again.
- P2 (MED): the picker listed the current freshly-created empty session and sorted
  it to the top; exclude the current adopted session id from the list.
- M1 (MED): ListSessions reported the default model for non-live sessions; use the
  persisted sess.ModelID instead of ResolvedModel's default-engine fallback.

Each fix carries a genuine regression test (several previously passed by encoding
the bug). task lint + task test + api:check + golden all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@JAORMX
JAORMX force-pushed the feat/session-open-245 branch from eea9b75 to 1abd99c Compare July 8, 2026 05:59
…pt (#247)

The first user message is the natural label for recognizing a session
("fix the auth bug" vs "write the README"), but the /sessions picker
showed a raw hex id. Multiple surfaces want this label (picker row,
terminal tab title, transcript header, future --name/rename), so it's
stored, not derived.

Session.Title is seeded ONCE from the first genuine user prompt
(clamped to 120 runes), persisted in the snapshot (additive omitempty,
no format bump — old snapshots load as Title==""), with a lazy
display-time fallback (DeriveTitle) that walks the loaded conversation
to the first genuine user message for old/compacted sessions. No
write-on-read — the snapshot stays the authoritative label.

Structural decision (the layering constraint): isGenuineUserTurn lives
in engine/agent (it composes prompt.IsInjectedTurn0Fragment), but
engine/session (where Title lives) is the domain leaf — it cannot
import engine/agent or engine/prompt. Resolution: the synthesised-
summary markers + isSynthesisedSummary move from engine/agent
(unexported) to engine/session (exported as
CompactionSummaryMarker/Tier4SummaryMarker/IsSynthesisedSummary), and
the loop's SetTitle call uses a CALL-SITE genuine flag (recordPrompt is
genuine; recordContinuation is synthetic — never calls SetTitle). The
new session.IsGenuineUserPrompt (domain predicate, prompt-free) is the
subset the read-time consumers (DeriveTitle, eventsource.Fold) use;
compaction's isGenuineUserTurn widens it with the prompt fragment arm
(defense-in-depth, behavior byte-identical).

eventsource.Fold derives Title from the first genuine EvUserPrompt in
the stream (captured in the folder accumulator, SetTitle after
reconstruction). For a compacted session whose opener was dropped into
the summarised head, the opener's EvUserPrompt was emitted BEFORE the
compaction in the stream, so Fold captures it — title survives
compaction (better than the snapshot lazy fallback, which loses the
opener for a compacted session).

Wire: proto Session + SessionSummary gain a `title` field (additive);
GetSession/ListSessions carry it; the /sessions picker row leads with
the title, falling back to the id.

Engine API change: task api:update (engine/api/session.txt regenerated
with Title/SetTitle/IsGenuineUserPrompt/IsSynthesisedSummary/ClampTitle
+ the two marker consts); engine/CHANGELOG.md ### Added (minor).

Tests: set-once + nudge-no-overwrite (the synthetic continuation must
not seed/overwrite — pinned by an explicit sub-assertion), clamp, old
snapshot Title=="", lazy fallback (no-write-on-read, skips synthesised
summary, empty for compacted), wire surfaces (gRPC + HTTP, seeded +
lazy), Fold derivation (first genuine, survives compaction, awaiting,
no-genuine, set-once, clamp), compaction behavior-identical after the
marker move.

Part of #247.
@JAORMX JAORMX added enhancement New feature or request e2e-live Run the live e2e suite on this PR ui labels Jul 8, 2026
JAORMX added 2 commits July 8, 2026 16:53
…eview fixes

Continue-by-default (#245): opening a top-level agent session from /sessions
now goes straight to live/interactive (phaseIdle) — the read-only phaseReplay
mode is eliminated for top-level sessions. Children (subagent/team/parallel)
stay read-only (phaseReplay) from the Children tab. The continueSession func
and the bare `c` key are removed as dead code.

MetaLister (#245): a new optional port.MetaLister seam (engine/port/store.go)
returns picker metadata by reading ONLY the last snapshot line per session and
decoding into a small struct that skips the messages array — O(N × last-line-
read) instead of O(N × filesize). jsonlstore implements it via a tail-read
(readLastLine seeks the last 64KiB). Service.ListSessions prefers MetaLister,
falls back to Load-per-row. SessionStore (Save/Load) unchanged.

Replay coalescing: updateReplayMsg now uses markDirtyReplay (the 16ms coalesced
flush) instead of refreshView per event; onRenderTick's gate widened to
phaseRunning || phaseReplay. Terminal arms still force-flush.

Review fixes (panel review): sanitized s.State on the confirm card; fixed stale
"open read-only" wording; deleted dead childTypeBadge; extracted shared
scanLastNonBlankLine across Load/decodeSessionID/MetaList; collapsed redundant
head decode + metaCounters; replaced hand-rolled trim/lastIndex helpers with
bytes stdlib. Three drift tripwires: TestMetaSnapshotTagsAreSessnapSubset,
TestKnownStatesMatchSessionPackage, TestChildIDPrefixesMatchEngine.

Part of #245.
Drop the confirm-overlay step: Enter on a /sessions picker row now opens the
session directly (continue for top-level, read-only for child). The confirm
overlay and its renderer are removed as dead code.

Load the prior conversation on continue: continuing a top-level session now
opens the replay stream, projects the durable event log into the view while
loading, and on stream close carries the transcript into m.conv and
transitions to phaseIdle (live). The user sees the prior conversation and can
type immediately. An empty/erroring log still continues to phaseIdle (the
server holds the history regardless). The child read-only path is unchanged.

Part of #245.
@JAORMX JAORMX changed the title feat: open an existing session by ID + view transcript (#245, #235) feat: open existing sessions, continue by default, fast picker (#245, #235) Jul 8, 2026
@JAORMX
JAORMX merged commit f5b5464 into main Jul 13, 2026
20 of 23 checks passed
JAORMX pushed a commit that referenced this pull request Jul 28, 2026
Fixes found reviewing PR #247, three of them only surfaced by driving the
feature end-to-end (mock provider) rather than reading the diff:

- H1 (HIGH): replayed compaction archives silently dropped — EventToMsg matched
  the literal "compaction_archive" but the wire type is "compaction.archive"
  (server relays string(ev.Type) verbatim). Fixed the client case label + a
  second dormant instance in eventlog_test.go whose switch never matched.
- H2 (HIGH): closeSessionsTranscript left the adopted session id set (resetSession
  never clears sessionID), so a prompt typed after esc ran a live turn against the
  read-only-inspected session. Clear it on teardown, matching the sibling handoffs.
- P1 (MED): /sessions was missing from the command palette — the wiredCollaborators
  literal was hand-copied in 3 sites and the palette copy omitted Sessions. Extract
  one wiredCollaborators() method so the 3 sites can't drift again.
- P2 (MED): the picker listed the current freshly-created empty session and sorted
  it to the top; exclude the current adopted session id from the list.
- M1 (MED): ListSessions reported the default model for non-live sessions; use the
  persisted sess.ModelID instead of ResolvedModel's default-engine fallback.

Each fix carries a genuine regression test (several previously passed by encoding
the bug). task lint + task test + api:check + golden all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
JAORMX added a commit that referenced this pull request Jul 28, 2026
…pt (#247)

The first user message is the natural label for recognizing a session
("fix the auth bug" vs "write the README"), but the /sessions picker
showed a raw hex id. Multiple surfaces want this label (picker row,
terminal tab title, transcript header, future --name/rename), so it's
stored, not derived.

Session.Title is seeded ONCE from the first genuine user prompt
(clamped to 120 runes), persisted in the snapshot (additive omitempty,
no format bump — old snapshots load as Title==""), with a lazy
display-time fallback (DeriveTitle) that walks the loaded conversation
to the first genuine user message for old/compacted sessions. No
write-on-read — the snapshot stays the authoritative label.

Structural decision (the layering constraint): isGenuineUserTurn lives
in engine/agent (it composes prompt.IsInjectedTurn0Fragment), but
engine/session (where Title lives) is the domain leaf — it cannot
import engine/agent or engine/prompt. Resolution: the synthesised-
summary markers + isSynthesisedSummary move from engine/agent
(unexported) to engine/session (exported as
CompactionSummaryMarker/Tier4SummaryMarker/IsSynthesisedSummary), and
the loop's SetTitle call uses a CALL-SITE genuine flag (recordPrompt is
genuine; recordContinuation is synthetic — never calls SetTitle). The
new session.IsGenuineUserPrompt (domain predicate, prompt-free) is the
subset the read-time consumers (DeriveTitle, eventsource.Fold) use;
compaction's isGenuineUserTurn widens it with the prompt fragment arm
(defense-in-depth, behavior byte-identical).

eventsource.Fold derives Title from the first genuine EvUserPrompt in
the stream (captured in the folder accumulator, SetTitle after
reconstruction). For a compacted session whose opener was dropped into
the summarised head, the opener's EvUserPrompt was emitted BEFORE the
compaction in the stream, so Fold captures it — title survives
compaction (better than the snapshot lazy fallback, which loses the
opener for a compacted session).

Wire: proto Session + SessionSummary gain a `title` field (additive);
GetSession/ListSessions carry it; the /sessions picker row leads with
the title, falling back to the id.

Engine API change: task api:update (engine/api/session.txt regenerated
with Title/SetTitle/IsGenuineUserPrompt/IsSynthesisedSummary/ClampTitle
+ the two marker consts); engine/CHANGELOG.md ### Added (minor).

Tests: set-once + nudge-no-overwrite (the synthetic continuation must
not seed/overwrite — pinned by an explicit sub-assertion), clamp, old
snapshot Title=="", lazy fallback (no-write-on-read, skips synthesised
summary, empty for compacted), wire surfaces (gRPC + HTTP, seeded +
lazy), Fold derivation (first genuine, survives compaction, awaiting,
no-genuine, set-once, clamp), compaction behavior-identical after the
marker move.

Part of #247.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR enhancement New feature or request ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mecatui: open an existing session by ID (view its transcript) Scheduled tasks — Phase 3b: jump-to-fire-transcript

2 participants