Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: render chat stream deterministically via history versions - #27098

Closed
ibetitsmike wants to merge 1 commit into
mike/chat-status-remove-unusedfrom
mike/chat-status-stream-suppression
Closed

fix: render chat stream deterministically via history versions#27098
ibetitsmike wants to merge 1 commit into
mike/chat-status-remove-unusedfrom
mike/chat-status-stream-suppression

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make live chat rendering match durable server state. Queued-message promotion no longer clears the stream, removes the queue row, or fabricates a running status while the server is interrupting the previous turn.

Problem

Interrupted assistant output is persisted, so hiding live parts only made content disappear and return after reload. Status updates and message_part events also come from independent sources, which made status-based suppression racy.

Fix

Expose history_version and generation_attempt on chat and status payloads. The frontend uses that tuple and each part's seq to replace the preview when a newer episode arrives and reject stale or replayed parts. Promotion keeps the authoritative queue row visible as a disabled Promoting... placeholder, and clears stale transient errors before starting the promoted request.

Stacked on #27064.

This PR was authored by Mux (AI agent) on Mike's behalf.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 441429bf07

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/AgentsPage/components/ChatConversation/useChatStore.ts Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from 441429b to 2f80d61 Compare July 8, 2026 18:34
@ibetitsmike
ibetitsmike requested a review from hugodutka July 8, 2026 18:35
@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-remove-unused branch from ffa5643 to c6c329f Compare July 8, 2026 19:47
@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from 2f80d61 to 9300876 Compare July 8, 2026 19:48
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 5b1d8e878d

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hugodutka hugodutka 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.

I'm not sure if this is the right thing to do. If we optimistically suppress the message parts after the user interrupts the chat, they'll reappear once the user reloads the page anyway, which would be confusing.

But even if we decide to suppress the parts, this approach doesn't feel robust. When I think about what message parts we should display to the user, I think in terms of the history_version that the frontend is aware of. After the user interrupts a chat that's on history_version n, then late message parts associated with version n should not be displayed to the user. But any message parts associated with versions > n should. This uses a heuristic instead: when the user interrupts, suppress message parts until the next non-interrupting status update comes over. I'd rather we relied on a method that considers history versions instead. While the heuristic would work most of the time, there are probably some edge cases it doesn't handle correctly.

@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from 5b1d8e8 to dd3558a Compare July 10, 2026 20:23
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

📖 View docs preview for docs/reference/api/chats.md

@ibetitsmike ibetitsmike changed the title fix(site/src/pages/AgentsPage): drop stale stream frames during queued promotion fix: render chat stream deterministically via history versions Jul 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

I reworked this around the version model you suggested.

I verified that interrupted output is persisted, so optimistic suppression only made content disappear and return after reload. I also found that status and message_part events are multiplexed from independent sources, so the previous non-interrupting status heuristic could drop a newer episode or admit a late older one.

The branch now exposes history_version and generation_attempt on chat/status payloads. The frontend treats status and REST tuples as a floor, adopts episodes from versioned parts, compares the full (history_version, generation_attempt) tuple, and uses seq for replay deduplication. Queued promotion no longer clears the stream, fakes status, or hides the queue row. The row stays authoritative and renders a temporary Promoting... placeholder until queue_update removes it.

Mux reworked this on Mike's behalf.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from dd3558a to a6b7ec1 Compare July 10, 2026 20:26
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: a6b7ec1927

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/AgentsPage/AgentChatPage.tsx
@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-remove-unused branch from c6c329f to cd12a50 Compare July 12, 2026 13:51
@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from a6b7ec1 to 53f61ec Compare July 12, 2026 13:51
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 53f61ec319

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/chat-status-stream-suppression branch from 53f61ec to b86647e Compare July 12, 2026 14:00
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b86647e90c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

After internal discussions we'll be closing that one and aim at an RFC led cleanup of frontend rendering.

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants