Skip to content

Approve and deploy from the dashboard - #276

Merged
coryodaniel merged 4 commits into
dashboardfrom
dashboard-actions
Nov 30, 2026
Merged

coryodaniel merged 4 commits into
dashboardfrom
dashboard-actions

Conversation

@coryodaniel

Copy link
Copy Markdown
Member

Stacked on #275.

The dashboard can now change things: approve a deployment that is waiting, or deploy an instance again.

  • n and N pick an instance in the side panel's list, and the picked row is highlighted. A move to another environment clears the pick.
  • y approves the picked instance's deployment when it is awaiting approval.
  • d deploys the picked instance again with its current params, the way mass instance deploy does.
  • Both open a confirmation box that names the action, the instance and its environment, and shows the blast radius: how many environments and instances depend on it downstream. y or enter confirms. Any other key cancels, including esc, q and ctrl+c, so a stray key never quits or acts behind the box.
  • After the call, a toast shows the result, and the map reads again. A permission error says so plainly.
  • --read-only turns both keys off.

NewAPIWithClient now takes a Services struct for the SDK services (audit log, stash, deployment logs, deployer) instead of one argument each.

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Member Author

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 27s —— View job


Review of #276: approve and deploy from the dashboard

I read the diff against origin/dashboard-logs. I did not run make check or make docs, so I haven't verified tests, lint or the generated docs.

The structure follows CLAUDE.md. The logic lives in internal/commands/dashboard, the dependencies are behind a narrow Deployer interface, and cmd/ only reads the flag. The confirmation box swallows every key, including ctrl+c and q, because handleKey checks m.confirm first. That gives the "stray key never acts" behaviour the PR describes.

Issues

  1. The pick is not cleared when you move to another environment. The PR description says it is, but nothing in the diff resets m.picked. I searched for it and found it written only in pickInstance. The pick looks cleared while you're elsewhere, for two reasons:

    • pickedInstance() only looks inside the selected environment.
    • The highlight only renders for rows in the visible environment.

    The ID stays in the model, though. Select env A, press n, move to B, then move back to A. The old row is highlighted again, and y or d acts on it without another n. That is a small surprise for a key that mutates infrastructure. Either clear m.picked wherever m.selected changes, or change the description. I'd clear it. The test cases in actions_test.go don't cover this path either.

  2. Deploy has no guard against an in-flight deployment. d calls CreateDeployment even when the instance is already deploying. inst.Deploying() exists in graph.go, so the dashboard could refuse with a toast, the way approve refuses when nothing is awaiting approval. If the server rejects it, actionError shows the message. If the server accepts it, you queue a second deploy from a stale view. The confirmation box also never says that a deployment is already running.

  3. Deploy re-sends the params from GetInstance. The comment explains why: the server has no "reuse saved params" mode. If Instance.Params can come back with secrets masked or redacted, this would redeploy with the masked values. I haven't checked how the SDK handles that. It's worth confirming that mass instance deploy uses the same read-then-send path, since the PR says it works that way.

Minor

  • ask() shows the blast radius from m.graph.BlastRadius(inst.ID) at the time of the keypress. The graph can refresh while the box is open, and the numbers and the captured deploymentID then go stale. Approving a specific captured deployment ID is the safer choice, so I don't think this needs a change. Maybe note it.
  • actionMsg calls m.fetch(), which cancels any fetch already in flight. That is fine, since it is the refresh you want.
  • Deployer and NewDeployer are exported, but NewAPI is the only caller outside tests. That matches the other services, so I have no objection.
  • The ErrNoDeployer branches in ApproveDeployment and Deploy need tests. I saw tests for the key flow, but I did not check the API layer for that case.

Looks good

  • The Services struct replaces the long positional argument list in NewAPIWithClient, and the call sites in api_test.go and logs_test.go are updated.
  • actionError maps ErrForbidden and ErrUnauthenticated to plain messages.
  • --read-only is checked in the model, not only hidden in the UI.
  • The legend, helpdoc and generated doc all changed together.

Issue 1 is the one I'd fix before merging. Issue 2 is worth a decision.
· branch dashboard-actions

@coryodaniel

coryodaniel commented Nov 28, 2026 •

Copy link
Copy Markdown
Member Author

Fixed in e36ae9c, with origin/dashboard-logs merged in, not rebased, so nothing is force-pushed:

  • 1: the pick is cleared whenever the selection moves. TestActionsFollowTheSelection covers leaving the environment.
  • 2: d refuses an instance that is already deploying, with a toast; covered by the same test.

