🐛 Allow users to edit mission description/steps before running#4341
🐛 Allow users to edit mission description/steps before running#4341clubanderson merged 1 commit intomainfrom
Conversation
Add an Edit button next to Run on saved missions so users can customize the mission description and individual step titles/descriptions before execution. Cmd+Enter in any edit field saves and runs immediately; Escape cancels edits. Fixes #4273 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
✅ Deploy Preview for kubestellarconsole ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
/lgtm |
|
@clubanderson: you cannot LGTM your own PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR adds an inline “Edit before running” experience for saved (not-yet-executed) missions in the mission sidebar, allowing users to modify the mission description and step titles/descriptions prior to execution, and persists those edits via a new updateSavedMission() hook API.
Changes:
- Added
updateSavedMission(missionId, updates)touseMissionsfor persisting edits to saved missions. - Updated
MissionChatto show an Edit toggle + Save/Cancel controls for saved missions before first run. - Implemented keyboard shortcuts (Enter-to-run on container; Cmd/Ctrl+Enter to save+run in fields; Escape to cancel edits).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| web/src/hooks/useMissions.tsx | Adds SavedMissionUpdates and exposes updateSavedMission() through the missions context. |
| web/src/components/layout/mission-sidebar/MissionChat.tsx | Adds pre-run editing UI/UX, keyboard handlers, and wiring to persist/run edited saved missions. |
| onKeyDown={(e) => { | ||
| // Enter (without modifier) on the container triggers Run when not editing | ||
| if (e.key === 'Enter' && !e.metaKey && !e.ctrlKey && !e.shiftKey && !isEditingMission) { | ||
| // Only handle if the target is the container itself (not a child input/textarea) | ||
| const tag = (e.target as HTMLElement).tagName | ||
| if (tag !== 'INPUT' && tag !== 'TEXTAREA') { | ||
| e.preventDefault() |
There was a problem hiding this comment.
The container-level Enter handler is meant to run only when the container itself is the event target, but the current check only excludes INPUT/TEXTAREA. Pressing Enter on other focusable children (e.g., the Edit/Back buttons) will bubble here and can inadvertently trigger runSavedMission. Consider checking e.currentTarget === e.target (or explicitly excluding BUTTON/A elements) before running.
| // Persist any pending edits before running | ||
| if (isEditingMission) saveEdits() | ||
| runSavedMission(mission.id) | ||
| } |
There was a problem hiding this comment.
saveEdits() updates missions state asynchronously, but runSavedMission(mission.id) is called immediately afterward. runSavedMission currently builds the prompt from the hook’s missions state, so this can run with the pre-edit description/steps (stale closure) and ignore the user’s edits. To ensure edits are applied, refactor so the run path uses the just-saved values (e.g., pass the edited prompt/steps into runSavedMission, or make runSavedMission read from the same functional-updater result / updated mission data).
| if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { | ||
| e.preventDefault() | ||
| saveEdits() | ||
| runSavedMission(mission.id) |
There was a problem hiding this comment.
The Cmd/Ctrl+Enter handler runs runSavedMission directly, bypassing the Netlify/demo-mode guards used by the Run button. This means the shortcut may attempt to execute locally even in environments where you intend to open the install/agent-setup dialogs. Align this path with the same isNetlifyDeployment / isDemoMode checks as the button handler.
| runSavedMission(mission.id) | |
| if (!isNetlifyDeployment() && !isDemoMode) { | |
| runSavedMission(mission.id) | |
| } |
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { | ||
| e.preventDefault() | ||
| saveEdits() | ||
| runSavedMission(mission.id) | ||
| } else if (e.key === 'Escape') { |
There was a problem hiding this comment.
Same as the description field: Cmd/Ctrl+Enter here runs runSavedMission directly, bypassing Netlify/demo-mode guards. It also calls saveEdits() immediately before running, which can race with state updates and run with stale mission content unless the run path is refactored to consume the edited values.
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { | ||
| e.preventDefault() | ||
| saveEdits() | ||
| runSavedMission(mission.id) | ||
| } else if (e.key === 'Escape') { |
There was a problem hiding this comment.
Same as the description field: Cmd/Ctrl+Enter here runs runSavedMission directly, bypassing Netlify/demo-mode guards. It also calls saveEdits() immediately before running, which can race with state updates and run with stale mission content unless the run path is refactored to consume the edited values.
| ? t('missionChat.editHint', { defaultValue: 'Edit the description and steps below, then Run or press Enter' }) | ||
| : t('missionChat.runHint', { defaultValue: 'Press Enter to run, or Edit to customize first' })} |
There was a problem hiding this comment.
The inline hint shown while editing says “then Run or press Enter”, but the implemented shortcut in fields is Cmd/Ctrl+Enter (plain Enter just inserts a newline / does nothing). This is user-facing guidance, so it should match the actual keyboard behavior (e.g., mention Cmd/Ctrl+Enter).
| ? t('missionChat.editHint', { defaultValue: 'Edit the description and steps below, then Run or press Enter' }) | |
| : t('missionChat.runHint', { defaultValue: 'Press Enter to run, or Edit to customize first' })} | |
| ? t('missionChat.editHint', { defaultValue: 'Edit the description and steps below, then Run or press Cmd/Ctrl+Enter' }) | |
| : t('missionChat.runHint', { defaultValue: 'Press Cmd/Ctrl+Enter to run, or Edit to customize first' })} |
🔄 Auto-Applying Copilot Code ReviewCopilot code review found 2 code suggestion(s) and 4 general comment(s). @copilot Please apply all of the following code review suggestions:
Also address these general comments:
Push all fixes in a single commit. Run Auto-generated by copilot-review-apply workflow. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
All 6 review items addressed in commit
|
saveEdits()+runSavedMission()use stale state — addsaveAndRunMission()callback passing fresh edit values as overrides torunSavedMission(lines 542, 679, 696)