Skip to content

webui: handle SSE error events and avoid false completion#1277

Open
tomerh2001 wants to merge 1 commit intoAudionut:masterfrom
tomerh2001:fix/webui-sse-error-handling-fast-exit
Open

webui: handle SSE error events and avoid false completion#1277
tomerh2001 wants to merge 1 commit intoAudionut:masterfrom
tomerh2001:fix/webui-sse-error-handling-fast-exit

Conversation

@tomerh2001
Copy link

@tomerh2001 tomerh2001 commented Mar 4, 2026

Fixes #1276.

What changed

  • Handle SSE error events in Web UI execution stream and display them in terminal output.
  • Handle SSE system events so server-side status messages are visible.
  • Track terminal/output states per run.
  • Avoid showing false ✓ Execution completed on error/empty-output termination.
  • Mark non-zero exit codes as error outcomes.

Why

The backend can emit SSE error events (for example lock contention: "Another in-process run is active").
The frontend previously ignored these events and unconditionally printed ✓ Execution completed when the stream ended, causing false-success runs with no useful output.

Validation

  • Linted frontend after dependency install; existing unrelated lint errors remain in app.js (react/no-unescaped-entities lines 1690, 2212).
  • Verified patch scope is limited to web_ui/static/js/app.js.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error resilience during template parsing and rendering operations.
    • Better handling of error scenarios in output display.
  • Improvements

    • Refined execution completion messaging to clearly indicate success, errors, or missing output.
    • Enhanced monitoring of data stream events for accurate execution state tracking.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Thanks for taking the time to contribute to this project. Upload Assistant is currently in a complete rewrite, and no new development is being conducted on this python source at this time.

If you have come this far, please feel free to leave open, any pull requests regarding new sites being added to the source, as these can serve as the baseline for later conversion.

If your pull request relates to a critical bug, this will be addressed in this code base, and a new release published as needed.

If your pull request only addresses a quite minor bug, it is not likely to be addressed in this code base.

Details for the new code base will follow at a later date.

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

The update enhances SSE event handling in the Web UI by introducing state tracking for output, terminal, and error events. It improves completion messaging logic to accurately reflect execution status—showing error, no-output, or success messages based on actual events received during execution, rather than always reporting success.

Changes

Cohort / File(s) Summary
SSE Event Tracking & Completion Logic
web_ui/static/js/app.js
Added state variables (sawOutputEvent, sawTerminalEvent, sawErrorEvent) to track SSE data streams. Extended event handlers to distinguish html/terminal/error events. Adjusted final completion messaging to emit "✗ Execution finished with errors", "✗ Execution ended without output", or "✓ Execution completed" based on actual events received. Improved error resilience in render path with specific "Parse error" messaging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through streams of events,
Tracking outputs, errors, and exits with intent,
No more false victories proclaimed too soon—
Now completion sings the proper tune!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'webui: handle SSE error events and avoid false completion' clearly summarizes the main changes: adding SSE error event handling and preventing false success messages.
Linked Issues check ✅ Passed The PR implements all key requirements from #1276: handles SSE error/system events, tracks output states, prevents false completion messages on errors or empty output, and treats non-zero exit codes as errors.
Out of Scope Changes check ✅ Passed All changes are scoped to web_ui/static/js/app.js and directly address the linked issue requirements; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web_ui/static/js/app.js`:
- Around line 1105-1108: The current code always calls appendSystemMessage with
a success checkmark for all exits even though non-zero codes set sawErrorEvent;
change the logic around appendSystemMessage in the exit handler so it uses the
exit code to choose the proper message and semantics: when Number(data.code) ===
0 call appendSystemMessage with the success message (✓ Process exited...),
otherwise call appendSystemMessage (or a dedicated error logger used elsewhere)
with an error-formatted message (e.g., ✗ or "Process exited with non-zero code")
and set sawErrorEvent = true; update references to appendSystemMessage,
sawErrorEvent and data.code to implement this branching so the UI no longer
shows a success checkmark on error exits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b36e7f6e-60c9-417a-a62f-0cc57a48e6c6

📥 Commits

Reviewing files that changed from the base of the PR and between 31571aa and 8724597.

📒 Files selected for processing (1)
  • web_ui/static/js/app.js

Comment on lines 1105 to +1108
appendSystemMessage(`✓ Process exited with code ${data.code}`);
if (Number(data.code) !== 0) {
sawErrorEvent = true;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Use error semantics for non-zero exit line

At Line 1105, the UI always prints ✓ Process exited..., even when Line 1106-Line 1108 classifies the exit as an error. This creates conflicting status in the same run.

Suggested fix
           } else if (data.type === 'exit') {
             sawTerminalEvent = true;
+            const exitCode = Number(data.code);
+            const isErrorExit = !Number.isFinite(exitCode) || exitCode !== 0;
+            if (isErrorExit) {
+              sawErrorEvent = true;
+            }
             if (!(localController && localController.signal.aborted)) {
               appendSystemMessage('');
-              appendSystemMessage(`✓ Process exited with code ${data.code}`);
-              if (Number(data.code) !== 0) {
-                sawErrorEvent = true;
-              }
+              appendSystemMessage(
+                `${isErrorExit ? '✗' : '✓'} Process exited with code ${data.code}`,
+                isErrorExit ? 'error' : 'info'
+              );
             }
           }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
appendSystemMessage(`✓ Process exited with code ${data.code}`);
if (Number(data.code) !== 0) {
sawErrorEvent = true;
}
} else if (data.type === 'exit') {
sawTerminalEvent = true;
const exitCode = Number(data.code);
const isErrorExit = !Number.isFinite(exitCode) || exitCode !== 0;
if (isErrorExit) {
sawErrorEvent = true;
}
if (!(localController && localController.signal.aborted)) {
appendSystemMessage('');
appendSystemMessage(
`${isErrorExit ? '✗' : '✓'} Process exited with code ${data.code}`,
isErrorExit ? 'error' : 'info'
);
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web_ui/static/js/app.js` around lines 1105 - 1108, The current code always
calls appendSystemMessage with a success checkmark for all exits even though
non-zero codes set sawErrorEvent; change the logic around appendSystemMessage in
the exit handler so it uses the exit code to choose the proper message and
semantics: when Number(data.code) === 0 call appendSystemMessage with the
success message (✓ Process exited...), otherwise call appendSystemMessage (or a
dedicated error logger used elsewhere) with an error-formatted message (e.g., ✗
or "Process exited with non-zero code") and set sawErrorEvent = true; update
references to appendSystemMessage, sawErrorEvent and data.code to implement this
branching so the UI no longer shows a success checkmark on error exits.

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.

Web UI occasionally exits immediately with 'Execution completed' and no run output

1 participant