Skip to content

fix: show the whole reply when you reopen a TUI session - #200455

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
woodmanlegion:fix/tui-full-capped-history
Nov 26, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
woodmanlegion:fix/tui-full-capped-history

Conversation

@woodmanlegion

@woodmanlegion woodmanlegion commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #200408

What Problem This Solves

In openclaw tui, a reply longer than 8,000 characters is complete while it streams, but after you close and reopen the session it stops mid-sentence with ...(truncated).... The full reply is stored, yet the TUI gives no way to see the rest, so it looks as if the model stopped early or text was lost.

User Impact

User impact: reopening a TUI session (Gateway or --local) shows long replies in full again. If the full text cannot be shown, the preview stays and says why, instead of ending silently.

Why This Change Was Made

The Gateway caps text in chat.history to keep history pages small. The Control UI already loads capped rows in full through chat.message.get (#122207); the TUI took the capped text as it came. The TUI now does the same as the Control UI: after loading history, each assistant row marked truncated: true / reason: "display-cap" is replaced by the stored message, newest first, four reads at a time. History pages stay bounded, and there are no protocol or schema changes.

When the full text cannot be shown, the preview is kept and its marker says why:

  • read failed, not found, or a Gateway without chat.message.get: ...(truncated; couldn't load the full reply. Reopen the session to try again)... (same advice as the Control UI's "Couldn't load the full message. Try again.")
  • chat.message.get reports the stored reply as oversized (over its ~25 MB payload limit): ...(truncated; the full reply is too large to show here)...

Local mode (openclaw tui --local) had the same cap. Its history read moves from embedded-backend.ts into src/tui/embedded-history-messages.ts, unchanged, and full text is loaded after the existing budgets pick the rows (the 128 KiB per-message limit and the page limit), so loading full text never drops an older row from the page. The stored message is then read in-process with the same limits as the Gateway's chat.message.get handler, so both modes show the same reply. A reply over 128 KiB shows in full in both. As with Gateway clients, a page with loaded replies can end up over its byte budget.

The first revision of this PR loaded local full text before those budgets. A reply over 128 KiB then became [chat.history omitted: message too large] instead of its preview, and expanded rows could push older rows off the page. This revision fixes both.

Known limit, left as is: chat.message.get caps text at 1,000,000 characters, so in both modes a longer reply loads its first million characters, ending in the plain ...(truncated)... marker. Command-line runs (openclaw agent) are not affected by any of this: they print the run result, not history.

Evidence

Live check, Windows 11, against a running 2026.11.5-beta.4 Gateway: the session from #200408 holds an 11,532-character reply that chat.history returns as 8,018 characters ending ...(truncated)....

  • Before (installed 2026.11.5-beta.4 TUI, session reopened): the reply stops mid-sentence at "forest ecology", followed by ...(truncated)....
  • After (this branch built from source, same session reopened): the whole reply is shown, ending with THE END.

Before:

tui-reopened-truncated-small

After (Gateway):

tui-patched-full

After (--local): live run of this branch, openclaw tui --local --session agent:main:proof, Windows 11. The run used throwaway HOME, OPENCLAW_HOME, OPENCLAW_STATE_DIR, config and OPENCLAW_WINDOWS_TASK_NAME. The session holds two stored assistant replies, written with the repo's own transcript writer (upsertSessionEntryCore + replaceTranscriptEvents). An 8,000-character preview of either stops partway through paragraph 72.

  • 11,539 characters, ending THE END: after reopening, it shows in full (paragraphs 1–103 and THE END).
  • 150,078 characters, over the 128 KiB per-message limit: after reopening, it also shows in full (paragraphs 1–1,326 and its last line, HUGE_REPLY_LAST_LINE), as it does over the Gateway.

The src/tui/tui-pty-local.e2e.test.ts harness times out on this Windows machine (its own existing cases too), so this was a manual run in a terminal. The retrieval-failure case can't be triggered live without corrupting storage; the unit tests below cover it.

Reopened TUI screen text (repeated middle paragraphs elided)
 openclaw tui - local embedded - agent main - session proof

 session agent:main:proof

Write the huge reply.

Huge paragraph 1: the tide pool keeps its water between waves, and every stone holds a small world of its own.
Huge paragraph 2: the tide pool keeps its water between waves, and every stone holds a small world of its own.
[... paragraphs 3-1,324 elided ...]
Huge paragraph 1325: the tide pool keeps its water between waves, and every stone holds a small world of its own.
Huge paragraph 1326: the tide pool keeps its water between waves, and every stone holds a small world of its own.

HUGE_REPLY_LAST_LINE

Write the long reply.

Long paragraph 1: the tide pool keeps its water between waves, and every stone holds a small world of its own.
Long paragraph 2: the tide pool keeps its water between waves, and every stone holds a small world of its own.
[... paragraphs 3-100 elided ...]
Long paragraph 101: the tide pool keeps its water between waves, and every stone holds a small world of its own.
Long paragraph 102: the tide pool keeps its water between waves, and every stone holds a small world of its own.
Long paragraph 103: the tide pool keeps its water between waves, and every stone holds a small world of its own.

THE END
 local ready | idle
 agent main | session proof | gpt-5.5 | deliver:off | tokens ?/200k

Focused tests:

  • src/tui/gateway-chat.test.ts: a capped row is replaced by the chat.message.get result; when the read reports unavailable, reports oversized, or is rejected, the preview is kept with the matching marker.
  • src/tui/embedded-history-messages.test.ts (new) runs the real history budgets with synthetic transcript rows: a capped reply shows its stored text; a 150,000-character stored reply shows in full; a reply the reader reports oversized, and a missing reply, keep their marked previews; loading a 30,000-character reply under a 40,000-byte page budget keeps the older 15,000-character row. The 150,000-character and page-budget cases fail when full text is loaded before the budgets (the order in the first revision) and pass here.
  • gateway-chat.test.ts, embedded-backend.test.ts and embedded-history-messages.test.ts: 172 passed.

pnpm check:changed: typecheck, lint, format, line-cap and mock-export ratchets pass. The dead-export scan reports three exports in untouched files that are already on main (approval-shared.ts, spawn-broker/host.ts, system-agent/operation-types.ts).

TUI history used chat.history rows as returned, so assistant replies over
8,000 characters stayed cut with "...(truncated)..." after a session was
reopened. Load display-capped assistant rows in full with chat.message.get
(Gateway mode) or the same single-message read in-process (--local), and
mark the preview when the full text cannot be loaded.

Closes openclaw#200408
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The TUI retrieves stored text for display-capped assistant replies when reopening Gateway and local sessions.

Example: Reopen a session containing an 11,532-character assistant reply.

  • Before: The reply stops after 8,000 characters with ...(truncated)....
  • After: The reopened reply includes the remaining text and its final THE END line.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, worthwhile fix with shipped-TUI proof, distinct regression coverage, and passing exact-head gates.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected Gateway before/after screenshots demonstrate the restored reply ending; supplied Windows local-TUI output demonstrates reopened 11,539- and 150,078-character stored replies reaching their final sentinels, and the final commit only changes session-field normalization and wrapper dependency inclusion.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Reopening a session makes complete stored replies appear to have stopped mid-sentence.
Reason: Restoring readable history has clear user value and follows the existing Control UI full-message contract without adding configuration or changing storage.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it fixes a current TUI history defect, addresses the earlier findings, and has passing exact-head gates with no identified blocking defects.

Reviewed head: 5518a8fcc7cc3773c0b1b416192e7b363955bf70

Before merge

None.

Findings

None.

Agent review details

How this fits together

The TUI backends read bounded session-history pages, retrieve full stored messages for capped assistant rows, and pass the resulting messages to the terminal renderer.

flowchart LR
  A[Reopen TUI session] --> B[Gateway or local backend]
  B --> C[Bounded history page]
  C --> D[Find capped assistant rows]
  D --> E[Existing stored message reader]
  E --> F[Full reply or marked preview]
  F --> G[Terminal renderer]
Loading

Technical review

Best possible solution:

Land the existing-reader hydration approach while preserving bounded history selection and visible retrieval-failure markers.

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

Current-main source retains capped history without expansion, corroborated by the linked official-version report and before screenshot; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch reuses the existing full-message reader, preserves history budgets and startup retries, and handles unavailable messages without replacing readable previews.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c7824fb4d2b0.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main retains the defect: Gateway loadHistory returns chat.history directly, while embedded history uses the default display cap without subsequent full-message retrieval. (src/tui/gateway-chat-requests.ts:131, c7824fb4d2b0)
  • Existing reader and physical session identity: The PR calls chat.message.get with the selected session key, optional agent, history session ID, and message ID; it preserves the existing history startup-retry owner. (src/tui/gateway-chat-requests.ts:133, 5518a8fcc7cc)
  • Earlier budget-ordering finding resolved: Local history applies the existing row and page budgets before replacing capped previews, preserving older admitted rows and allowing a 150,000-character reply to display. (src/tui/embedded-history-messages.ts:77, 5518a8fcc7cc)
  • Shipped-entry-point proof: Inspected the supplied Gateway before/after screenshots: the preview ends at forest ecology, while the patched view reaches THE END; the PR body also supplies Windows local-TUI terminal output reaching THE END and HUGE_REPLY_LAST_LINE. (5518a8fcc7cc)
  • Exact-head gates pass: The reviewed head has successful openclaw/ci-gate, dependency-review, and security-sensitive-review statuses; check runs have no failed or pending results, resolving the prior workflow-approval blocker. (5518a8fcc7cc)
  • History ownership and precedent: Merged refactor(tui): consolidate runtime ownership #117368 established shared Gateway history ownership; merged fix(ui): always show full assistant responses #122207 established automatic full-message presentation in Control UI, which this PR extends to the TUI. (src/tui/embedded-backend.ts:454, d876a8338722)

Likely related people:

  • Peter Steinberger: Raw commit d876a83 adds src/tui/embedded-backend.ts:621 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d876a8338722; files: src/tui/embedded-backend.ts)
  • Vincent Koc: Raw commit 13083df adds src/tui/embedded-backend.ts:656 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 13083df05f8e; files: src/tui/embedded-backend.ts)
  • fuller-stack-dev: Raw commit 276c000 adds src/tui/embedded-backend.ts:246 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 276c00015c83; files: src/tui/embedded-backend.ts)

