Skip to content

fix(tui): load long replies whole when reopening a session - #200437

Closed
harsha-7179 wants to merge 1 commit into
openclaw:mainfrom
harsha-7179:fix/tui-history-full-replies
Closed

harsha-7179 wants to merge 1 commit into
openclaw:mainfrom
harsha-7179:fix/tui-history-full-replies

Conversation

@harsha-7179

Copy link
Copy Markdown

Fixes #200408

What Problem This Solves

After openclaw tui is closed and reopened on a session, an assistant reply longer than 8,000 characters ends in ...(truncated).... The stored reply is complete, and the TUI showed it in full before it was closed.

The TUI requested chat.history with sessionKey, agentId and limit only, so the Gateway applied its default 8,000-character display cap. The TUI renders history rows as-is and has no per-message expansion, so the capped text looked like the whole reply. openclaw tui --local applied the same default cap.

User Impact

Reopened TUI sessions show each reply in full, up to 500,000 characters. Tool results keep the Gateway's default 8,000-character preview, so history payloads grow only by the long replies themselves.

Why This Change Was Made

The issue names two documented routes: a per-request maxChars on chat.history, or chat.message.get per truncated entry (what the Control UI does). This PR takes the first.

  • The TUI now sends maxChars: 500000 (the schema maximum) and toolResultMaxChars: 8000 on chat.history.
  • --local passes the same two limits to readChatHistoryPage.
  • Both limits live in src/tui/tui-backend.ts so the two backends cannot drift.

maxChars was chosen over chat.message.get because the TUI has no lazy-expansion surface: it would have to fetch every truncated row before rendering anyway, which adds a hydration step, concurrency bounds and a failure fallback for the same result. The Control UI's complete-history read already uses maxChars: 500_000. I am happy to switch routes if maintainers prefer chat.message.get; another contributor proposed that route on the issue.

Accepted limits:

  • A reply over 500,000 characters is still capped.
  • A newer TUI connected to a Gateway that predates toolResultMaxChars would have its history request rejected as an unknown parameter. I could not determine which release added the parameter; please say if a fallback is wanted.

Evidence

Real Gateway over WebSocket (temporary test in src/gateway/server.chat.gateway-server-chat-b.test.ts, not committed): a stored 11,532-character assistant reply ending in THE END, read with the TUI's old and new chat.history parameters.

Request Text returned Ends with
Before: limit only 8,018 characters, truncated: true, reason: "display-cap" ...(truncated)...
After: maxChars: 500000, toolResultMaxChars: 8000 11,532 characters, identical to the stored reply THE END

The 8,018 matches the issue report (8,000 cap plus the 18-character marker).

Checks run on this head:

  • pnpm exec vitest run src/tui/gateway-chat.test.ts src/tui/embedded-backend.test.ts: 164 passed. The updated assertions cover the request parameters in Gateway mode and the page-reader parameters in --local mode.
  • pnpm tsgo:core: passed.
  • pnpm format:check on the touched files: passed.

Not done: the reopened reply has not been viewed in a live openclaw tui with a real model. The development container had no systemd user session for the launcher's Gateway check and no configured model provider.

The TUI requested chat.history without a text limit, so the Gateway
applied its 8,000-character display cap and replies ended in
"...(truncated)..." after a session was reopened. The TUI renders
history rows as-is and has no per-message expansion.

Request whole replies (maxChars 500,000, the protocol maximum) in both
the Gateway and --local backends. Tool results keep the default
8,000-character preview through toolResultMaxChars.

Fixes 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Nov 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-environment 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 real behavior proof before merge.

What this changes

This PR requests larger reply previews when restoring history in Gateway and local TUI modes.

Example: Reopen tidepool-test with an 11,532-character assistant reply ending in THE END.

  • Before: The reply ends after 8,000 characters with ...(truncated)....
  • After: The new parameters allow that reply to retain its THE END suffix.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) A useful, focused repair attempt with a concrete long-reply regression and no after-fix TUI proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A complete reply becomes visibly truncated after the user closes and reopens the TUI.
Reason: Restoring stored reply text has clear value, but the proposed cap cannot deliver the documented 500,000-character range under existing history budgets.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR addresses a confirmed TUI bug, but raising the history cap can replace very long replies with an omission placeholder.

Priority: P2
Reviewed head: 630e13a11f2dac5a43fa09c4c82b41a1236a66e2

Before merge

  • Add real behavior proof - The downloaded screenshot shows the original truncation, while after-fix evidence consists of reported tests and a temporary WebSocket integration test that bypasses the changed TUI entry points; the author explicitly states that neither reopened TUI mode was viewed after the fix. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • [P2] Recover replies that exceed the history row byte limit (P2) - A stored assistant reply containing 150,000 ASCII characters is below the advertised 500,000-character limit, but its projected JSON exceeds CHAT_HISTORY_MAX_SINGLE_MESSAGE_BYTES (128 KiB). With this override, Gateway history replaces the entire reply with [chat.history omitted: message too large]; embedded loadHistory applies the same replacement at lines 475–480. Previously the 8,000-character preview remained readable. The TUI renders that placeholder directly and has no recovery path, so this change makes these existing replies less readable. Recover complete assistant entries through the existing full-message owner while retaining bounded previews and add a regression that checks the restored text rather than only request parameters.

Findings

  • [P2] [P2] Recover replies that exceed the history row byte limit — src/tui/gateway-chat-requests.ts:144-145

Tests

  • Missing end-to-end proof: Supply redacted after-fix evidence of exiting and reopening Gateway and local TUI sessions with the suffix intact, including an existing stable-release session, and a committed base-failing regression covering a reply over 128 KiB.
Agent review details

How this fits together

Both TUI backends obtain display-projected session history from the Gateway history owner, then render the returned rows directly.

flowchart TD
  A[Stored session transcript] --> B[Gateway history projection]
  C[Gateway TUI request] --> B
  D[Local TUI reader] --> B
  B --> E[History byte limits]
  E --> F[TUI session renderer]
Loading

Technical review

Best possible solution:

Preserve bounded history previews and recover complete assistant entries through the existing full-message owners in both TUI backends.

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

Current-main source establishes the default-cap-to-renderer failure path, corroborated by the reporter's screenshot and paired RPC measurements; no target code was executed.

Is this the best way to solve the issue?

The small parameter change restores ordinary long replies but misses the independent 128 KiB history-row limit, making existing full-message retrieval the safer complete solution.

Full review comments:

  • [P2] [P2] Recover replies that exceed the history row byte limit — src/tui/gateway-chat-requests.ts:144-145
    A stored assistant reply containing 150,000 ASCII characters is below the advertised 500,000-character limit, but its projected JSON exceeds CHAT_HISTORY_MAX_SINGLE_MESSAGE_BYTES (128 KiB). With this override, Gateway history replaces the entire reply with [chat.history omitted: message too large]; embedded loadHistory applies the same replacement at lines 475–480. Previously the 8,000-character preview remained readable. The TUI renders that placeholder directly and has no recovery path, so this change makes these existing replies less readable. Recover complete assistant entries through the existing full-message owner while retaining bounded previews and add a regression that checks the restored text rather than only request parameters.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Embedded history ownership keeps the original intent (d876a83: Centralize history projection in the Gateway owner while retaining hard history budgets.)
  • Default history text limit changes intended behavior with a stated reason (13083df: Remove unused configuration forwarding while retaining the 8,000-character default, explicit request overrides, and full-message retrieval.)
  • Gateway history request lifecycle keeps the original intent (543dd39: Keep startup readiness retries and cancellation in the existing request owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm exec vitest run src/tui/gateway-chat.test.ts src/tui/embedded-backend.test.ts src/tui/tui-session-actions.test.ts
  • pnpm tsgo:core
  • pnpm check:changed
  • Verify focused text-restoration regressions fail on the base and pass with the repair.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 543dd39 adds src/tui/gateway-chat-requests.ts:142 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 543dd39563e4; files: src/tui/gateway-chat-requests.ts)
  • fuller-stack-dev: Raw commit 276c000 adds src/tui/tui-backend.ts:1 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/tui-backend.ts)
  • Masato Hoshino: Raw commit 781afcf adds src/tui/tui-backend.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 781afcf53be3; files: src/tui/tui-backend.ts)

PR surface

Source +14, Tests +2, Docs +1. Total +17 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 18 4 +14
Tests 2 5 3 +2
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 24 7 +17

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: This PR attempts to repair the canonical issue's capped TUI history rendering.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Reopened TUI replies are incomplete, while stored transcripts remain intact and other retrieval paths work.
  • merge-risk: 🚨 compatibility: The increased text cap can replace previously readable previews of existing long replies with omission placeholders.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed November 17, 2026, 1:18 AM ET / 06:18 UTC.

@vincentkoc

Copy link
Copy Markdown
Member

Thank you, @harsha-7179, for tracing the 8,000-character cutoff in both TUI backends and testing reopened replies. @woodmanlegion’s original fix landed in 4fa3be0 and resolved the reported issue. Both backends now keep their history-page budgets and fetch the stored text for an individual capped reply. If that read fails or the reply exceeds its limit, the preview explains what happened.

Closing this alternative because the landed fix covers the same reopen behavior. Its documentation for a 500,000-character history request was specific to the approach proposed here.

@vincentkoc vincentkoc closed this Nov 26, 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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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