Skip to content

feat(attach): warn on empty transcript, capture footer, amend-fail note#1568

Merged
computermode merged 8 commits into
mainfrom
attach-improvements
Jul 1, 2026
Merged

feat(attach): warn on empty transcript, capture footer, amend-fail note#1568
computermode merged 8 commits into
mainfrom
attach-improvements

Conversation

@computermode

@computermode computermode commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/699

What

Improves entire attach diagnosability and feedback across four small, related changes — no behavioral regressions, attach still always writes the checkpoint.

  1. Warn on a transcript that parses to nothing (highest value). When extractTranscriptMetadata yields no first prompt and zero turns, attach previously produced a contentless checkpoint silently. It now emits a warning to stderr and continues. It stays a warning, not a hard error: agents whose user-content shape isn't matched by the generic JSONL/Gemini parser (codex/copilot/pi/factory) can legitimately yield empty metadata from a valid transcript, and token usage is still computed agent-specifically. Under --review the warning additionally calls out that the review prompt will be empty.

  2. Post-attach summary footer. A real attach now prints Captured: <turns> · <model> · <tokens> from data already in scope, reusing the existing totalTokens/formatTokenCount helpers. Each segment is omitted when its value is absent (turns 0, empty model, nil token usage).

  3. Surface the amend-failure reason. When --amend fails, the reason is now printed to stderr (Could not amend the commit automatically (...)) in addition to the existing debug log, so the user knows the best-effort amend was attempted before the manual-paste trailer fallback. Polish, not a correctness fix — the recovery path already worked.

  4. Help-text accuracy. --force help notes the amend is best-effort; Long help documents transcript-based agent auto-detection.

How

  • Threads an errW io.Writer through runAttach (the cobra caller passes cmd.ErrOrStderr()) so warnings/notes land on stderr, never interleaved with stdout success lines.
  • Extracts three small helpers — warnEmptyTranscriptMetadata, printAttachFooter/attachSummaryLine, and amendOrPrintTrailer (the last de-duplicates the two amend call sites and keeps runAttach under the maintidx linter threshold).

Tests

Added TestAttach_WarnsOnEmptyTranscriptMetadata (+ _Review variant), TestAttachSummaryLine (footer builder incl. nil-token and empty cases), and TestAttach_NonInteractivePrintsTrailerForManualPaste. Existing runAttach call sites updated for the new signature.

Verification

mise run check passed: lint 0 issues, unit + integration (59 vogon) + e2e canary (4) all green.

Reviewer notes

  • The amend hard-fail path isn't cleanly stubbable without injecting the git command, so it remains untested; the non-interactive trailer branch is covered instead.
  • The empty-transcript warning reports the --agent flag value verbatim (per spec), which may be the claude-code default even when auto-detection later resolves a different agent.

Note

Low Risk
CLI-only UX and messaging around attach; checkpoint write semantics are unchanged and failures remain non-fatal where documented.

Overview
entire attach gets clearer CLI feedback without changing the core rule that a checkpoint is still written.

When transcript parsing yields no user prompts and zero turns, attach now warns on stderr (and continues). With --review, the warning also notes an empty review prompt. A new stdout line Captured: <turns> · <model> · <tokens> summarizes what was stored; segments are omitted when unknown.

Commit amend behavior is centralized in amendOrPrintTrailer: failures log and print Could not amend the commit automatically (...) on stderr, then still show the manual Entire-Checkpoint trailer. runAttach takes a separate errW writer so diagnostics stay off stdout. Help text documents best-effort --force amend and agent auto-detection when --agent misses the transcript.

Tests cover empty-metadata warnings, the footer builder, and non-interactive trailer fallback; existing runAttach call sites pass the new stderr argument.

Reviewed by Cursor Bugbot for commit ae3a8aa. Configure here.

…il note

Improve `entire attach` diagnosability and feedback:

- Warn (don't fail) when a transcript parses to no prompts and no model,
  so a contentless checkpoint is never produced silently. Stays a warning
  because agents whose user-content shape isn't matched (codex/copilot/pi/
  factory) can legitimately yield empty metadata from a valid transcript;
  the warning goes to stderr and calls out --review when the empty prompt
  would also empty the review prompt.
- Print a "Captured: <turns> · <model> · <tokens>" footer after a real
  attach, reusing the existing token-total/format helpers; each segment is
  omitted when absent.
- Surface the amend-failure reason on stderr in addition to the existing
  debug log, so the user knows the best-effort amend was attempted before
  the manual-paste trailer fallback.
- Document the best-effort amend and transcript-based agent auto-detection
  in --force/Long help.

Threads an errW writer through runAttach for the stderr output, and
extracts warnEmptyTranscriptMetadata / printAttachFooter / amendOrPrintTrailer
helpers (the last de-duplicates the two amend call sites).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 38c6ac0d707e
Copilot AI review requested due to automatic review settings June 29, 2026 20:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ae3a8aa. Configure here.

Comment thread cmd/entire/cli/attach.go
Comment thread cmd/entire/cli/attach.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves entire attach user feedback and diagnosability while keeping attach non-fatal and ensuring checkpoints are still written in all the same cases.

Changes:

  • Added stderr warnings when transcript parsing yields no user prompts / turns (with an extra note under --review).
  • Added a post-attach stdout footer summarizing captured turns/model/tokens when available.
  • Centralized best-effort amend behavior and improved stderr messaging when amend fails; updated help text and added targeted tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/attach.go Threads stderr writer through attach flow; adds empty-metadata warning, capture footer, and shared amend-or-trailer helper.
cmd/entire/cli/attach_test.go Updates runAttach call sites for new signature; adds tests for empty-metadata warnings, footer builder, and non-interactive trailer behavior.

Comment thread cmd/entire/cli/attach.go
computermode and others added 2 commits June 29, 2026 14:20
- Suppress the "review prompt will be empty" warning when a pending-review
  marker's ReviewPromptOverride supplies the prompt; the general "no prompts
  parsed" warning still fires.
- Omit the footer token segment when the total is zero (not just nil), so it
  never renders "0 tokens" — matches the turns guard and the helper's doc.
- Truncate the amend-failure stderr note to the error's first line via the
  existing firstLine helper, keeping the full multi-line git output in the
  debug log only.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: a548a19a0542
@computermode computermode marked this pull request as ready for review June 29, 2026 21:53
@computermode computermode requested a review from a team as a code owner June 29, 2026 21:53
computermode and others added 5 commits July 1, 2026 14:31
# Conflicts:
#	cmd/entire/cli/attach_test.go
…-improvements

Entire-Checkpoint: 9fee3beaaebb
The empty-transcript warning printed the raw --agent flag value, but the
transcript is parsed from the agent resolved in resolveAgentAndTranscript,
which can come from existing session state or auto-detection. When the agent
was auto-detected or read from state, the warning pointed the user at the
wrong --agent value. Report ag.Name() (the resolved agent's flag-form name)
instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 00116e978416
@computermode computermode merged commit 2482802 into main Jul 1, 2026
9 checks passed
@computermode computermode deleted the attach-improvements branch July 1, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants