Skip to content

feat: add a Manage menu, modal dialog frame and write-token support - #37

Merged
HemSoft merged 7 commits into
mainfrom
t3/issue-33-manage-menu
Oct 27, 2026
Merged

HemSoft merged 7 commits into
mainfrom
t3/issue-33-manage-menu

Conversation

@HemSoft

@HemSoft HemSoft commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the shared base for the management dialogs: a Manage menu in the title bar, a reusable modal dialog frame, a pmd write client with its own write token, and the shared 409 stale_version "Changed elsewhere" flow. Projects (#34), Work items (#35) and Fleet (#36) only need to add their content.

  • Menu (dashboard-app/src/manage.rs): Projects…, Work items…, Fleet…, Write access…. Entries that can't open stay visible but disabled, with a one-line reason: not built yet (Add a Projects dialog to track, edit and re-prioritize pmd projects #34/Add a Work items dialog to override status, priority and rank #35/Add a Fleet dialog to manage machines, subscriptions and agents #36), writes off, no token, or the missing scope (for example "the token lacks write:work"). Fully keyboard-driven: Enter, Space or Down opens the menu, Up and Down move, Enter activates, and Esc or Tab closes it and returns focus to the button.
  • Modal frame: focus moves into the dialog on open and is trapped there (Tab and Shift+Tab, through gpui-kit's focus trap). Esc and the close button ask before discarding unsaved edits, Enter runs the default action, and closing returns focus to the Manage button. Every control shows a visible focus ring. Only one dialog is open at a time and the table behind it ignores input. The dialog sits inside the dashboard's element tree, so F5 still refreshes.
  • Write client (dashboard-core/src/write.rs): PUT and PATCH with If-Match or If-None-Match: *, like the read client: no redirects, no proxy, a 64 KB body limit (larger bodies are never sent), a 1 MB response limit and a 40 s timeout (a project create can wait 30 s on GitHub). Writes are never retried. After a create times out, the client reads the row with the read token to say whether it landed. pmd's errors map to typed WriteErrors: every 400 code with pmd's message, 401, 403 insufficient_scope, 404, 409 stale_version / already_exists / item_closed / other, 413, 428, 429 with Retry-After, 5xx with code, timeouts, and network failure. The client is a generic WriteBackend, so write:projects (project-manager#50's PUT /v1/projects/{slug}) fits without changes.
  • Edit flow (dashboard-core/src/edit.rs): Form tracks unsaved edits and the save in flight (a second save while one is running is ignored). It places a 400 next to the field pmd names, or on the dialog otherwise. On stale_version it re-reads the row with the read token and keeps the user's values beside the new ones, with Reapply mine / Discard mine. A successful write reloads pmd data at once.
  • pmd_write_token_path: optional; unset means writes are off. Write access… explains setup when unset. When set, it shows the token file, the name and scopes from GET /v1/whoami, and which dialogs the scopes allow, and accepts a pasted token in a masked field. Editing the setting while the app runs applies at once.

Token storage: mechanism and why

The write token lives in its own file at pmd_write_token_path, beside the read token, never in config.toml, ui-state.json or the status cache. The dashboard creates a new file that is owner-only before any byte is written, then renames it over the old one, so the token is never readable by others, even briefly:

  • Linux/macOS: mode 600 (O_CREAT|O_EXCL with mode 600, then an exact chmod).
  • Windows: the file is created by CreateFileW with the protected DACL D:P(A;;FA;;;OW) attached at creation (full access for OWNER RIGHTS only, nothing inherited from %APPDATA%) and with no sharing, so no other process can open it under the folder's inherited entries. This goes through windows-sys, already in the lock through GPUI. A Windows CI test reads the DACL back.

I chose this over the Windows credential store because the token then sits beside the read token, works the same on every OS, is inspectable with icacls or ls -l, and matches project-manager's own guidance (clients keep tokens in a mode-600 file).

The token never appears in logs, panics, error strings, the UI, screenshots or fixtures. Both tokens are scrubbed from every pmd message. WriteError carries no URL, body or reqwest diagnostic. The client type isn't Debug. The input is masked and cleared once the token is stored. tokens_never_appear_in_any_error sends both tokens through 400+ error paths (every status × error code, echoed in codes, messages and headers, plus timeouts, a closed port, malformed URLs and bodies, and token storage) and asserts neither appears in any Display, Debug or form message.

Placeholder dialog

With --demo, the menu adds Sample dialog (demo)…, which edits an in-memory row. It shows the frame with real fields: a priority above 5 shows pmd's kind of field error, and the first save meets a change made "elsewhere". The tests and screenshots use it. It's hidden outside the demo.

Validation

Head 701e8703d980d62ad90040737982040e6c1460d8, built and run on air (macOS 26, Apple Silicon). It addresses every Codex finding so far:

  • on ce4835e: the Windows token file now gets its DACL at creation; dialog work is bound to the dialog that started it (a_token_save_that_lands_after_its_dialog_closed_leaves_a_newer_dialog_alone, which fails without the fix);

  • on 458e165: saving a token starts a new access generation, so a check about the replaced token is dropped (an_access_check_about_the_replaced_token_cannot_overwrite_the_new_one, which fails without the fix); a failed store rechecks the token still in place (a_failed_token_store_says_why_and_rechecks_the_token_still_in_place).

  • cargo fmt --all --check: clean.

  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean. The Windows ACL module also passes cargo clippy --target x86_64-pc-windows-msvc -D warnings in isolation; CI's windows-latest job builds and runs it in full.

  • cargo test --workspace --locked --no-fail-fast: every dashboard-core suite passes, including 25 new tests in tests/write.rs. The write client runs against a loopback stub for every status above, plus timeouts with no retry, the create read-back, no redirects, body and response limits, path validation, writes-off, owner-only storage and the token-leak test. dashboard-app passes 80, including 15 new UI tests (manage_tests.rs and editing_pmd_write_token_path_turns_writes_on_and_off): menu open and close by mouse and keyboard, focus return, disabled entries with reasons, writes-off setup, scopes, masked token store, the focus trap, unsaved-edit confirm, table input blocked with F5 still working, the field error, the conflict with reapply and discard, the double-save guard, a late token save leaving a newer dialog alone, a stale access check dropped after a token is replaced, and a failed store. Four existing zoom tests fail on macOS only, identically on main: zoom binds secondary-= (Cmd on macOS) while those tests press Ctrl. CI runs Linux and Windows, where they pass.

  • The token strings used by the tests were searched for in the full test log, the capture log, all PNGs and the recording: no match.

  • Not run here: cargo run -p dashboard-app -- --demo with mouse and keyboard on a desktop (screenshots are headless by policy; the recording below drives the same keys in the real view), and the check against a local pmd serve with a read-only token (that state is shown below with an in-memory backend returning read, write:work).

Screenshots. Rendered headlessly with CAPTURE_DIR=$PWD/captures cargo test -p dashboard-app captures -- --ignored. That needed a small change so captures also run on macOS: GPUI's Metal headless renderer, with the text system built directly because the Mac platform object can only be created on the main thread. App default size 1100×760; 150% zoom on the right. These were rendered at ce4835e and re-rendered at 458e165 and 701e870: every PNG and recording frame is byte-identical, so they show the current head. These are macOS renders. Windows-native screenshots can follow once laptop or home is available.

Manage menu open by keyboard, writes off: each entry's reason is visible and the focus ring is on Work items.

Manage menu open, writes off, 100% Manage menu open, writes off, 150%

Manage menu with a read, write:work token: Work items says only "Not built yet (#35)", while Fleet and Projects also name their missing scope.

Manage menu with scoped token, 100% Manage menu with scoped token, 150%

Write access… with writes off: the setup steps, with Close focused.

Write access with writes off, 100% Write access with writes off, 150%

Write access… with a token that has scopes: file, name, scopes, allowed dialogs, and a pasted token masked.

Write access with token scopes, 100% Write access with token scopes, 150%

Placeholder dialog open, focus in the first field.

Sample dialog open, 100% Sample dialog open, 150%

Inline validation error: pmd's 400 naming priority sits under that field.

Inline validation error, 100% Inline validation error, 150%

Unsaved-edit confirm after Esc, with Keep editing focused.

Unsaved-edit confirm, 100% Unsaved-edit confirm, 150%

"Changed elsewhere": your values next to pmd's new ones, with Reapply mine focused.

Changed elsewhere conflict, 100% Changed elsewhere conflict, 150%

Keyboard recording, one frame per key from the headless view: focus Manage → Enter opens the menu → Down ×3 → Enter opens Write access… (focus in the token field) → Tab ×5 cycles close → field → Cancel → Save token → close, staying inside → Shift+Tab → Esc closes, and the focus ring is back on Manage.

manage-keyboard.mp4

Accessibility basics: controls carry roles (Button, Menu, MenuItem, Dialog, AlertDialog, Status) and labels, and disabled entries carry their reason as a description. The UI tests look controls up by these labels. No manual screen-reader pass.

Closes #33

🤖 Generated with Claude Code

HemSoft and others added 4 commits October 26, 2026 20:07
pmd_write_token_path turns writes on. The write client sends PUT and
PATCH with If-Match or If-None-Match, without redirects or proxy, with
bounded bodies and a timeout, and never retries; a timed-out create reads
the row first. pmd's errors map to typed results with both tokens
scrubbed. The token is stored owner-only (mode 600, or a protected
owner-only DACL on Windows). edit.rs holds one row's edit and the shared
409 stale_version flow.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title bar gets a Manage menu with Projects, Work items, Fleet and
Write access. Unbuilt or unauthorized entries stay disabled with a reason.
Dialogs trap focus, close on Esc after asking about unsaved edits, return
focus to the Manage button and leave F5 working. Write access shows the
token's scopes and stores a pasted token. The demo adds a sample dialog
for the validation and Changed elsewhere states. Captures also render on
macOS through GPUI's Metal headless renderer.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T04:01:29.232855Z 701e870 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: ce4835e8ad

ℹ️ 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 thread crates/dashboard-core/src/write.rs Resolved
Comment thread crates/dashboard-app/src/manage.rs Resolved
HemSoft and others added 2 commits October 26, 2026 20:28
Tightening the DACL after creating the file left a moment in which
another process could open it under the folder's inherited entries and
keep that handle. CreateFileW now attaches the protected owner-only
descriptor at creation, with no sharing.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A token save that landed after its dialog closed could clear a newer
Write access dialog's field and its saving state. Each dialog opening now
has an id, and every completion checks it before touching dialog state.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HemSoft

HemSoft commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

1 similar comment
@HemSoft

HemSoft commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 458e16569a

ℹ️ 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 thread crates/dashboard-app/src/manage.rs Resolved
Saving a token now starts a new access generation, so a whoami still
running for the old token can't overwrite the new token's name and
scopes. A failed store rechecks the token still in place instead of
leaving access at Checking.

Refs #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HemSoft

HemSoft commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 701e8703d9

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

@HemSoft
HemSoft merged commit 030ea34 into main Oct 27, 2026
4 checks passed
@HemSoft
HemSoft deleted the t3/issue-33-manage-menu branch October 27, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Manage menu, modal dialog frame and write-token support

1 participant