Skip to content

Fix: render TUI chat events for canonical session-key aliases - #36100

Closed
Octane0411 wants to merge 1 commit into
openclaw:mainfrom
OasAIStudio:codex/fix-35523-tui-display
Closed

Octane0411 wants to merge 1 commit into
openclaw:mainfrom
OasAIStudio:codex/fix-35523-tui-display

Conversation

@Octane0411

@Octane0411 Octane0411 commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Normalize TUI chat-event session matching so canonical session-key aliases are treated as equivalent during render filtering.
  • Keep active-run and stream handling unchanged while ensuring assistant events are rendered for alias-equivalent sessions.
  • Add regression coverage for canonical vs legacy session-key alias matching in TUI event handlers.

Security Impact

  • N/A (no auth, permission, or trust-boundary changes)

Repro+Verification

  • Reproduced with events emitted under alias-equivalent session keys where UI previously dropped assistant messages.
  • Verified assistant messages now render when session keys are canonical aliases of the same session.
  • Confirmed no behavior change for non-matching sessions.

Testing

  • pnpm test src/tui/tui-event-handlers.test.ts

AI Assisted

  • AI assisted (Codex)

Fixes

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3412453e0e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


const isSessionMatch = (sessionKey: string) => {
const current = state.currentSessionKey.trim().toLowerCase();
const incoming = sessionKey.trim().toLowerCase();

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.

P2 Badge Guard chat sessionKey type before canonicalizing

handleChatEvent is fed raw evt.payload from the websocket path (src/tui/tui.ts), so malformed chat payloads can still reach this code at runtime even though ChatEvent is typed. The new matcher unconditionally does sessionKey.trim(), which throws when sessionKey is missing or non-string (for example, an unexpected event shape from an older/misbehaving gateway), and that exception stops chat event handling instead of safely ignoring the bad payload as before. Add a runtime typeof sessionKey === "string" check before calling isSessionMatch (or inside it).

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR successfully fixes the TUI rendering regression where chat events with legacy session key aliases (e.g., "main") were rejected because the handler required exact string matching against the canonical form (e.g., "agent:main:main").

What works well:

  • The isSessionMatch helper correctly implements canonical ↔ legacy key equivalence for the default agent
  • The test validates the regression fix: canonical current key now accepts legacy incoming keys
  • All 14 existing tests pass, including the new regression test
  • The fix is focused and doesn't alter active-run or stream handling

Key change:
The fallback path return currentParsed.rest === incoming enables the TUI to render chat events arriving with legacy aliases that match the rest segment of the current session.

Confidence Score: 4/5

  • Safe to merge. The fix is narrowly scoped to session key matching logic, preserves all existing event handling, and includes a passing regression test.
  • The PR correctly fixes the reported regression ([Bug]: TUI doesn't display assistant messages until restart #35523) where canonical session keys now accept incoming events with legacy aliases. The implementation is sound for single-agent deployments (which all tests confirm), the test validates the specific regression, and no existing functionality is altered. Score of 4/5 reflects the focused, low-risk nature of the fix with appropriate test coverage for the stated problem.
  • No files require special attention. Both changed files implement and test the regression fix appropriately.

Last reviewed commit: 3412453

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUI doesn't display assistant messages until restart

2 participants