feat(attach): warn on empty transcript, capture footer, amend-fail note#1568
Merged
Conversation
…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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
Contributor
There was a problem hiding this comment.
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. |
- 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
# 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
…into attach-improvements
alishakawaguchi
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

https://entire.io/gh/entireio/cli/trails/699
What
Improves
entire attachdiagnosability and feedback across four small, related changes — no behavioral regressions, attach still always writes the checkpoint.Warn on a transcript that parses to nothing (highest value). When
extractTranscriptMetadatayields 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--reviewthe warning additionally calls out that the review prompt will be empty.Post-attach summary footer. A real attach now prints
Captured: <turns> · <model> · <tokens>from data already in scope, reusing the existingtotalTokens/formatTokenCounthelpers. Each segment is omitted when its value is absent (turns 0, empty model, nil token usage).Surface the amend-failure reason. When
--amendfails, 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.Help-text accuracy.
--forcehelp notes the amend is best-effort; Long help documents transcript-based agent auto-detection.How
errW io.WriterthroughrunAttach(the cobra caller passescmd.ErrOrStderr()) so warnings/notes land on stderr, never interleaved with stdout success lines.warnEmptyTranscriptMetadata,printAttachFooter/attachSummaryLine, andamendOrPrintTrailer(the last de-duplicates the two amend call sites and keepsrunAttachunder themaintidxlinter threshold).Tests
Added
TestAttach_WarnsOnEmptyTranscriptMetadata(+_Reviewvariant),TestAttachSummaryLine(footer builder incl. nil-token and empty cases), andTestAttach_NonInteractivePrintsTrailerForManualPaste. ExistingrunAttachcall sites updated for the new signature.Verification
mise run checkpassed: lint 0 issues, unit + integration (59 vogon) + e2e canary (4) all green.Reviewer notes
--agentflag value verbatim (per spec), which may be theclaude-codedefault 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 attachgets 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 lineCaptured: <turns> · <model> · <tokens>summarizes what was stored; segments are omitted when unknown.Commit amend behavior is centralized in
amendOrPrintTrailer: failures log and printCould not amend the commit automatically (...)on stderr, then still show the manualEntire-Checkpointtrailer.runAttachtakes a separateerrWwriter so diagnostics stay off stdout. Help text documents best-effort--forceamend and agent auto-detection when--agentmisses the transcript.Tests cover empty-metadata warnings, the footer builder, and non-interactive trailer fallback; existing
runAttachcall sites pass the new stderr argument.Reviewed by Cursor Bugbot for commit ae3a8aa. Configure here.