-
Notifications
You must be signed in to change notification settings - Fork 860
Fix UI stuck on Stop when request is slow or proxy disconnects #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PeterDaveHello
merged 1 commit into
ChatGPTBox-dev:master
from
PeterDaveHello:fix/stop-abort-ui-unstick
Jul 17, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||
| export function markProxyGenerationStarted(port, proxyGenerationId, requestGenerationId) { | ||||||||||||||||||||||
| if (proxyGenerationId !== undefined) port._proxyGenerationId = proxyGenerationId | ||||||||||||||||||||||
| port._proxyRequestGenerationId = requestGenerationId | ||||||||||||||||||||||
| port._generating = true | ||||||||||||||||||||||
| port._suppressReconnectError = false | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function tagProxyRequestGeneration(port, message) { | ||||||||||||||||||||||
| return port._proxyRequestGenerationId === undefined | ||||||||||||||||||||||
| ? message | ||||||||||||||||||||||
| : { ...message, requestGenerationId: port._proxyRequestGenerationId } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function isCurrentProxyGenerationMessage(port, message) { | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| message.stoppedGenerationId !== undefined || | ||||||||||||||||||||||
| port._proxyGenerationId === undefined || | ||||||||||||||||||||||
| (port._generating && message.proxyGenerationId === port._proxyGenerationId) | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function markProxyGenerationFinished(port) { | ||||||||||||||||||||||
| port._generating = false | ||||||||||||||||||||||
| port._suppressReconnectError = false | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function forwardProxyMessage(port, message) { | ||||||||||||||||||||||
| const forwardedMessage = | ||||||||||||||||||||||
| message?.stop && port._stopAcknowledged ? { ...message, stopAcknowledged: true } : message | ||||||||||||||||||||||
| if (message?.stop) interruptProxyGeneration(port) | ||||||||||||||||||||||
| port.proxy.postMessage(forwardedMessage) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function markProxyGenerationFinishedFromMessage(port, message) { | ||||||||||||||||||||||
| if ( | ||||||||||||||||||||||
| !isCurrentProxyGenerationMessage(port, message) || | ||||||||||||||||||||||
| message.stoppedGenerationId !== undefined || | ||||||||||||||||||||||
| (!message.error && !message.done) | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| return false | ||||||||||||||||||||||
| markProxyGenerationFinished(port) | ||||||||||||||||||||||
| return true | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+34
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To prevent potential runtime
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function interruptProxyGeneration(port) { | ||||||||||||||||||||||
| if (!port._generating) return false | ||||||||||||||||||||||
| port._generating = false | ||||||||||||||||||||||
| port._suppressReconnectError = true | ||||||||||||||||||||||
| return true | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function clearProxyReconnectErrorSuppression(port) { | ||||||||||||||||||||||
| port._suppressReconnectError = false | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function consumeProxyReconnectErrorSuppression(port) { | ||||||||||||||||||||||
| const shouldSuppress = Boolean(port._suppressReconnectError) | ||||||||||||||||||||||
| port._suppressReconnectError = false | ||||||||||||||||||||||
| return shouldSuppress | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export function shouldSkipProxyReconnect(port) { | ||||||||||||||||||||||
| return port._isClosed || Boolean(port.proxy) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Stale disconnect requestid
🐞 Bug≡ CorrectnesspostProxySession() posts to port.proxy before recording the new request generation state, but the proxy disconnect handler tags its {done:true, proxyDisconnected:true} using the stored _proxyRequestGenerationId. If port.proxy.postMessage() throws or a disconnect happens before markProxyGenerationStarted() runs, the disconnect completion can be tagged with a previous requestGenerationId and be dropped by the UI’s superseded-request filter, leaving the current request stuck.Agent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools