Skip to content

fix(tui): keep failed attachments visible beside replies - #132115

Merged
steipete merged 1 commit into
mainfrom
codex/qa-tui-attachment-failures-20260828
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-tui-attachment-failures-20260828

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where TUI users received no visible failed-attachment outcome when an assistant reply contained a typed attachment error. A failure-only reply became empty history or (no output), while a caption hid the error entirely.

Why This Change Was Made

The TUI's canonical content formatter now combines the selected reply with actionable attachment failures instead of treating all attachments as a fallback for missing text. History and final stream assembly share that owner. The existing reply-media formatter supplies the wording, while the TUI retains generic media-kind labels so private filenames, source URLs and terminal escape sequences do not leak into the display.

Final text still takes precedence over streamed text, then an actual error and successful-attachment fallback. Failure receipts are composed after that selection, so a failure-only final cannot erase an already streamed caption. The optimistic projection keeps the rendered receipt once; authoritative history can replace it without duplicating it. Failure-only aborts remain cancellation diagnostics rather than successful final output.

This removes the duplicate record-coercion helper and makes the successful-attachment helper private after migrating its sole production caller. Production LOC: +37/-30 (net +7; including the ownership comment). The small remaining growth implements validation and presentation of a typed failure variant the TUI previously could not render; failure wording and final selection are reused rather than duplicated. The assertion baseline is reduced by one, not relaxed. No configuration, protocol, SDK, dependency or persistent-store change.

Provenance: #131826 introduced the typed failure producer (8bd8958, 2026-08-28; code author, PR author and merger @vyctorbrzezowski). That made the missing TUI consumer visible. The successful-attachment-only fallback dates to #117460 (b83a966, code author @steipete); it predates the new failure variant.

User Impact

TUI replies and reloaded history now retain the actionable attachment failure beside the answer, without exposing attachment sources. The TUI documentation describes this behavior. This is the release-note context for the repair.

Evidence

The complete six-path changed-file gate passed, including production/test typechecking, core/script lint and the selected architecture guards. Independent isolated Codex review found no actionable findings. No landing is claimed before exact-head hosted CI and the native merge workflow complete.

Root reproduction on unchanged main observed empty history and (no output) for a failure-only reply, and only Your recording for a caption plus failure. The first regression run had 12 intended failures. The repaired owner/formatter/assembler suite passes 126 tests; 94 selected event, ChatLog and Markdown sibling tests also pass (172 others intentionally filtered, not counted). Root independently reran the original formatter/assembler reproduction on Node 24 and confirmed both repaired outcomes.

The real ChatLog renderer is exercised through final events, streamed captions, optimistic history and authoritative history replacement, with an exactly-once receipt assertion. All media kinds and failure codes, mixed success/failure content, error precedence, thinking visibility, aborted runs and private source metadata are covered.

Before, caption plus failed audio:

Your recording

After:

Your recording
⚠️ audio attachment: Delivery failed. Try sending this file again.

Native PTY replays are on an explicit campaign hold, so this is real renderer/event-flow proof, not a launched terminal UI, authenticated Gateway, provider or live-channel test. No held test, operator Gateway, state directory or credentials were touched.

Validation recovery: the assertion ratchet required its legitimate 5-to-4 reduction after removing a cast. A missing isolated-checkout UI dependency link initially selected old transitive pako; linking the already-installed declared UI package resolved it, and the full gate passed. No dependency installation or guard suppression was used.

Shared CI follow-up: #132102 and #132105 independently encounter the current main-composition startup gzip budget overrun. This TUI patch does not alter UI source, the budget, or its baseline; that owner-level repair is being investigated separately before landing.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete steipete self-assigned this Aug 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 5:45 PM ET / 21:45 UTC.

ClawSweeper review

What this changes

The PR makes the terminal UI show privacy-safe, actionable failed-attachment receipts alongside assistant reply text during live streaming and history reload.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: this is a distinct, active TUI repair with no introduced correctness finding; the protected maintainer label and incomplete exact-head checks require normal human merge review.

Priority: P2
Reviewed head: 8323b12760f93fb55a0e76b9c3d6a60fe2714a0a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent repair with meaningful boundary coverage and no actionable introduced defect found in review.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied event-handler and ChatLog coverage is relevant, but the TUI scoped policy correctly limits it to renderer/event-flow evidence rather than Gateway or live-provider proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied event-handler and ChatLog coverage is relevant, but the TUI scoped policy correctly limits it to renderer/event-flow evidence rather than Gateway or live-provider proof.
Evidence reviewed 6 items Introduced formatter behavior: The introduced formatter recognizes only the producer's closed attachment-error code and kind combinations, substitutes a generic media label, and appends the existing actionable receipt text without reading attachment labels, URLs, or MIME metadata.
Live final caller: Stream finalization retains any preceding streamed text and passes the final message to the shared formatter, so a failure-only final can add its receipt without erasing a streamed caption.
History ownership: Optimistic projection stores the already-rendered final text and only successful attachment blocks; authoritative history independently formats raw typed failures, preventing a duplicate receipt.
Findings None None.
Security None None.

How this fits together

Gateway chat events and session history feed assistant messages into the terminal UI formatter, which renders live chat rows and rebuilt history. The change extends that shared presentation boundary to typed attachment failures.

flowchart LR
  A[Assistant message] --> B[Gateway chat event]
  A --> C[Session history]
  B --> D[Terminal UI formatter]
  C --> D
  D --> E[Stream finalization]
  D --> F[History rebuild]
  E --> G[Terminal chat log]
  F --> G
Loading

Decision needed

Question Recommendation
After exact-head checks finish, should the TUI-area owner accept this bounded presentation repair with its existing stream and history coverage? Accept after checks: Merge once required exact-head checks are green and the TUI reviewer confirms the retained generic-label privacy boundary.

Why: The protected maintainer label requires an explicit human merge decision even though source review found no actionable patch defect.

Before merge

  • Resolve merge risk (P1) - Production code is net +7 lines for a bug fix; the added closed-shape validation and privacy-safe presentation are justified, but the scope should remain bounded while exact-head CI completes.
  • Complete next step (P2) - The protected maintainer label keeps this active implementation PR in normal human review; no narrow automated repair is indicated.
Agent review details

Security

None.

PR surface

Source +7, Tests +248, Docs +1, Other 0. Total +256 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 37 30 +7
Tests 1 248 0 +248
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 6 287 31 +256

Review metrics

Metric Value Why it matters
Production versus test delta production +7 net; tests +248; docs +1; assertion baseline -1 The small production increase adds typed-failure validation and safe terminal presentation while the new boundary coverage protects stream and history behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one terminal-specific formatter that converts the producer-owned typed outcome into generic safe receipt text, while keeping live finalization and history reconstruction on that same formatter.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one terminal-specific formatter that converts the producer-owned typed outcome into generic safe receipt text, while keeping live finalization and history reconstruction on that same formatter.

Do we have a high-confidence way to reproduce the issue?

Yes—at the verified base/current-main SHA, attachment_error has no terminal formatter path, while final selection only uses successful attachment summaries as a fallback; failure-only and caption-plus-failure cases are directly derivable from source. This review did not execute the supplied harness.

Is this the best way to solve the issue?

Yes—the shared terminal formatter is the narrow owner for rendering this terminal-specific, privacy-safe receipt across both live finalization and history reload, without changing the Gateway producer contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5b605da38946.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded terminal-UI visibility defect without changing configuration, persistence, authentication, or delivery behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied event-handler and ChatLog coverage is relevant, but the TUI scoped policy correctly limits it to renderer/event-flow evidence rather than Gateway or live-provider proof.

Evidence

What I checked:

  • Introduced formatter behavior: The introduced formatter recognizes only the producer's closed attachment-error code and kind combinations, substitutes a generic media label, and appends the existing actionable receipt text without reading attachment labels, URLs, or MIME metadata. (src/tui/tui-formatters.ts:433, 8323b12760f9)
  • Live final caller: Stream finalization retains any preceding streamed text and passes the final message to the shared formatter, so a failure-only final can add its receipt without erasing a streamed caption. (src/tui/tui-stream-assembler.ts:230, 8323b12760f9)
  • History ownership: Optimistic projection stores the already-rendered final text and only successful attachment blocks; authoritative history independently formats raw typed failures, preventing a duplicate receipt. (src/tui/tui-session-projection.ts:160, 8323b12760f9)
  • Producer contract: The in-tree producer emits attachment_error blocks with the same three failure codes and maps generic media to document, matching the TUI's accepted shape. (src/gateway/managed-image-attachments.ts:343, 8323b12760f9)
  • Boundary-level regression coverage: The new test exercises the real event-handler and ChatLog boundary for failure-only, mixed, streamed, optimistic-to-authoritative, abort, and privacy cases rather than adding a test-only seam. (src/tui/tui-attachment-failures.test.ts:179, 8323b12760f9)
  • Current-main comparison and provenance: The verified main/base SHA lacks this formatter path; the introduced diff adds it. Blame attributes the new formatter lines to this PR head, while merged PR fix(webchat): show named cards for failed attachments #131826 supplies the typed producer that made the missing consumer visible. (src/tui/tui-formatters.ts:433, 8323b12760f9)

Likely related people:

  • steipete: Authored the prior merged TUI attachment-only rendering repair and the current formatter/stream follow-up. (role: TUI attachment presentation owner; confidence: high; commits: b83a966c0562, 8323b12760f9; files: src/tui/tui-formatters.ts, src/tui/tui-stream-assembler.ts, src/tui/tui-session-projection.ts)
  • vyctorbrzezowski: Merged PR fix(webchat): show named cards for failed attachments #131826 introduced the typed attachment-failure blocks consumed by this TUI repair. (role: typed attachment-outcome producer author; confidence: high; commits: 8bd895862d13; files: src/auto-reply/reply-payload.ts, src/gateway/managed-image-attachments.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-28T21:24:37.247Z sha f5773d03233d0c078b6e44b4709bac05c0de4bae :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer review completed. The net seven production lines are accepted for the missing typed-outcome boundary: validation and privacy-safe presentation of attachment failures cannot be supplied by the successful-attachment fallback. The patch keeps one shared content formatter, reuses the canonical receipt wording, removes the local record guard and fallback-only argument, and covers final/stream/history ownership without duplicated rendering.

No correctness/security finding or separate Rank-up move remains in the latest review. The exact-head CI failure is separately confirmed: all five substantive failing jobs stop at the unchanged shared Control UI startup gzip gate, while 160 jobs pass. I am repairing that startup owner boundary and will refresh/retest this PR before the native prepare/merge flow. No gate bypass or landing is claimed.

@steipete
steipete force-pushed the codex/qa-tui-attachment-failures-20260828 branch from f5773d0 to 8323b12 Compare August 28, 2026 21:36
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 28, 2026
@steipete
steipete merged commit 5e92497 into main Aug 28, 2026
238 checks passed
@steipete
steipete deleted the codex/qa-tui-attachment-failures-20260828 branch August 28, 2026 21:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant