Skip to content

fix(design-v2): confirm before restarting simulation - #1107

Open
anooragsingh07 wants to merge 1 commit into
accordproject:mainfrom
anooragsingh07:codex/confirm-restart-before-reset
Open

anooragsingh07 wants to merge 1 commit into
accordproject:mainfrom
anooragsingh07:codex/confirm-restart-before-reset

Conversation

@anooragsingh07

Copy link
Copy Markdown

Closes #1103

Changes

  • Confirm before restarting an initialized Design V2 simulation, so cancelling preserves the current runs and contract state.
  • Route re-running init through the same confirmation; keep first-time initialization immediate.
  • Add focused component regression tests for the confirmation and re-run init behavior.

Flags

  • None.

Screenshots or Video

  • Not applicable; this is a behavior-only fix.

Related Issues

Author Checklist

  • DCO sign-off included in commit a904b8e.
  • Regression coverage added; the focused component suite passes (27 tests).
  • Commit message follows the Accord Project AP format.
  • Documentation changes are not needed for this UI behavior fix.
  • Merging to main from anooragsingh07:codex/confirm-restart-before-reset.

@netlify

netlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

👷 Deploy request for ap-template-playground pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 0ffe5d3

@mira-accord-project

Copy link
Copy Markdown

Thank you for this fix, and welcome to the Accord Project! Adding a confirmation before a Design V2 simulation restart, so that cancelling keeps the current runs and contract state, is a useful change. The regression tests for both the confirmation and the re-run path are a good start.

What happens next: the test and E2E workflows were waiting for a maintainer to approve them, which is normal for a first contribution, and a maintainer has now approved them. Review has been requested from the playground maintainers. The PR is still a draft, so please mark it ready for review when you are happy with it.

Drafted by an Accord Project agent, reviewed by a maintainer.

@mttrbrts mttrbrts left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this looks good. Routing both Restart and re-running init through one restart path, and skipping the dialog when there's no history, is the right shape.

Nits:

  • vi.spyOn(Modal, 'confirm') is never restored and leaks into later tests. Add afterEach(() => vi.restoreAllMocks()) to that describe.
  • Please add a test that clicking Cancel does not reset the history.

The E2E failure isn't caused by this PR. It's the runner issue that #1094 fixes. Mark it ready for review when you're happy with it.

@mttrbrts
mttrbrts force-pushed the codex/confirm-restart-before-reset branch from a904b8e to 3d16ca9 Compare November 16, 2026 09:41
@anooragsingh07
anooragsingh07 marked this pull request as ready for review November 16, 2026 15:39
@anooragsingh07
anooragsingh07 requested a review from a team as a code owner November 16, 2026 15:39

@mira-accord-project mira-accord-project 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.

Thank you for this, and for your first contribution. Asking before Restart or a re-run of init throws away the runs is a good fix for #1103. It uses the same antd Modal.confirm approach as the classic runner, the copy lives in constants.ts, and the new tests check that the dialog opens, that initContract is not called until the user confirms, and that the first init runs straight away. To make it mergeable: (1) cover the case in the finding below, where a restored chain has no runs after a page refresh, and (2) rebase on main, because GitHub currently reports a merge conflict.

Nothing blocking; some suggestions below. Findings: 1 should-fix.


Automated review by Mira, an Accord Project agent, at 3d16ca9. Findings are labelled blocking, should-fix or nit; a maintainer makes the final call.


if (history.length === 0) {
void startNewContract();
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should-fix · correctness

The confirmation is skipped when history.length === 0, but executionHistory is not persisted while executionChain is (see getInitialChain in src/store/store.ts). After a page refresh the chain, state and isContractInitialized are restored, so Send is enabled, but the runs list is empty and the empty-state Init button is shown. Clicking it calls restart(), which skips the confirmation, and initContract() then runs resetExecution() and wipes the restored chain and state without asking. The classic runner guards on executionChain.length > 0 for the same reason. Suggested fix: also read executionChain (or isContractInitialized) from useAppStore and skip the confirmation only when both the history and the chain are empty. A test that sets a non-empty chain with an empty history and expects Modal.confirm to be called would cover it.

@github-actions github-actions Bot added the maintainer-engaged A maintainer has commented or reviewed this item label Nov 17, 2026

@mttrbrts-agent mttrbrts-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this, @anooragsingh07. Asking before a restart throws away the runs is the right fix for #1103, and putting both Restart and re-running init behind one restart path keeps it simple. To make it mergeable:

  • Rebase on main. #1083 changed restart so stateless templates call resetExecution(), and that path clears the runs too, so keep it behind the confirmation.
  • Switch to Modal.useModal() so the dialog picks up the Design V2 theme (see the inline comment).
  • Address the open points from the earlier reviews: a Cancel test, no leaked Modal.confirm spies, and asking when a restored chain has no runs yet.

Drafted by an Accord Project agent, reviewed by a maintainer.

return;
}

Modal.confirm({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Modal.confirm(...) is the static form. Ant Design renders it in a separate React root outside the ConfigProvider theme={designV2Theme(isDark)} in DesignV2Layout.tsx, so the dialog doesn't use the Design V2 palette or fonts, and in dark mode it falls back to the classic playground's global .ant-modal-confirm styles. The rail's reset confirmation already solves this (Rail.tsx, around line 40): const [modal, modalContext] = Modal.useModal();, call modal.confirm({...}), and render {modalContext} inside the component. As a bonus, the tests can then open the real dialog and click its buttons by role instead of spying on Modal.confirm.

it('restart re-initialises the contract', () => {
it('asks before restarting when execution history exists', () => {
let confirmOptions: ModalFuncProps | undefined;
const confirm = vi.spyOn(Modal, 'confirm').mockImplementation((options: ModalFuncProps) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two points from the earlier review are still open here. The vi.spyOn(Modal, 'confirm') spies (here and in the two tests below) are never restored; the only vi.restoreAllMocks() is in the nested copy block's afterEach. And no test clicks Cancel and checks that the history and selected run survive. Moving to Modal.useModal() removes the spies entirely: click getByRole('button', { name: SIMULATE.restartConfirm.cancelText }) and assert that initContract was not called and executionHistory is unchanged.

Signed-off-by: Anoorag Singh <anooragsingh0007@gmail.com>
@anooragsingh07
anooragsingh07 force-pushed the codex/confirm-restart-before-reset branch from 3d16ca9 to 0ffe5d3 Compare November 21, 2026 11:19

This branch has not been deployed

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

Labels

ai/decision:needs-review ai/kind:bugfix ai/risk:medium bug Something isn't working maintainer-engaged A maintainer has commented or reviewed this item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Design V2] Re-running init clears simulation history without confirmation

3 participants