Skip to content

[WRONG BRANCH] fix(gui): protect parked prompt-layer drafts - #360

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-unsaved-changes-bug
Draft

[WRONG BRANCH] fix(gui): protect parked prompt-layer drafts#360
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-unsaved-changes-bug

Conversation

@luvs01

@luvs01 luvs01 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The in-dialog navigation activated parked drafts in memory but the close/save guard only considered the currently visible layer, which could silently discard edits parked on other layers.
  • The change prevents data loss for unsaved custom prompt-layer text when switching targets inside the same dialog.

Description

  • Track parked drafts and whether any parked draft differs from its persisted sibling by keeping per-layer drafts in draftsRef and a parkedDirty flag; added othersRef to safely compare against the saved layers without widening effect deps.
  • Require explicit confirmation before closing or saving if any parked draft is dirty by introducing discardAction and routing close/save through requestClose / requestSave which show the existing discard UI when needed.
  • Wire the Save button to requestSave so a Save from another layer defers until the user confirms discard/save of parked drafts.
  • Added a regression test (8b. closing or saving another layer warns about a parked edit) in gui/tests/codex-set-stack.test.tsx that exercises both the close and save paths and verifies the server PUT behavior.

Testing

  • Ran the focused GUI test file with cd gui && bun test tests/codex-set-stack.test.tsx, and all tests in that file passed (including the new regression).
  • Ran cd gui && bun run lint and cd gui && bun run build and both completed successfully (lint produced only a benign hook warning earlier that was addressed).
  • Attempting the full cd gui && bun test tests run exercised the wider suite; the focused changes are green but the full suite encountered unrelated environment-specific failures (missing Jest timer helpers and a node:zlib symbol) that are not caused by this change.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eaa17ec7-bd01-418d-92e1-bbb4a4a4d7b6


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 28, 2026
@github-actions github-actions Bot changed the title fix(gui): protect parked prompt-layer drafts [WRONG BRANCH] fix(gui): protect parked prompt-layer drafts Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev. UI screenshot required.

What to do

  • Retarget this PR to dev — all contributions go to dev.
  • Add a screenshot of the UI change to the PR description.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 28, 2026 04:18

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

Copy link
Copy Markdown

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: ce8cb8eab3

ℹ️ 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".

<button
type="button"
className="btn btn-danger btn-sm"
onClick={() => discardAction === "save" ? onSave({ ...draft, body: normalized }) : onClose()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the layer selected when Save was requested

When a parked draft triggers the Save confirmation, discardAction records only "save" while draft continues to follow the displayed layer. The header navigation remains enabled, so moving to another layer before clicking Discard makes this callback save that newly displayed layer instead of the layer for which Save was requested; pressing Escape similarly routes through requestClose and changes the pending action to "close". Capture the pending normalized draft when opening the confirmation, or lock navigation and treat Escape as cancellation while it is active.

AGENTS.md reference: gui/AGENTS.md:L31-L34

Useful? React with 👍 / 👎.

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant