Skip to content

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

Closed

Description

@HemSoft

Description

The dashboard only reads pmd. pmd.rs is a bounded read-only adapter that loads the read token from pmd_token_path (config.rs). The title bar (render_title_bar) holds the icon, the title, the refresh status and a refresh button. There is no menu, no modal dialog and no way to send a write.

pmd now accepts writes with separate scopes: write:work (#48) and write:fleet (#49). A write token also needs read, because neither write scope implies it (Tokens). The live /v1/whoami for the Chief's token shows read only, so the setup has to be explicit.

This issue builds the shared base for three management dialogs: a Manage menu, a modal dialog frame, and a write client with its own token.

The dialogs that build on this are #34 (Projects, blocked on project-manager#50), #35 (Work items) and #36 (Fleet).

Why

Franz wants to manage projects, work items and the fleet from the dashboard instead of curl. Each dialog needs the same menu entry, modal behavior, token handling and conflict handling. Building that once keeps the three dialogs small and keeps write credentials in one reviewed place. The read path must stay exactly as safe as it is: the AGENTS.md rule is that the dashboard never logs or commits a token.

Goal

A Manage menu in the title bar opens modal dialogs. Writes use a separate write token that is off until configured. The base is tested with a placeholder dialog so the Projects, Work items and Fleet issues only add content.

Acceptance Criteria

  • The title bar has a Manage button that opens a menu with Projects…, Work items…, Fleet… and Write access…. Entries whose dialogs are not built yet are hidden or disabled, never dead.
  • The menu and every dialog work by keyboard. Focus moves into the dialog on open and returns to the menu button on close. Tab and Shift+Tab stay inside the dialog. Esc closes it, Enter activates the default action, and a visible focus ring shows the focused control.
  • A dialog with unsaved edits asks before Esc or the close button discards them.
  • Only one management dialog is open at a time. The table behind it ignores input while it is open, and F5 refresh keeps working.
  • Config gains an optional pmd_write_token_path. Unset means writes are off: the Manage entries that need a token show a one-line reason and Write access… explains how to set it up.
  • Write access… shows the configured token path, the token name and scopes from GET /v1/whoami, and which management dialogs the scopes allow (write:work for Work items, write:fleet for Fleet, the scope from project-manager#50 for Projects). It accepts a pasted token in a masked field and stores it at that path.
  • The token is stored with owner-only access, outside config.toml, ui-state.json and the status cache. The PR states the mechanism and why (a file beside the read token with an owner-only ACL, or the Windows credential store).
  • The token never appears in logs, panics, error strings, the UI, screenshots or test fixtures. The existing scrub behavior for read errors applies to writes, and a test sends a token through every error path and asserts it is absent.
  • A write client in dashboard-core sends PUT and PATCH with If-Match or If-None-Match, no redirects, no proxy, a bounded body and a timeout, like the read client. It never retries a write automatically. After a create that timed out it reads the row before offering a retry, as the pmd README says.
  • The client maps pmd's errors to typed results the dialogs can show: 400 bad_request and the other 400 codes with pmd's message, 401 and 403 insufficient_scope, 404 not_found, 409 stale_version, 409 already_exists, 409 item_closed, 413 too_large, 428 precondition_required, 429 rate_limited and network failure.
  • 409 stale_version shows "Changed elsewhere", re-reads the row with the read token, keeps the user's edits visible next to the new values, and lets them reapply or discard. The base provides this behavior as a reusable piece so each dialog only supplies the fields.
  • Field-level validation errors from a 400 sit next to the field when pmd names it, and in a dialog-level message otherwise. The Save button shows progress and ignores double clicks while a write is in flight.
  • After a successful write, the dashboard reloads the affected pmd data so the table (priority, counts, Board) shows the change without waiting for the five-minute refresh.

Definition of Done

  • Menu, dialog frame, write client and write-access dialog are implemented in the existing crates. Logic that does not need a window lives in dashboard-core.
  • Unit tests cover the write client against a local stub server for every status above. UI tests (#[gpui_kit::test]) cover menu open and close, focus trap, Esc, unsaved-edit confirm and the disabled states.
  • README "Usage" documents the Manage menu, pmd_write_token_path, how to mint a token (pmd token add project-dashboard@home --scopes read,write:work,write:fleet) and AGENTS.md notes that writes are now allowed and where the write client lives. The "pmd is the data source" rule is reworded so it still forbids a gh-x fallback and token logging.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings and cargo test --workspace --locked pass.
  • The PR is reviewed and links this issue with Closes #n.

Validation

  • Run cargo test --workspace --locked and expect the new client and UI tests to pass.
  • Run cargo run -p dashboard-app -- --demo, open Manage with the mouse and again with the keyboard, and confirm Esc returns focus to the button.
  • Point pmd_write_token_path at a read-only token against a local pmd serve, open Write access…, and confirm the scopes show and the Work items entry explains that write:work is missing.
  • Search the captured logs and screenshots for the token string and expect no match.
  • The PR embeds current-head screenshots, rendered with CAPTURE_DIR=$PWD/captures cargo test -p dashboard-app captures -- --ignored and uploaded as GitHub attachments, in its ## Validation section. The states are: title bar with the Manage menu open, a placeholder dialog open, Write access… with writes off, Write access… with a token that has scopes, an inline validation error, the "Changed elsewhere" conflict state and the unsaved-edit confirm. Capture at the default window size and at 150% zoom. Add an inline recording of the keyboard path (open, Tab through, Esc) if practical, otherwise state why not.
  • Accessibility basics are shown by the keyboard recording or tests and by the semantic labels on controls in UI tests. No manual screen-reader pass is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions