Skip to content

[bugfix] : fix error hadling - #22

Open
harshil-2096 wants to merge 2 commits into
mainfrom
bugfix/error-handling
Open

[bugfix] : fix error hadling#22
harshil-2096 wants to merge 2 commits into
mainfrom
bugfix/error-handling

Conversation

@harshil-2096

@harshil-2096 harshil-2096 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Touches core send-turn and isRunning semantics; behavior changes are intentional for UX but could affect consumers relying on prior error shapes or running-state timing.

Overview
Pre-turn failures are now wrapped in TrueFoundryPreTurnError with a phase (session-initialization, session-resolution, session-loading, turn-headers) when sendTurn fails before the user message is projected or the turns API runs. Those steps go through runPreTurnStep, which still invokes onError and rethrows the typed error.

isRunning is set at the start of sendTurn (including session creation and other prep), and cleared in a finally only when no stream actually started—so the composer can exit a stuck busy state if prep fails, without clearing running state when a newer stream superseded the send.

Composer recovery: On TrueFoundryPreTurnError in onNew, the runtime puts the user's text back into the composer via new getTurnMessageText (when the composer is empty).

API: getTurnMessageText is extracted from getTurnMessageContent; TrueFoundryPreTurnError and PreTurnFailurePhase are exported from the package index.

Reviewed by Cursor Bugbot for commit 5f9efb4. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
truefoundry-agents-assistant-ui-runtime-assistant-ui-react Error Error Jul 31, 2026 5:16am

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

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5f9efb4. Configure here.

// stream must remain running when this send settles after supersession.
if (streamGenerationAtStart === streamGenerationRef.current) {
setIsRunning(false);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuck running after pre-turn failure

High Severity

sendTurn sets isRunning before pre-turn work, then clears it only when streamGenerationRef is unchanged. load also bumps that counter, so a pre-turn failure after a concurrent load can skip the clear and leave the composer permanently busy with no stream to recover it.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5f9efb4. Configure here.

return await step();
} catch (error) {
onErrorRef.current?.(error);
throw new TrueFoundryPreTurnError(phase, error);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate pre-turn error callbacks

Medium Severity

runPreTurnStep already invokes onError before throwing TrueFoundryPreTurnError, but callers such as trySendCollectedRequiredActions and onEdit also report the rejection. Pre-turn failures therefore surface twice to consumers.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5f9efb4. Configure here.

const text = getTurnMessageText(message);
if (text.length > 0 && composer.getState().text.length === 0) {
composer.setText(text);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attachments lost on send failure

Medium Severity

Pre-turn recovery only restores text via getTurnMessageText and composer.setText. Messages with attachments lose those files on failure, and attachment-only messages restore nothing because the text-length guard fails.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5f9efb4. Configure here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant