Skip to content

fix(web): expose manual edit undo/redo and save confirmation#3034

Open
leno23 wants to merge 1 commit into
nexu-io:mainfrom
leno23:fix/manual-edit-undo-ui-2866
Open

fix(web): expose manual edit undo/redo and save confirmation#3034
leno23 wants to merge 1 commit into
nexu-io:mainfrom
leno23:fix/manual-edit-undo-ui-2866

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

Fixes #2866

Also helps #2905 — the edit panel now shows transient Saved ✓ / Saving… feedback after persisted manual edits (including deletes), even though the legacy HTML tab UI is no longer present.

Summary

Manual edit history (undoManualEdit / redoManualEdit) already worked in FileViewer, but ManualEditPanel never rendered controls or keyboard shortcuts, so deletes felt irreversible.

Surface area

  • apps/web/src/components/ManualEditPanel.tsx — Undo/Redo buttons, Cmd/Ctrl+Z shortcuts, saved status line.
  • apps/web/src/components/FileViewer.tsx — track manualEditSavedAt after successful writes/undo/redo.
  • apps/web/src/styles/viewer/memory.css — titlebar status styling.
  • Tests in ManualEditPanel.test.tsx and FileViewer.manual-edit-history.test.tsx.

Validation

  • cd apps/web && pnpm test tests/components/ManualEditPanel.test.tsx tests/components/FileViewer.manual-edit-history.test.tsx — 27 passed.

Made with Cursor

…#2866)

Wire the existing history callbacks into the edit panel with Undo/Redo
buttons, keyboard shortcuts, and a transient Saved status after writes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8281a87753

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +90 to +94
const mod = event.metaKey || event.ctrlKey;
if (!mod || event.altKey) return;
if (event.key.toLowerCase() === 'z' && !event.shiftKey && canUndo) {
event.preventDefault();
onUndo();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Skip document undo hotkeys when focus is in editable fields

The new global keydown listener handles Cmd/Ctrl+Z without checking whether the focused element is an input, textarea, or contentEditable, so once canUndo is true, pressing undo while typing in any manual-edit form control triggers onUndo() and writes an older full document to disk instead of undoing text in that field. This is a destructive behavior change for normal editing workflows; the shortcut handler should bail out for editable targets (and typically for already-handled events).

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

Visual regression review

Head: 8281a87 · Base: 1d72914

0 changed · 17 unchanged · 0 missing baseline · 0 failed

Unchanged cases
Case Main PR Diff
visual-avatar-menu main pr diff
visual-design-systems main pr diff
visual-home main pr diff
visual-home-catalog main pr diff
visual-home-context-picker main pr diff
visual-home-plugin-filter main pr diff
visual-integrations main pr diff
visual-integrations-use-everywhere main pr diff
visual-new-project-modal main pr diff
visual-plugin-details main pr diff
visual-plugins main pr diff
visual-projects main pr diff
visual-projects-kanban main pr diff
visual-settings-byok main pr diff
visual-settings-execution main pr diff
visual-tasks main pr diff
visual-topbar-execution-switcher main pr diff

Visual diff is advisory only and does not block merging.

Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

Hi @leno23! Thanks for tying #2866 to the manual-edit history path — the Summary and Validation make the intent clear. One PR-body thing before pool review: could you update ## Surface area to use the checklist and tick UI? This touches visible ManualEditPanel controls/status, so the checklist helps reviewers and release verification scope it quickly.

Related: #2925 by @xxiaoxiong is also open in this area and overlaps on FileViewer.tsx, ManualEditPanel.tsx, and memory.css for #2905 save-confirmation feedback. You two may want to compare approaches; the maintainer team will pick what lands.

Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

Hi @leno23! Thanks for tying #2866 to the manual-edit history path — the Summary and Validation make the intent clear. One PR-body thing before pool review: could you update ## Surface area to use the checklist and tick UI? This touches visible ManualEditPanel controls/status, so the checklist helps reviewers and release verification scope it quickly.

Related: #2925 by @xxiaoxiong is also open in this area and overlaps on FileViewer.tsx, ManualEditPanel.tsx, and memory.css for #2905 save-confirmation feedback. You two may want to compare approaches; the maintainer team will pick what lands.

Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

Hi @leno23! Thanks for tying #2866 to the manual-edit history path — the Summary and Validation make the intent clear. One PR-body thing before pool review: could you update ## Surface area to use the checklist and tick UI? This touches visible ManualEditPanel controls/status, so the checklist helps reviewers and release verification scope it quickly.

Related: #2925 by @xxiaoxiong is also open in this area and overlaps on FileViewer.tsx, ManualEditPanel.tsx, and memory.css for #2905 save-confirmation feedback. You two may want to compare approaches; the maintainer team will pick what lands.

Copy link
Copy Markdown
Contributor

@PerishCode PerishCode left a comment

Choose a reason for hiding this comment

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

@leno23 — thanks for closing the loop on #2866 with the undo/redo controls, keyboard shortcuts, and the transient Saved ✓ confirmation in ManualEditPanel. The tests cover both the panel-level wiring and the FileViewer history regression (delete → undo restores the element), which is exactly the right shape for a bugfix PR.

One non-blocking inline finding (i18n consistency for the new status label).

Unrelated to this review's inline finding, the existing unresolved Codex thread on the global keydown listener is worth addressing before merge: ManualEditPanel contains several <input> elements (UnitRow, ColorRow, QuadCell), so Cmd/Ctrl+Z while focus is in one of those inputs will now hit the window-level handler instead of native input undo, overwriting the file with the previous persisted snapshot. A guard such as if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement || (event.target as HTMLElement)?.isContentEditable) return; would resolve it.

🔁 Powered by Looper · runner=reviewer · agent=claude-code · An autonomous AI dev team for your GitHub repos.

Comment on lines +128 to +136
{busy ? (
<em className="manual-edit-status" data-testid="manual-edit-status">
Saving…
</em>
) : showSaved ? (
<em className="manual-edit-status" data-testid="manual-edit-status">
Saved ✓
</em>
) : null}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The two new status labels are hardcoded English: Saving… (line 130) and Saved ✓ (line 134). The surrounding titlebar text was migrated to t('manualEdit.title') in this same PR, and the new undo/redo buttons below use t('manualEdit.undo') / t('manualEdit.redo'), so a non-English locale (e.g. zh-CN, ja, fr) will render this titlebar as a mix of localized + raw English, which is jarring and breaks the i18n convention the rest of this PR follows.

Why it matters: per the root AGENTS.md i18n keys section, user-visible strings must be defined as typed keys in apps/web/src/i18n/types.ts and populated for all 18 locale files. The change to t('manualEdit.title') clearly intends to honor that contract; the new status strings sidestep it for the same surface in the same patch.

Suggested change: add two new keys to apps/web/src/i18n/types.ts (for example 'manualEdit.savingStatus': string and 'manualEdit.savedStatus': string), populate them in every file under apps/web/src/i18n/locales/ (the English values can stay Saving… / Saved ✓ — translators can localize later), and replace these two literals with t('manualEdit.savingStatus') and t('manualEdit.savedStatus'). Keep the existing <em className="manual-edit-status" data-testid="manual-edit-status"> wrapper and the visual treatment unchanged so the test selectors still match.

🔁 Powered by Looper · runner=reviewer · agent=claude-code · An autonomous AI dev team for your GitHub repos.

@lefarcen
Copy link
Copy Markdown
Contributor

Heads-up: PR #3055 is also open in this manual-edit feedback area. Both PRs touch apps/web/src/components/FileViewer.tsx; #3034 covers undo/redo + save confirmation more broadly, while #3055 is a narrower Apply HTML success toast for #2905.

You and @DonQuilatte may want to coordinate so effort does not get duplicated; maintainers will pick the final shape.

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

Labels

risk/medium Medium risk: regular code changes size/M PR changes 100-300 lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Deleted elements cannot be undone in Edit mode

3 participants