Repository navigation
feat: let a desktop app run and manage Levelrail in a local VM - #1882
Conversation
|
Important Review skippedToo many files! This PR contains 158 files, which is 58 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This organization's CodeRabbit subscription is cancelled. Resubscribe in Billing to continue reviews beyond the free-tier limit.
|
glinr-botA protected condition applies, so a person decides.
No action taken. A person reviews this one. Checks (shadow, nothing is enforced)
Next steps:
|
| if err := c.DetachPolicy(ctx, policyID, a.PrincipalType, a.PrincipalID); err != nil { | ||
| warnings = append(warnings, fmt.Sprintf("could not detach %s %s from the %s policy: %v", a.PrincipalType, a.PrincipalID, LocalLoginPolicyName, err)) |
There was a problem hiding this comment.
Old tokens gain database access
detachOtherPrincipals removes the policy from tokens that remain valid. For an earlier local login whose credentials were lost or replaced, this also removes its Deny write rule. The token still has write, so it gains permission to delete and reconfigure databases until it expires. Revoke those tokens before detaching them, or leave their restrictive policy attached.
How this was verified: Local logins receive write, the detached policy supplies their database restriction, and database deletion accepts write when no attached policy denies it.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/apiclient/local_login.go
Line: 175-176
Comment:
**Old tokens gain database access**
`detachOtherPrincipals` removes the policy from tokens that remain valid. For an earlier local login whose credentials were lost or replaced, this also removes its `Deny write` rule. The token still has `write`, so it gains permission to delete and reconfigure databases until it expires. Revoke those tokens before detaching them, or leave their restrictive policy attached.
**How this was verified:** Local logins receive `write`, the detached policy supplies their database restriction, and database deletion accepts `write` when no attached policy denies it.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if creds == (apiclient.Credentials{}) || strings.TrimRight(creds.APIURL, "/") == base { | ||
| return creds.TokenID, nil |
There was a problem hiding this comment.
Port changes block login renewal
After a successful vm login, changing the dashboard port with ports set—or letting vm start replace an occupied port—leaves this-mac pointing at the old port. previousLocalLogin treats the new URL as a different server, so every later vm login refuses to refresh the saved connection. Allow a port change after checking the saved instance identity, and retain the previous token ID so it can still be revoked.
Prompt To Fix With AI
This is a comment left during a code review.
Path: cmd/levelrail-cli/vm_login.go
Line: 110-111
Comment:
**Port changes block login renewal**
After a successful `vm login`, changing the dashboard port with `ports set`—or letting `vm start` replace an occupied port—leaves `this-mac` pointing at the old port. `previousLocalLogin` treats the new URL as a different server, so every later `vm login` refuses to refresh the saved connection. Allow a port change after checking the saved instance identity, and retain the previous token ID so it can still be revoked.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| func WritePortRequest(dataDir string, r PortRequest) error { | ||
| _ = os.Remove(filepath.Join(dataDir, portResultName)) | ||
| return writeJSON(filepath.Join(dataDir, portRequestName), r) |
There was a problem hiding this comment.
Port changes overwrite each other
Developer-mode port changes share one request file and one result file without a lock. If two terminals run ports set together, the second request can replace the first before the supervisor reads it. A later request also deletes the previous result. One caller can lose its answer, and a stale full port set can undo the other caller's change. Serialize the complete read, restart, and reply cycle per data directory.
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/localmode/ports.go
Line: 327-329
Comment:
**Port changes overwrite each other**
Developer-mode port changes share one request file and one result file without a lock. If two terminals run `ports set` together, the second request can replace the first before the supervisor reads it. A later request also deletes the previous result. One caller can lose its answer, and a stale full port set can undo the other caller's change. Serialize the complete read, restart, and reply cycle per data directory.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const saved = await putServerUiMode(mode).then( | ||
| () => true, | ||
| () => false, | ||
| ) | ||
| if (saved) | ||
| queryClient.setQueryData(serverUiModeKey, { available: true, mode }) |
There was a problem hiding this comment.
apply shows the applied mode before its server write finishes, so the user can click Undo while that write is pending. undo sends a separate delete without waiting for or canceling the earlier write. If the write finishes last, apply puts the mode back into the query cache and useUiMode restores it locally. Order these writes, or ignore an apply result after Undo has replaced that choice.
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/hooks/useAutoMode.ts
Line: 43-48
Comment:
**Undo loses to pending save**
`apply` shows the applied mode before its server write finishes, so the user can click Undo while that write is pending. `undo` sends a separate delete without waiting for or canceling the earlier write. If the write finishes last, `apply` puts the mode back into the query cache and `useUiMode` restores it locally. Order these writes, or ignore an apply result after Undo has replaced that choice.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
What
Command line and server support for running Levelrail in a local macOS VM and driving it from a desktop app.
Please review
Four new entries in
test/execgate/allowlist.txtfor files that importos/exec: two run/usr/sbin/lsofwith fixed flags and a port, one only looks uplimactl, one only stops the child that local mode already starts.Checked
Local pre-commit and pre-push hooks passed. Before the last merge of main,
go test -shortpassed on the changed Go packages (internal/apifiltered to the changed test files).Confidence Score: 1/5

The PR is not ready to merge because old local tokens can gain database access, login renewal breaks after port changes, and concurrent port changes can overwrite each other.
Findings
Fix with agent prompt
Summary
Adds CLI and server support for a desktop-managed local VM.
Reviews (2) · Last reviewed commit: "fix: use the client command name in the ..." · Reviewed by Greptile