No change:

  • 3: mass instance deploy (internal/commands/instance/deploy.go) reads the instance and sends its params back the same way, so d behaves like the command people already use.
  • Minor: the approve call takes the deployment ID captured when you press y, so a refresh while the box is open can't move it to another deployment. The ErrNoDeployer paths are tested in TestAPIActions (the bare client).

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 19s —— View job


Re-review of #276 after e36ae9c

I read the new commit and actions.go in full. I did not run make check or make docs, so tests, lint and the generated docs are unverified.

Resolved

  • Pick on leaving an environment. model.go:282 clears picked in Update whenever next.selected != m.selected. That one place catches every path that moves the selection: tab, search, the incident wizard restore and a refresh that reselects. It is better than clearing at each call site. The n, tab, d case in TestActionsFollowTheSelection covers it.
  • Deploy while deploying. ask() (actions.go:161) refuses with a toast. The guard sits in the else of the approve branch, so approving an instance that is mid-deploy is unaffected.
  • Params, approval ID and ErrNoDeployer. Your explanations hold. The approve call uses act.deploymentID, which ask() captured at keypress. TestAPIActions covers the no-deployer paths. I haven't checked mass instance deploy or the SDK's params handling myself, so I'm relying on your account of it.

Remaining nits

None of these block the merge.

  • Guards run only when the box opens. ask() checks Deploying() and AwaitingApproval(), but handleConfirmKey doesn't check them again. If a refresh lands while the box is open, y can still queue a deploy on an instance that has started deploying since. The window is small and the server is the real authority, so I'd accept it. If you want it closed, re-check against the current graph in handleConfirmKey.
  • Confirm-time Deploying() check lacks a direct test. The in-flight case covers ask(), but nothing exercises a graph refresh while the box is open.
  • pickInstance uses the raw instance list. It cycles env.Instances without the Restricted or Unloaded filter that pickedInstance applies. In a restricted or unloaded environment n may set picked, and the next y or d says "pick an instance with n first". That is confusing but harmless. Returning early on those environments would make it consistent.

No blocking issues from me.
· branch dashboard-actions

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

Copy link
Copy Markdown
Member Author

Fixed in 08e4ca4:

  • handleConfirmKey checks again whether the instance has started deploying before it sends a deploy, using the current graph.
  • n does nothing in a restricted or unloaded environment.

I didn't add a test for a refresh landing while the box is open. Driving the model there means hand-building a graph change in the middle of the confirm, and the server still refuses a deploy that conflicts.

@coryodaniel

Copy link
Copy Markdown
Member Author

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 16s —— View job


Re-review of #276 after 08e4ca4

I read actions.go and the model.go, detail.go and views.go changes against origin/dashboard-logs. I did not run make check or make docs, so tests, lint and the generated docs are unverified.

Resolved

  • Confirm-time deploy check. handleConfirmKey (actions.go:~178) re-reads the current graph and refuses a deploy on an instance that has started deploying. This closes the gap I raised last round.
  • n in restricted or unloaded environments. pickInstance now returns early there, so it matches pickedInstance.
  • No test for a refresh landing while the box is open. Your reasoning holds. The server is the real authority, so I accept this.

Remaining nits

None of these block the merge.

  • Approve isn't re-checked at confirm time. An approve whose deployment is no longer awaiting approval goes to the server using the captured deploymentID. The server will reject it and actionError will show the message. That is safe, and the ID capture is the right design. The confirm-time check covers only deploy, which is fine, but a one-line comment would explain why approve is exempt.
  • Nil graph in handleConfirmKey. m.graph.Instance(...) is called without a nil check. ask() only opens the box when a graph exists, and I found nothing that sets m.graph back to nil while the box is open. It is safe today. If Instance isn't nil-receiver safe, a later change could turn this into a panic.
  • Key conflicts. n, N, y and d do not collide with any existing case in model.go. Both the box and the footer hint are gated on m.confirm.

No blocking issues from me. The earlier findings are all resolved or reasonably declined.
· branch dashboard-actions

Base automatically changed from dashboard-logs to dashboard November 30, 2026 06:12
@coryodaniel
coryodaniel merged commit 0d45cb3 into dashboard Nov 30, 2026
2 checks passed
@coryodaniel
coryodaniel deleted the dashboard-actions branch November 30, 2026 06:13
@coryodaniel

Copy link
Copy Markdown
Member Author

Folded into #272.

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.

1 participant