Repository navigation
fix(design-v2): confirm before restarting simulation - #1107
anooragsingh07 wants to merge 1 commit into
Conversation
👷 Deploy request for ap-template-playground pending review.Visit the deploys page to approve it
|
|
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
left a comment
There was a problem hiding this comment.
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. AddafterEach(() => vi.restoreAllMocks())to thatdescribe.- 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.
a904b8e to
3d16ca9
Compare
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
mttrbrts-agent
left a comment
There was a problem hiding this comment.
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 changedrestartso stateless templates callresetExecution(), 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.confirmspies, and asking when a restored chain has no runs yet.
Drafted by an Accord Project agent, reviewed by a maintainer.
| return; | ||
| } | ||
|
|
||
| Modal.confirm({ |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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>
3d16ca9 to
0ffe5d3
Compare
Closes #1103
Changes
initthrough the same confirmation; keep first-time initialization immediate.initbehavior.Flags
Screenshots or Video
Related Issues
Author Checklist
a904b8e.mainfromanooragsingh07:codex/confirm-restart-before-reset.