Skip to content

[Task] Improve session export diagnostics ergonomics (#563 follow-up) #564

@Astro-Han

Description

@Astro-Han

Context

Follow-up to #563, which introduced abort provenance and ensureTitle() background trace diagnostics on session export. Opus second-pass review flagged three P3 items that were deferred to keep that PR scoped to v1 diagnostics + #560 version fix.

Scope

Four small improvements to the diagnostic surface added in #563:

1. Log dropout when recordTitleTrace cannot find the assistant message

packages/opencode/src/session/prompt.ts polls up to 50 × 10ms for the assistant message before recording the title trace. If the message has not appeared within 500ms, the trace is silently dropped. Add a single elog.warn (or equivalent) on dropout so missing traces are observable from logs rather than silently absent from the export.

2. Either annotate or wire InterruptMeta.viaCtxAbort

The field is reserved but never set to true anywhere in v1 (the single cancel callsite explicitly sets viaCtxAbort: false). Either:

  • Annotate it as reserved-for-future so the next reproduction reader does not interpret "always false" as evidence; or
  • Hook ctx.abort paths to set it correctly.

3. Add explicit title_generation_state correlation in the abort diagnostic

Currently abort.recorded_at and title_generation.completed_at are independent fields. To answer "was ensureTitle() still in flight when the main run was aborted?", a reader must join two structured records on timestamps.

Add a snapshot field to the abort diagnostic:

abort: {
  ...
  title_generation_state: "not_started" | "in_flight" | "completed_before_abort" | "completed_after_abort"
}

so the temporal relationship is immediately visible in the export.

4. Keep title_generation.applied consistent with setTitle() success

packages/opencode/src/session/prompt.ts currently records applied: true on the success path without separately proving that sessions.setTitle(...) actually succeeded. If setTitle() fails after title generation succeeds, the export can claim the title was applied when it was not.

Update the flow so recordTitleTrace({ applied: true }) only happens when sessions.setTitle(...) succeeds, and record applied: false (with error context when available) on failure.

Acceptance

  • A log line is emitted when recordTitleTrace cannot locate the assistant message within the polling window.
  • InterruptMeta.viaCtxAbort either reflects an actual ctx.abort path or is annotated as reserved with a code comment.
  • The abort diagnostic block contains an explicit title_generation_state field with one of the four values above.
  • title_generation.applied is only true when sessions.setTitle(...) actually succeeds.

Priority

P3 (ergonomic polish for diagnostic surface; not blocking any user-visible behavior). Pick up when the diagnostic surface from #563 is needed for an actual reproduction and the missing correlation slows down RCA.

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priorityharnessModel harness, prompts, tool descriptions, and session mechanicstaskNarrow execution, audit, spike, migration, tracking, or upstream follow-up worktech-debtSupplemental cleanup, maintainability, architecture, test, or quality debt context

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions