Skip to content

feat: editable plan card, step progress and pause/stop for browser plans (E2.3, E2.4) - #695

Merged
neuromechanist merged 9 commits into
developfrom
feature/issue-662-plan-card-and-step-progress
Nov 11, 2026
Merged

neuromechanist merged 9 commits into
developfrom
feature/issue-662-plan-card-and-step-progress

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

The NEMAR widget now answers the server's propose_plan call with an editable plan card (E2.3, board A2), and shows step headers, a progress strip, a paused bar and Stop plan (E2.4, board A3).

  • Declaring. propose_plan is added to client_tools on /chat and /chat/resume only once the runtime bundle that carries OSARuntime.plan has loaded.
  • The card. It shows the findings, Proposed plan · N steps, Largest step needs about N MB (no budget named), the steps with Edit, Remove (down to 1) and + Add a step (up to 8), the run-mode radios (Pause default, Run all), Approve and run step 1 and Ask for changes (optional note, 1000 characters). Approve and Ask for changes are 44 px tall; every field has a label; model and reader text is escaped.
  • The answer. Approve posts {session_id, result: {call_id, decision, steps, run_mode, feedback?}, client_tools}. Ask for changes posts changes_requested and runs no code.
  • Consent. The plan is answered inside askToRunCode, so osa-controller.js is unchanged. A run that is the plan's next step, or the second attempt of a failed step, skips the permission card. Anything else asks, including a third attempt, a request after the last step, and every request after Stop plan or Ask for changes.
  • Steps. Each run is attributed to a step in the widget (no server change) and stored with step, attempt, stepTitle and elapsedMs. Run cards read Step N · title or Step N failed · ErrorType: message with the elapsed time. A strip says Plan · step N of M with M segments and Pauses after each step or Runs all steps. The bar offers Run step N (sends Continue with step N.), Change step N (prefills the input) and Stop plan, and says Step N+1 waits until step N works. while a failed step retries.
  • Stop plan. It cancels the running step and the reply answers no further request for code (the parked call is left for the next message to repair); the strip says stopped.
  • Reload. The plan and the step fields are stored, bounded; a restored chat shows the plan read-only as Approved with the strip and bar, and buildConversationNotebook names steps by their plan titles.
  • Files. New frontend/osa-plan.js (pure logic, OSARuntime.plan); the DOM and CSS are one block in osa-chat-widget.js; frontend/test-widget-plan-card.js is wired into the frontend-tests job after the History panel step. Also the stale comment in src/assistants/nemar/config.yaml, docs/community-widget.md and CHANGELOG.md.

No change to src/ other than that comment, and none to osa-controller.js.

Closes #662
Closes #671

Commands run

  • bun install
  • bun frontend/test-widget-plan-card.js: 219 passed, 0 failed
  • frontend/test-widget-tools.js (443), test-widget-run-card.js (261), test-widget-history-store.js (212), test-widget-history-panel.js (200), test-widget-handover-events.js (9), test-controller.js (144), test-runtime-bundle.js (39): all pass. The other frontend suites (widget, worker core, workspace, data lane, notebook builder, egress, output, lifecycle, streaming, markdown) also pass.
  • bun scripts/build-runtime-bundle.js && bun scripts/build-runtime-bundle.js --check: bundle is current
  • node --check frontend/osa-chat-widget.js
  • uv run pytest tests/test_frontend tests/test_api/test_propose_plan.py tests/test_api/test_tool_results.py -q: 261 passed (including the 19 cases of the new tests/test_frontend/test_plan_resume_payload.py)
  • uv run ruff check . && uv run ruff format --check .: clean

I also looked at the card, the editor, the paused bar and a failed step at 400 px in light and dark in real Chrome by hand, with a throwaway script that is not part of this PR (no harness screenshots attached, since no browser-harness check is added). Approve, Ask for changes and the bar buttons measured 44 and 36 px tall, with no sideways scroll.

