Skip to content

Update pydemo1#104

Merged
jayvdb merged 1 commit into
mainfrom
update-pydemo1
Jul 23, 2026
Merged

Update pydemo1#104
jayvdb merged 1 commit into
mainfrom
update-pydemo1

Conversation

@jayvdb

@jayvdb jayvdb commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • The combined eye-and-speech demo now launches directly when selected.
    • Added a persistent recording timer and an exit button to the speech panel.
    • Stored eye captures now appear in the picture viewer automatically.
    • The demo can be relaunched immediately after exiting.
    • The demo is now selected by default in the module dropdown when available.
  • Bug Fixes

    • Improved failure handling during demo startup and recording.
    • Updated recording status and countdown displays for clearer feedback.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PyDemo workflow now launches directly, uses redesigned timer and exit controls, broadcasts stored eye captures through websocket messages, exports and tests the new Python helper, and selects et-ws-pydemo1 by default.

Changes

PyDemo workflow

Layer / File(s) Summary
Direct demo entry and controls
services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js, services/ws-server/static/app.js
The demo launches directly, manages navigation and runtime cleanup, replaces the speech retry control with timer and exit controls, and defaults the module selection to et-ws-pydemo1.
Recording completion and timer lifecycle
services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js
Speech recording updates the timer chip, resets speech state on teardown, reveals the exit control after completion, and removes countdown-arc rendering.
Stored eye-capture broadcast contract
services/ws-modules/pydemo1/pydemo1/demo.py, services/ws-modules/pydemo1/pydemo1/__init__.py, services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js, services/ws-modules/pydemo1/tests/test_demo.py
Stored eye captures use the shared broadcast formatter, are sent through the websocket client, are publicly exported, and are covered by JSON and storage-path assertions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModuleSelector
  participant run
  participant enterDemo
  participant PythonWorkflow
  ModuleSelector->>run: select et-ws-pydemo1 and start
  run->>enterDemo: create demo state
  enterDemo->>PythonWorkflow: load runtime and execute workflow
Loading
sequenceDiagram
  participant saveEyeCapture
  participant eye_capture_stored_json
  participant capture_broadcast_json
  participant WebSocket
  saveEyeCapture->>eye_capture_stored_json: pass agent_id and filename
  eye_capture_stored_json->>capture_broadcast_json: build stored-capture message
  eye_capture_stored_json-->>saveEyeCapture: return JSON
  saveEyeCapture->>WebSocket: send broadcast JSON
Loading

Possibly related PRs

  • edge-toolkit/core#99: Refactors the shared capture_broadcast_json implementation reused by the new stored-capture helper.
  • edge-toolkit/core#102: Introduces and wires the pydemo1 demo module modified here.

Suggested reviewers: pierre-tenedero

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the change, but it is too generic to convey the main update. Use a specific title that names the key change, such as adding stored eye-capture broadcasts and updating the pydemo1 demo flow.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-pydemo1

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

@deepsource-io

deepsource-io Bot commented Jul 23, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 19c85d7...05968aa on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Jul 23, 2026 2:09a.m. Review ↗
C & C++ Jul 23, 2026 2:09a.m. Review ↗
Docker Jul 23, 2026 2:09a.m. Review ↗
Java Jul 23, 2026 2:09a.m. Review ↗
JavaScript Jul 23, 2026 2:09a.m. Review ↗
Python Jul 23, 2026 2:09a.m. Review ↗
Rust Jul 23, 2026 2:09a.m. Review ↗
Secrets Jul 23, 2026 2:09a.m. Review ↗
Code coverage Jul 23, 2026 2:35a.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
100%
57.9%
[▲ up 0.1% from main]
Python
100%
85.3%
[▲ up 0.1% from main]
Rust -
55.7%
[▲ up 0.1% from main]

➟ Additional coverage metrics may have been reported. See full coverage report ↗


Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 high

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
ErrorProne 2 high

View in Codacy

🟢 Metrics -22 complexity · 0 duplication

Metric Results
Complexity -22
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@jayvdb
jayvdb marked this pull request as ready for review July 23, 2026 04:29
@jayvdb
jayvdb requested a review from pierre-tenedero July 23, 2026 04:29

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js (2)

637-658: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Broadcast failure after a successful upload gets misreported as "eye capture failed".

If state.client?.send?.(...) throws after the storage fetch already succeeded, the shared catch logs eye capture failed and emits eye_capture_error_json, even though the image was stored correctly.

🔧 Proposed fix
     state.client?.send?.(py.eye_capture_stored_json(agentId, filename));
-    log(`eye capture saved to storage and broadcast: ${filename} (${bytes.length} bytes)`);
+    log(`eye capture saved to storage: ${filename} (${bytes.length} bytes)`);
+    try {
+      state.client?.send?.(py.eye_capture_stored_json(agentId, filename));
+    } catch (broadcastError) {
+      log(`eye capture broadcast failed (capture already stored): ${String(broadcastError)}`);
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js` around lines 637 - 658,
Update saveEyeCapture so failures from state.client?.send?.(...) after a
successful storage upload are handled separately from capture and upload
failures. Preserve the success log and avoid emitting eye_capture_error_json for
broadcast-only errors; only report capture or storage failures as eye capture
failures.

37-48: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Race: stop() clears runtime before the async back()-navigation cleanup completes.

window.history.back() fires popstate asynchronously, but stop() unconditionally sets runtime = null right after calling it — before the pending exitDemo(state) (triggered by that popstate) actually restores the DOM. If run() is invoked again in that window, if (runtime) return; no longer guards it (runtime is already null), so a new demo session is created while the old exitDemo cleanup is still pending. When that stale exitDemo eventually fires, it replaces document.body with the old demo's previousBodyNodes snapshot, silently wiping out the brand-new demo overlay that was just built.

🔧 Proposed fix
 export function stop() {
   if (!runtime) return;
   const state = runtime;
   state.stopped = true;
   if (state.activeDemo && window.history.state?.pydemo1) {
     window.history.back();
+    // exitDemo() runs asynchronously via the pending popstate and clears `runtime` itself.
   } else {
     exitDemo(state);
+    runtime = null;
   }
-  runtime = null;
   setMainStatus("pydemo1 stopped.");
 }

Also applies to: 23-35, 1069-1071

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js` around lines 37 - 48,
Update stop() so runtime remains set while asynchronous history.back() cleanup
is pending, preventing run() from starting a new session before exitDemo(state)
completes. Clear runtime only after the popstate-triggered cleanup finishes,
while preserving immediate cleanup for the non-navigation path; ensure stale
exitDemo cannot overwrite a newly created demo.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js`:
- Around line 637-658: Update saveEyeCapture so failures from
state.client?.send?.(...) after a successful storage upload are handled
separately from capture and upload failures. Preserve the success log and avoid
emitting eye_capture_error_json for broadcast-only errors; only report capture
or storage failures as eye capture failures.
- Around line 37-48: Update stop() so runtime remains set while asynchronous
history.back() cleanup is pending, preventing run() from starting a new session
before exitDemo(state) completes. Clear runtime only after the
popstate-triggered cleanup finishes, while preserving immediate cleanup for the
non-navigation path; ensure stale exitDemo cannot overwrite a newly created
demo.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cfda6b99-4303-4278-a941-4628936e51a9

📥 Commits

Reviewing files that changed from the base of the PR and between 19c85d7 and 05968aa.

📒 Files selected for processing (5)
  • services/ws-modules/pydemo1/pkg/et_ws_pydemo1.js
  • services/ws-modules/pydemo1/pydemo1/__init__.py
  • services/ws-modules/pydemo1/pydemo1/demo.py
  • services/ws-modules/pydemo1/tests/test_demo.py
  • services/ws-server/static/app.js

@jayvdb
jayvdb merged commit cd94cb4 into main Jul 23, 2026
33 of 34 checks passed
@jayvdb
jayvdb deleted the update-pydemo1 branch July 23, 2026 05:49
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.

2 participants