Skip to content

🐛 Allow users to edit mission description/steps before running#4341

Merged
clubanderson merged 1 commit intomainfrom
fix/4273-mission-edits
Apr 2, 2026
Merged

🐛 Allow users to edit mission description/steps before running#4341
clubanderson merged 1 commit intomainfrom
fix/4273-mission-edits

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

@clubanderson clubanderson commented Apr 2, 2026

  • Fix container Enter handler to also exclude BUTTON/A elements (line 516)
  • Fix race condition: saveEdits() + runSavedMission() use stale state — add saveAndRunMission() callback passing fresh edit values as overrides to runSavedMission (lines 542, 679, 696)
  • Add Netlify/demo-mode guards to Cmd/Ctrl+Enter handlers in description & step fields (lines 620, 679, 696)
  • Update hint text to say "Cmd/Ctrl+Enter" instead of just "Enter" (line 591)
  • Build & lint pass (no new errors in changed files)

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>
Copilot AI review requested due to automatic review settings April 2, 2026 22:02
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 2, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 7c3cfb3
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cee75d59703d0008a79a4d
😎 Deploy Preview https://deploy-preview-4341.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 2, 2026
@clubanderson
Copy link
Copy Markdown
Collaborator Author

/lgtm
/approve

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@clubanderson: you cannot LGTM your own PR.

Details

In response to this:

/lgtm
/approve

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.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
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

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) to useMissions for persisting edits to saved missions.
  • Updated MissionChat to 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.

Comment on lines +510 to +516
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()
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +539 to +542
// Persist any pending edits before running
if (isEditingMission) saveEdits()
runSavedMission(mission.id)
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
saveEdits()
runSavedMission(mission.id)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
runSavedMission(mission.id)
if (!isNetlifyDeployment() && !isDemoMode) {
runSavedMission(mission.id)
}

Copilot uses AI. Check for mistakes.
Comment on lines +674 to +679
onKeyDown={(e) => {
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
saveEdits()
runSavedMission(mission.id)
} else if (e.key === 'Escape') {
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +691 to +696
onKeyDown={(e) => {
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
saveEdits()
runSavedMission(mission.id)
} else if (e.key === 'Escape') {
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +590 to +591
? 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' })}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
? 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' })}

Copilot uses AI. Check for mistakes.
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🔄 Auto-Applying Copilot Code Review

Copilot code review found 2 code suggestion(s) and 4 general comment(s).

@copilot Please apply all of the following code review suggestions:

  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 620): if (!isNetlifyDeployment() && !isDemoMode) { runSavedM...
  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 591): ? t('missionChat.editHint', { defaultValue: 'Edit the description and steps belo...

Also address these general comments:

  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 516): The container-level Enter handler is meant to run only when the container itself is the event target, but the current ch
  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 542): saveEdits() updates missions state asynchronously, but runSavedMission(mission.id) is called immediately afterward.
  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 679): Same as the description field: Cmd/Ctrl+Enter here runs runSavedMission directly, bypassing Netlify/demo-mode guards.
  • web/src/components/layout/mission-sidebar/MissionChat.tsx (line 696): Same as the description field: Cmd/Ctrl+Enter here runs runSavedMission directly, bypassing Netlify/demo-mode guards.

Push all fixes in a single commit. Run cd web && npm run build && npm run lint before committing.


Auto-generated by copilot-review-apply workflow.

@clubanderson clubanderson merged commit 1737437 into main Apr 2, 2026
28 of 34 checks passed
@kubestellar-prow kubestellar-prow bot deleted the fix/4273-mission-edits branch April 2, 2026 22:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

🔄 Auto-Applying Copilot Code Review

Copilot code review found 2 code suggestion(s) and 4 general comment(s)....

All 6 review items addressed in commit 0617c7d:

  1. Container Enter handler (line 516): Extended tag exclusion to also cover BUTTON and A elements, preventing Enter-on-button from accidentally triggering runSavedMission.

  2. Race condition (lines 542, 679, 696): Added a saveAndRunMission() callback that snapshots the current edit values and passes them as overrides directly to runSavedMission. Extended runSavedMission in useMissions to accept optional overrides: SavedMissionUpdates and use those values in preference to reading from potentially stale React state.

  3. Netlify/demo-mode guards (lines 620, 679, 696): All three Cmd/Ctrl+Enter handlers in the description field and step title/description fields now check isNetlifyDeployment / isDemoMode and dispatch the appropriate install/agent-setup events, consistent with the Run button.

  4. Hint text (line 591): Updated to say "Cmd/Ctrl+Enter" in both the edit hint and run hint strings.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants