Skip to content

Save before navigate in workspace#1960

Open
AaronPlave wants to merge 5 commits into
developfrom
feat/workspace-navigation-confirm-save
Open

Save before navigate in workspace#1960
AaronPlave wants to merge 5 commits into
developfrom
feat/workspace-navigation-confirm-save

Conversation

@AaronPlave

@AaronPlave AaronPlave commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Save and Navigate option to the workspace "unsaved changes" prompt. Previously, leaving a file with unsaved edits meant either discarding them or staying put. Now you can save and continue in one step. Also fixes a couple of related bugs found along the way. Closes #1959

Details

  • The unsaved-changes prompt now offers three choices everywhere it appears: switching files, leaving the page, and opening the Actions view: Save and Leave, Discard and Leave, or Keep Editing (Save is the default).
  • If a save fails, navigation is cancelled and your edits are kept.
  • Saving a brand-new (never-named) file through this prompt opens the save file modal first.
  • Fixed a pre-existing bug where switching to the Actions view and back dropped the open file from the URL (broke refresh / deep links).
  • The "don't proceed if the save failed" guard now also covers move / rename / download / run-action on a file with unsaved changes.

Visible UX Changes

  • New Save and Navigate / Save and Leave button in the unsaved-changes dialog.
  • Clearer wording: the dialog is now titled Unsaved Changes, and the discard button reads Discard and Navigate (was "Navigate Away") and is styled as a destructive action so it's obvious it drops your edits.
  • Returning to the Files tab keeps the current file in the URL.

Verification

  • Added e2e tests to e2e-tests/tests/workspace.test.ts

Manual steps (open a workspace with a couple of sequence files):

  1. Save and Navigate — Open file A, make an edit, click file B → Save and Navigate. You land on file B; reopen file A and confirm the edit was saved.
  2. Discard and Navigate — Edit file A, click file B → Discard and Navigate. You land on file B; reopen file A and confirm the edit is gone.
  3. Keep Editing — Edit file A, click file B → Keep Editing. You stay on file A with the edit intact.
  4. Save into the Actions view — Edit a file, click the Actions tab → Save and Navigate, then click back to Files. The file is saved, still open, and present in the URL.
  5. Save a brand-new draft — With no file open, type in the editor, click the Actions tab → Save and Navigate → enter a name → Confirm. Back on Files, the new file is open with your content and in the URL (not a blank editor). Refresh to confirm the URL reopens it.
  6. Leave the page — Edit a file, then navigate to another section (e.g. Plans). Confirm Save and Leave, Discard and Leave, and Stay on Page each behave as labeled.
  7. URL preservation — Open a file, click the Actions tab, then the Files tab. The file is still in the URL; refreshing reopens the same file.
  8. Failed save aborts navigation (optional) — In devtools, set the network offline, then choose Save and Navigate. A failure toast appears, navigation is cancelled, and your edits remain.
  9. Save before move/rename — Edit a file, then move or rename it and confirm "Save and …". With the network offline, the operation aborts and your edits are kept.

@AaronPlave AaronPlave self-assigned this Jun 23, 2026
@AaronPlave AaronPlave added the feature New feature or request label Jun 23, 2026
@AaronPlave AaronPlave changed the title Save before navigate in workspace WIP Save before navigate in workspace Jun 23, 2026
@AaronPlave AaronPlave changed the title WIP Save before navigate in workspace WIP: Save before navigate in workspace Jun 23, 2026
@AaronPlave AaronPlave changed the title WIP: Save before navigate in workspace Save before navigate in workspace Jun 23, 2026
@AaronPlave AaronPlave marked this pull request as ready for review June 23, 2026 15:36
@AaronPlave AaronPlave requested a review from a team as a code owner June 23, 2026 15:36
'Navigate Away',
true,
const { confirm, value } = await showUnsavedChangesModal(
'There are unsaved changes. What would you like to do before navigating away from the current file?',

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.

Is it possible to extract the invocation of showUnsavedChangesModal to a function that can be used here and reused in the beforeNavigate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

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.

Oh! Sorry. I meant to also include the messages and labels as hardcoded into the function itself so that they wouldn't be repeated in separate places. Is there a desire to make this function flexible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I see what you mean, there are differences in copy between these invocations so I did a bit more streamlining so that there should be no duplication now. See what you think.

@AaronPlave AaronPlave force-pushed the feat/workspace-navigation-confirm-save branch from 3014833 to 096ba25 Compare June 25, 2026 23:22
@AaronPlave AaronPlave force-pushed the feat/workspace-navigation-confirm-save branch from 5eb82b2 to 151d535 Compare July 10, 2026 16:08
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Save" button to modal when navigating away from a sequence

2 participants