Skip to content

Prevent create-file modal from closing during creation#4298

Open
jurgenwerk wants to merge 1 commit intomainfrom
cs-10557-creating-a-card-definition-can-fail-after-dismissing-the
Open

Prevent create-file modal from closing during creation#4298
jurgenwerk wants to merge 1 commit intomainfrom
cs-10557-creating-a-card-definition-can-fail-after-dismissing-the

Conversation

@jurgenwerk
Copy link
Copy Markdown
Contributor

@jurgenwerk jurgenwerk commented Apr 1, 2026

There is a scenario where if you choose to create a card or file using the modal in code mode, and click "Create" and then immediately close the modal, this error would show up next time you open the modal:

image

I think we should not allow the user to close the modal if file creation is still in progress. This fixes the problem.

The modal's onCancel now returns early if any creation task is running,
preventing the crash caused by accessing newFileDeferred on an already-
cleared currentRequest.

Fixes CS-10557

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Preview deployments

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Realm Server Test Results

  1 files  ±0    1 suites  ±0   12m 11s ⏱️ -15s
828 tests ±0  828 ✅ ±0  0 💤 ±0  0 ❌ ±0 
899 runs  ±0  899 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 49faad7. ± Comparison against base commit 1a594af.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   2h 13m 2s ⏱️ -28s
2 092 tests +1  2 077 ✅ +1  15 💤 ±0  0 ❌ ±0 
2 107 runs  +1  2 092 ✅ +1  15 💤 ±0  0 ❌ ±0 

Results for commit 49faad7. ± Comparison against base commit 1a594af.

@jurgenwerk jurgenwerk marked this pull request as ready for review April 1, 2026 12:08
@jurgenwerk jurgenwerk requested a review from Copilot April 1, 2026 12:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Prevents the “Create file/card” modal in operator code mode from being dismissed while a create/duplicate operation is in-flight, avoiding a broken modal state on subsequent opens.

Changes:

  • Block modal cancellation/dismissal when a create task (or duplicate task) is running.
  • Add an acceptance test that simulates an in-flight create request and verifies the modal remains open until completion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/host/app/components/operator-mode/create-file-modal.gts Guards onCancel so the modal cannot be closed while create/duplicate tasks are running.
packages/host/tests/acceptance/code-submode/create-file-test.gts Adds an acceptance test that blocks the save POST request and attempts to dismiss the modal during creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +601 to +603
if (this.isCreateRunning || this.duplicateCardInstance.isRunning) {
return;
}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

onCancel now no-ops while a create/duplicate task is running, but the UI controls that trigger it (Cancel button, close “X”, overlay/escape) will still look interactive and just do nothing. Consider also reflecting the blocked-close state in the UI (e.g., disable the Cancel/close controls and/or show a short “Creating…” hint) so keyboard/screen-reader users get correct affordances.

Suggested change
if (this.isCreateRunning || this.duplicateCardInstance.isRunning) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines 600 to +601
@action private onCancel() {
if (this.isCreateRunning || this.duplicateCardInstance.isRunning) {
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The “cannot close while busy” condition is split between isCreateRunning and an extra duplicateCardInstance.isRunning check here. To keep the busy/disabled logic consistent across the component, consider folding duplicateCardInstance.isRunning into isCreateRunning (or introducing a single isBusy getter) and use that everywhere.

Suggested change
@action private onCancel() {
if (this.isCreateRunning || this.duplicateCardInstance.isRunning) {
private get isBusy() {
return this.isCreateRunning || this.duplicateCardInstance.isRunning;
}
@action private onCancel() {
if (this.isBusy) {

Copilot uses AI. Check for mistakes.
let createClickPromise = click('[data-test-create-definition]');

// Wait for the POST to be intercepted (task is now mid-creation)
await waitUntil(() => postIntercepted);
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

waitUntil(() => postIntercepted) uses the helper’s default timeout, which can make this acceptance test flaky on slower CI runs. Please pass an explicit timeout and timeoutMessage so failures are deterministic and easier to diagnose.

Suggested change
await waitUntil(() => postIntercepted);
await waitUntil(() => postIntercepted, {
timeout: 10000,
timeoutMessage:
'Timed out waiting for save POST to be intercepted in create-file-test (modal cannot be dismissed while creation is in progress).',
});

Copilot uses AI. Check for mistakes.
// settled, which won't resolve while the creation task is blocked)
let cancelBtn = document.querySelector(
'[data-test-cancel-create-file]',
) as HTMLElement;
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

document.querySelector('[data-test-cancel-create-file]') as HTMLElement will throw a less-informative error if the selector ever changes (null deref on .click()). Prefer asserting it exists (or using a non-null check with a clear failure message) before clicking to make this test easier to debug.

Suggested change
) as HTMLElement;
);
if (!cancelBtn) {
throw new Error(
'Could not find [data-test-cancel-create-file] button while creation is in progress',
);
}

Copilot uses AI. Check for mistakes.
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