Notes for the reviewer

  • test-widget-plan-card.js and build_plan_payload_fixture.js share frontend/test-support/plan-widget-harness.js, so the payload the Python test parses is the one the widget really posts. A body carries page_context when the reader shares the page; the tests that assert the exact body turn that off, and one scenario keeps it on.
  • frontend/test-workers/executing.js gains a FAIL:<Type>: <message> directive (a run that raised, in the runtime's stderr shape); existing directives are unchanged.
  • test-widget-tools.js now expects propose_plan in the declared tools once the real bundle is loaded.

… OSARuntime.plan

Pure functions for the propose_plan flow (E2.3, E2.4): normalize a proposal, edit, add and
remove steps within 1 to 8, build the PlanDecision, attribute runs to steps (two attempts
a step) and derive the progress. Rebuilt the bundle and its integrity hash. Tested by the
bundle test, which holds the minified logic to the source's; the card tests follow.
…E2.3, E2.4)

The widget declares propose_plan once the runtime bundle loads and answers it with a card
(edit, add, remove, run mode, approve, ask for changes) via /chat/resume. An approved plan
is consent for its steps (the gate answers Run, controller untouched); runs are attributed
to steps and stored with step, attempt, stepTitle and elapsedMs; run cards get step
headers, a strip, a bar with Run step N, Change step N and Stop plan; a reload restores
the plan read-only. Tested in happy-dom against the real widget and bundle
(test-widget-plan-card.js, wired into CI); all other frontend suites pass; checked at
400 px in light and dark in real Chrome by hand.
Drives the real widget through the card in several scenarios and parses what it posts with
ResumeRequest, PlanDecision and build_plan_tool_message; also holds the card's limits to the
server's. Tested: 19 pytest cases pass.
…es propose_plan

Documentation and a YAML comment only (the stale note that the widget does not declare
propose_plan). Not run beyond the tests/test_frontend embed hygiene check.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-662-plan-card--demo.osc.earth
Branch feature/issue-662-plan-card-and-step-progress
Commit 88e37c1

This preview will be updated automatically when you push new commits.

…, announce progress, clip by code point

Review round 1 on the plan card: a failed /chat/resume after Approve or Ask for changes
returns the plan to Not answered; a planned run with status denied reads Step N failed with
the retry line; a live region says where the plan stands; focus moves to the card heading
after a decision and to the strip after Run step N; Edit, Remove and bar buttons are 44 px;
formatStepElapsed no longer prints 1 min 60 s; limits cut by code point; the status
vocabulary and step cleaning are checked against osa-plan.js.
Tested: frontend/test-widget-plan-card.js (261 passed), bundle --check.
…oint limits)

Tested: tests/test_frontend (165 passed).
…the undone decision; fix the stale propose_plan note

Documentation only.
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1: outcome for each finding. Fixes are commits 9f0eb91, eb3603d, b1cc1e8 and c15dc74 on this branch.

  • Critical, tests.yml (Python job has no bun install): fixed in 9f0eb91. The Python job now runs bun install after "Set up Bun" (gated on RUN_ALL), and the comment explains why the plan fixture needs happy-dom. There is no Bun lockfile in the repo, so no --frozen-lockfile. Checked locally on a fresh install; the workflow was only syntax-checked, not run.
  • Important, a failed /chat/resume leaves the plan approved: fixed in eb3603d. continueBrowserReply now calls revokePlanDecision when the answer or resume for a propose_plan call rejects: the plan returns to unanswered (read-only, "Not answered", no strip or bar, nextRun returns null). New test: the resume post fails after Approve, and the next code request asks.
  • Important, denied handled inconsistently: fixed in eb3603d. Decision: a planned run with status denied is a failed attempt, as nextRun and progressOf already count it. planStepFailed now drives the head (Step N failed · denied_import: scipy), the failed card look and the retry line; docs/community-widget.md lists denied. New DENY:<package> marker in test-workers/executing.js and a plan-card test for the head, retry line, strip, bar and the permission-free second attempt.
  • Important, consent by position: fixed by stating it (c15dc74) rather than narrowing it. The widget cannot tell whether code matches a step, and narrowing to "the reply after Approve or Continue" would break a reader who types "go ahead". The docs now have a "trust model" paragraph (what bounds an approval: the sandbox and egress allowlist, two attempts a step, nothing after the last step, Stop plan, the run card showing each step's code, and a new plan needing its own approval). A test pins the behaviour for an unrelated question in pause mode. Not changed: a plan re-proposed inside one reply still counts that reply's earlier runs; the docs say a new plan counts the runs from the reply that proposed it onward.
  • Important, stale CHANGELOG sentence: fixed in c15dc74. The Agent: propose_plan client tool with edit and approve through /chat/resume #660/NEMAR prompt: inspect first, propose a plan, run one step per call #661 entry now says the widget declares propose_plan from Widget: editable plan card with run mode #662 and Widget: step progress, pause and continue, stop plan #671, and the Widget: editable plan card with run mode #662 entry lists this round's changes.
  • Suggestion, accessibility: fixed in eb3603d. (a) A polite live region of its own (.osa-plan-announcer, outside the conversation so a redraw does not replace it) says where the plan stands after each change. (b) Focus goes to the card heading after Approve or Ask for changes, and to the strip after Run step N. (c) The Edit, Remove and bar buttons are 44 px. Tests assert each.
  • Suggestion, formatStepElapsed printing 1 min 60 s: fixed in eb3603d by rounding to whole seconds before splitting; tests cover 59.95, 65, 119.4, 119.6, 119.99 and 120 s.
  • Suggestion, UTF-16 versus code point limits: fixed in eb3603d. osa-plan.js has clip (cuts by code point) used for titles, details, findings and feedback, and the widget's planText does the same; the runtime bundle is rebuilt and --check passes. The Python parity test has a new changes_astral scenario (120-code-point title, 600-code-point detail, over-long note, all emoji) that the server's models accept, with no lone surrogate (b1cc1e8). The maxlength attributes still count code units, which is stricter than the server, so they cannot let through anything it would refuse.
  • Suggestion, duplicated vocabulary and cleaning: fixed in eb3603d. The widget exposes PLAN_STATUS_LABELS and a test checks it against Object.values(PLAN_STATUS) both ways; another test compares the widget's stored-step cleaning with cleanStep on hostile inputs (whitespace, over-long, emoji, non-strings, untitled).

No finding concerned code this PR did not touch, so no issues were filed.

Tests rerun: bun frontend/test-widget-plan-card.js (261 passed), the other widget suites (no failures), bun scripts/build-runtime-bundle.js --check (current), uv run pytest tests/test_frontend (165 passed), uv run ruff check . (clean) and ruff format --check on src, tests and scripts (clean).

…t cannot outlive its render. Tested: all frontend suites pass
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes (fix commit 8f6e4ed):

  • Important, live region reads "Working on step N" after done or stopped: fixed. renderPlanChrome now adds the bar text only when the plan is not done or stopped, so the region reads Plan · all 3 steps done. and Plan stopped · step 1 of 3.. Tests added: the run-all test asserts the done announcement; a new test stops a plan and asserts the stopped announcement with no "Working on".
  • Suggestion, stale planFocusAfterRender: fixed. Run step N returns before setting the selector when a reply is already loading (the only early return in sendMessage besides empty input, which cannot happen here). decidePlan now redraws immediately after resolving the decision, so its selector is consumed by that render and cannot survive to a later one.

Tested: all frontend/test-*.js suites pass under bun (plan card suite: 264 passed, 0 failed).

@neuromechanist

Copy link
Copy Markdown
Member Author

Project manager verdict: ready. All acceptance criteria are covered by the diff and tests (plan card suite 264 passed, all other frontend suites, bundle --check, node --check and tests/test_frontend 166 passed, rerun locally). Every review finding from both rounds has an outcome. All checks pass. Merging with squash.

@neuromechanist
neuromechanist merged commit 9567675 into develop Nov 11, 2026
13 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-662-plan-card-and-step-progress branch November 11, 2026 05:32
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