PR surface

Source +216, Tests +186, Other +1. Total +403 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 242 26 +216
Tests 2 186 0 +186
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 7 429 26 +403

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #200408
Summary: The linked issue and both TUI PRs address display-capped history being rendered as the complete reply.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-17T06:59:50.545Z sha aaaf09d :: needs real behavior proof before merge. :: [P2] Hydrate local replies after applying history byte limits | [P3] Give unavailable-reply messages a recovery action
  • reviewed 2026-11-18T00:23:54.178Z sha 61c485a :: blocked before merge. :: none

Reviewed November 25, 2026, 8:33 PM ET / November 26, 2026, 01:33 UTC (Revision 3).

Local mode loaded full text before the per-message and page budgets, so a
reply over 128 KiB became an omission placeholder and expanded rows could
push older rows off the page. Move the local history read into
embedded-history-messages.ts and load full text after the budgets pick the
rows, with the same limits as chat.message.get, so local and Gateway mode
show the same reply. Unavailable replies now say to reopen the session to
retry.
@woodmanlegion

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Nov 18, 2026
@vincentkoc vincentkoc self-assigned this Nov 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 26, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 Nov 26, 2026
@vincentkoc
vincentkoc merged commit 4fa3be0 into openclaw:main Nov 26, 2026
94 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 26, 2026
…irement-rule

* origin/main: (172 commits)
  test(gateway): expect a revoked person's Goal retry to be hidden as not found (#205698)
  fix: keep browser disabled when only hardening relay authentication (#203137)
  fix: recover Linux stream automations after command-anchor crashes (#203149)
  fix(whatsapp): identify voice-note captions as text in delivery receipts (#205381)
  fix(test): unblock restart-auth plugin and worker publication qualification (#205679)
  chore(ui): refresh control ui locales (#205691)
  fix: reduce memory during SQLite usage refresh (#201064)
  fix(plugins): readmit native captures with a dangling host link
  chore(i18n): refresh native locales (#205680)
  fix(update): hash SQLite lock bytes as zeros so Windows exclusion cannot fail verification (#205668)
  fix(skill-workshop): skip the skill diet for skills with Markdown outside support directories (#204881)
  fix(plugins): clarify dated SDK migration notices (#200932)
  fix: keep the resident launcher when reinstalling Gateway (#205655)
  fix: show the whole reply when you reopen a TUI session (#200455)
  test(ui): wait for restored speech player authorization (#199502)
  feat: let agents post approved GitHub comments (#204301)
  fix(agents): honor imageMaxDimensionPx at the provider and CLI image handoffs (#205663)
  chore(ui): refresh control ui locales (#205664)
  fix(google): preserve playback when Google Live splits audio into parts (#205364)
  fix: show named characters in exported session messages (#205362)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
)

* fix(tui): show full replies after reopening a session

TUI history used chat.history rows as returned, so assistant replies over
8,000 characters stayed cut with "...(truncated)..." after a session was
reopened. Load display-capped assistant rows in full with chat.message.get
(Gateway mode) or the same single-message read in-process (--local), and
mark the preview when the full text cannot be loaded.

Closes openclaw#200408

* fix(tui): load full replies after local history budgets

Local mode loaded full text before the per-message and page budgets, so a
reply over 128 KiB became an omission placeholder and expanded rows could
push older rows off the page. Move the local history read into
embedded-history-messages.ts and load full text after the budgets pick the
rows, with the same limits as chat.message.get, so local and Gateway mode
show the same reply. Unavailable replies now say to reopen the session to
retry.

* fix(tui): reuse the history session field reader and include its dependency

---------

Co-authored-by: Vincent Koc <[email protected]>
@woodmanlegion
woodmanlegion deleted the fix/tui-full-capped-history branch November 27, 2026 04:24
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
* fix(tui): show full replies after reopening a session

TUI history used chat.history rows as returned, so assistant replies over
8,000 characters stayed cut with "...(truncated)..." after a session was
reopened. Load display-capped assistant rows in full with chat.message.get
(Gateway mode) or the same single-message read in-process (--local), and
mark the preview when the full text cannot be loaded.

Closes #200408

* fix(tui): load full replies after local history budgets

Local mode loaded full text before the per-message and page budgets, so a
reply over 128 KiB became an omission placeholder and expanded rows could
push older rows off the page. Move the local history read into
embedded-history-messages.ts and load full text after the budgets pick the
rows, with the same limits as chat.message.get, so local and Gateway mode
show the same reply. Unavailable replies now say to reopen the session to
retry.

* fix(tui): reuse the history session field reader and include its dependency

---------

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 4fa3be0)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix(tui): show full replies after reopening a session

TUI history used chat.history rows as returned, so assistant replies over
8,000 characters stayed cut with "...(truncated)..." after a session was
reopened. Load display-capped assistant rows in full with chat.message.get
(Gateway mode) or the same single-message read in-process (--local), and
mark the preview when the full text cannot be loaded.

Closes #200408

* fix(tui): load full replies after local history budgets

Local mode loaded full text before the per-message and page budgets, so a
reply over 128 KiB became an omission placeholder and expanded rows could
push older rows off the page. Move the local history read into
embedded-history-messages.ts and load full text after the budgets pick the
rows, with the same limits as chat.message.get, so local and Gateway mode
show the same reply. Unavailable replies now say to reopen the session to
retry.

* fix(tui): reuse the history session field reader and include its dependency

---------

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 4fa3be0)

Companion audit: No direct later reference follow-up; sender-independent stable chat.message.get and its in-process history reader already exist.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts 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.

[Bug]: TUI shows replies over 8,000 characters cut with "...(truncated)..." after reopening a session

2 participants