Repository navigation
Conversation
There was a problem hiding this comment.
Request changes (1 P1)
Scope: base main at merge-base d4dd9255, 1 commit, 2 files reviewed (computer_permission.go, computer_permission_test.go). Loaded the review guidance from coderbook (§2, §3, §5), ponytail-review (§1–3) and karpathy-guidelines (§2–3). Ran in a separate session.
Findings
P1
apps/computer/local-daemon/internal/linger/localtools/computer_permission.go:377: the restart trigger stays true, so a polled card still restarts CuaDriver every 30 s.
cuaRestartDue treats two signals as a "stale grant": "Linger reports Screen Recording granted" and "this process prompted". Neither is a one-time event. Both can stay true for as long as the daemon runs:
- Linger granted does not mean CuaDriver was granted. CuaDriver is a separate TCC subject. It is its own signed app, started with
open -a CuaDriver.app(cua_service.go:70-76).cua.go:112says "The signed application owns TCC permissions", andapps/desktop/AGENTS.md:424-426describes the bridge as reporting "the app's own Screen Recording and Accessibility, which shell commands of Agents are attributed to". So "Linger granted, CuaDriver denied" is also the normal state when the owner granted Linger and never granted CuaDriver. That is the exact state in which acomputer_use/screen_recordingpermission card is pending. A restart cannot clear that state. cuaPrompted[PermissionScreenRecording]is never cleared. It is set atcomputer_permission.go:341and nothing resets it. If the owner dismisses or denies the prompt once, every later denied status read qualifies again after each interval.
The card polls while it is pending (decision-computer-permission-view.tsx:163-166, refetchInterval: pendingPollMs). In either case, stopCuaService therefore SIGTERMs the shared service (cua_service.go:114-117) every 30 s. Each restart kills any in-flight CUA call of another Run, and errDriverStopped reports that call as "may or may not have taken effect". That is the path into the uncleanOperations lockout the PR sets out to remove. The rate drops from one restart per poll to one per 30 s, but the storm is not removed. This contradicts the PR description's "A plain denied reading … no longer touches the shared service" for the Desktop case, which is the main case.
The new tests do not cover this case. TestComputerPermissionsThrottlesCuaRestart asserts a second restart after the interval, which encodes the periodic restart as intended behavior.
Fix: make the restart one-shot per trigger instead of time-based. For example:
- consume the prompt flag on restart, using a separate "restart pending" flag so
cuaGroup's denied/not-determined distinction is kept; - restart on a Linger-granted reading only when that grant is newly observed (it moved from not granted to granted since the last read), not on every read where it holds.
Then drop cuaRestartedAt, now and cuaRestartInterval. Add a test that polls N times with Linger granted and CuaDriver denied and asserts exactly one restart in total.
Verified as fine
- The restart decision and
cuaRestartedAtare only touched underp.mu(computer_permission.go:182-183), so there is no data race.go test -race -count=1 ./internal/linger/localtools -run ComputerPermissionspassed locally. - The explicit
relaunchaction still restarts CuaDriver unconditionally (computer_permission.go:306-313). - A granted reading never restarts (
computer_permission.go:363). - A standalone daemon with no bridge (
lingerAnswered=false) and no prompt never restarts (computer_permission.go:384-386). - The prompt path still returns its own reading without a status read, so it does not restart CuaDriver during the grant flow (
computer_permission.go:343-345). - Embedded hosts are unaffected:
RestartCuais a no-op whenCuaEmbeddedis set (cua_service.go:250-254). - No CJK in added lines or in the commit message. The commit follows the conventional-commit format.
Process notes
- The branch is up to date with
main(0 commits behind). It has a single commit and no merge or fixup commits.
CI
check (web)andchangespassed.check (computer-go),check (desktop)andrepository-gatewere still pending at review time.- CI runs the daemon's Go tests without
-race. I ran the touchedComputerPermissionstests locally with-race -count=1: pass.
Automated review by Claude Code
Automated review of 3404c34 by Claude Code.
|
Requesting changes: a 30s throttle only slows the restart storm rather than stopping it. Both triggers are sticky states—Linger Desktop and CuaDriver are separate TCC subjects (so Linger granted + CuaDriver denied is normal while a card is pending), and cuaPrompted is never cleared—so polling still SIGTERMs CuaDriver every 30s and kills active CUA calls. Please make the restart one-shot per state transition (e.g. consume a separate restart-pending flag after a prompt, or only trigger when Linger moves from not-granted to granted) and drop the 30s interval/clock injection. |
3404c34 to
dd60a33
Compare
|
Thanks — the P1 is right, and the interval version still left a periodic restart in the normal "Linger granted, CuaDriver never granted" state. Reworked in
Tests now encode one-shot behavior:
The full |
There was a problem hiding this comment.
Request changes (1 P1)
Scope: follow-up on 3404c34, now at dd60a33; base main, merge base d4dd9255, 1 commit, 2 files. Helper skills were not loaded; the review followed the linger-pr-review checklist directly and ran in a separate session.
Previous findings
- Resolved: Restart condition is always true, so a polled card still kills in-flight calls every poll.
cuaRestartDue(computer_permission.go:378) now uses each trigger once.TestComputerPermissionsRestartsCuaOncePerGrantedReadingshows 5 polls → 1 restart.
Findings
P1
apps/computer/local-daemon/internal/linger/localtools/computer_permission.go:360: the one-shot restart is used up before the owner grants, so CuaDriver never sees a grant made later.- The poll fires right after the prompt. The card polls status every 2 s while it is pending (
apps/web/src/features/local-computer/computer-permissions-api.ts:16,45). Afterprompt computer_use screen_recordingsetscuaRestartPending, the next status read (≤2 s later) still reads denied, clears the flag and restarts CuaDriver. Your ownTestComputerPermissionsRestartsCuaAfterAPromptOnceshows the restart happening on that first still-denied read. - The owner grants later. Granting Screen Recording takes the owner well over 2 s: the
cua-driver permissions grantflow waits up tocuaGrantLimit = 10m(cua_service.go:205). The service started by the next read caches the denial again. Per the comment atcomputer_permission.go:362, the preflight is cached for the life of the process. - Once granted, nothing restarts it. After the owner grants, no trigger is left. The flag is gone, and the Linger transition does not apply: CuaDriver runs under its own TCC identity, launched via
open -n -a CuaDriver.app(cua_service.go:70-77), so Linger's grant says nothing about it. The same happens when the owner uses the card'sopen_settingsstep forcomputer_use(desktop-computer.ts:93-96): that path never sets the flag. - The card has no way out. It offers
relaunchonly forlinger(desktop-computer.ts:97,decision-computer-permission-view.tsx:91), so thecomputer_usescreen_recording entry stays denied and the card waits indefinitely. Before this PR, the per-read restart eventually picked up the grant. So this replaces the restart storm with a recovery path that can't succeed. - Fix: restart on a signal that comes after the grant. For example, restart once when the background
permissions grantprocess started byRequestCuaPermissionsexits (cua_service.go:228-235already waits for it), or keep the flag armed until a reading comes back granted while limiting how often it restarts. Add a test where the grant arrives after one or more denied polls.
- The poll fires right after the prompt. The card polls status every 2 s while it is pending (
Verified as fine
- All state is guarded by the lock. Every read and write of
cuaRestartPending/cuaLingerGrantedhappens underp.mu, taken inComputerPermission(computer_permission.go:178).go test -race -run ComputerPermissionspasses. - Explicit relaunch is unchanged. The
relaunchaction still callsRestartCua(computer_permission.go:302-308). - Embedded hosts are untouched.
RestartCuais a no-op there (cua_service.go:250-253). - Fixture still exercises the restart path.
TestComputerPermissionsRestartCuaAfterMissingScreenRecordingwas updated to set the Linger grant, so its restart assertion still holds.
Unverified
- That CuaDriver caches the Screen Recording preflight for the life of the process. This rests on the code comment, not on the external binary.
Process notes
- Single commit, no merge or fixup commits. The author is linked.
CI
- All relevant checks pass: computer-go, computer-go-windows, desktop, web, repository-gate.
- Ran locally:
go test -race -count=1 ./internal/linger/localtools -run ComputerPermissionspassed (CI's computer-go job runs without-race).
Automated review by Claude Code
Automated review of dd60a33 by Claude Code.
dd60a33 to
06d656f
Compare
|
Reworked the trigger in
The |
There was a problem hiding this comment.
Approve with nits (1 P3)
Scope: follow-up on dd60a33. Base main, merge-base d4dd9255, 1 commit (squashed since the previous review), 3 files. Loaded coderbook, ponytail-review and karpathy-guidelines. Ran in a separate session.
Previous findings
- Resolved: One-shot restart consumed before the owner grants.
cuaRestartDuenow keepscuaRestartPendingarmed whileManager.CuaGrantRunning()reports that thecua-driver permissions grantprocess is still alive (computer_permission.go:406,cua_service.go:243). It restarts once, on the first denied read after the process exits.TestComputerPermissionsWaitsForTheGrantFlowcovers this: no restart during the flow, one after it, none on later polls.
Findings
P3
apps/computer/local-daemon/internal/linger/localtools/computer_permission.go:118:cuaGrantFlowis an optional interface with one implementation,*Manager. That is also the only productionCuaPermissionChecker, wired atcmd/linger-computer-daemon/main.go:315. The code finds the method through a type assertion. A checker without the method therefore falls back silently to restarting on the first denied read after a prompt, which is the behavior the previous review flagged. Simpler: addCuaGrantRunning() booltoCuaPermissionCheckerand drop the assertion. The compiler then requires it on every implementation and fake.
Verified as fine
- Production passes the real
*Managerasoptions.Cua(main.go:315), so the assertion succeeds today and the wait applies. cuaGrantis cleared undercuaGrantMu, and only aftercommand.Wait()returns (cua_service.go:229-236). The 10-minute kill (cua_service.go:227) makes sure the flow exits eventually, so a pending restart can't be held forever.- All
ComputerPermissionsstate (cuaRestartPending,cuaLingerGranted) changes underp.mu(computer_permission.go:186).CuaGrantRunningtakes onlycuaGrantMu, so the two locks can't be taken in opposite orders. - In the
newGrantbranch, clearingcuaRestartPendingmatches the old behavior:cuaStatusalready cleared it after any restart. - Unverified: whether the external
cua-driver permissions grantbinary exits once the owner has granted, or only when the 10-minute limit kills it. If it only exits at the limit, the restart can be delayed by up to 10 minutes. Therelaunchaction still covers that case.
Process notes
mainhas moved past the merge base (d4dd9255vs6a511c15), so the branch needs a rebase before it can merge.- The commit was squashed into one, but its subject and body (
restart CuaDriver after the CUA grant flow exits; "A CUA status poll restarted CuaDriver once per prompt...") describe only the follow-up change. They compare against an in-between state that never existed onmain. The commit lands onmainas it is, so reword it to cover the whole change: status polls no longer restart CuaDriver, and each stale-grant trigger restarts it once, after the grant flow exits.
CI
web, changes and repository-gate passed. computer-go, computer-go-windows and desktop were still pending at review time. Ran locally: go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions, which passed. CI's computer-go runs without -race.
Automated review by Claude Code
Automated review of 06d656f by Claude Code.
06d656f to
be631ea
Compare
|
Took the P3 in
|
There was a problem hiding this comment.
Approve with nits (1 P2)
Scope: base main, merge base 6a511c15, 1 commit, 3 files. This is a follow-up on 06d656f. The PR was rebased since then, so I compared the two versions with git range-diff. Loaded coderbook, ponytail-review and karpathy-guidelines; ran in a separate session.
Previous findings
- Resolved: optional single-implementation interface via type assertion.
CuaGrantRunningis now part ofCuaPermissionChecker(computer_permission.go:116), andcuaRestartDuecalls it directly (computer_permission.go:403).
Findings
P2
apps/computer/local-daemon/internal/linger/localtools/computer_permission.go:391: there is a gap where a CuaDriver grant made through System Settings is never picked up.- What changed: before this PR, every denied status read restarted CuaDriver. Now a restart happens only when the Desktop app's Screen Recording grant flips to granted, or when a pending prompt's grant flow has exited.
- Scenario: the owner clicks Request on the card. They don't finish within
cuaGrantLimit(10 minutes,cua_service.go:205), so the flow is killed andcuaGrantbecomes nil (cua_service.go:229-236). The next poll consumescuaRestartPendingand restarts CuaDriver while it is still denied. The card now readsdenied, becausecuaPromptedis set, sonextActionoffers Open Settings (decision-computer-permission-view.tsx:101). The owner turns on CuaDriver's Screen Recording in System Settings. No trigger is left:cuaAction'sopen_settingsbranch does not arm one (computer_permission.go:347), and the Desktop app's grant did not change. CuaDriver keeps its cached denial for the life of the process, so the card never reaches granted until the Desktop app or Daemon restarts. - PR body claim: it says "the owner can still use the relaunch action". The daemon does support
relaunchforcomputer_use, but the card offers relaunch only forsubject === "linger"(decision-computer-permission-view.tsx:91,:113). So the owner has no way to reach it from the UI. - Fix: show a CuaDriver relaunch step on the card when CUA Screen Recording reads denied after a prompt. Alternatively, arm
cuaRestartPendingonopen_settingsforcomputer_use/screen_recordingand consume it only once the owner returns, for example on the next read after the grant flow is idle. - Tests: add a test for this path either way.
Verified as fine
- The new fields
cuaRestartPendingandcuaLingerGrantedare only touched underp.mu, whichComputerPermissionholds for the whole action (computer_permission.go:182-183).CuaGrantRunningtakescuaGrantMu(cua_service.go:243-247), the same mutex the Wait goroutine uses to clearcuaGrant. - Embedded hosts are unaffected.
RequestCuaPermissionsreturnsErrCuaUnavailablewhenCuaEmbeddedis set, so the prompt falls back to settings without arming a restart (cua_service.go:213,computer_permission.go:333-335).RestartCuais a no-op there (cua_service.go:260). - A granted reading clears the pending flag (
computer_permission.go:373-375). The explicitrelaunchaction still restarts unconditionally (computer_permission.go:306-313). Manageris the only production implementation ofCuaPermissionChecker, wired atcmd/linger-computer-daemon/main.go:472. Adding the method to the interface breaks no other caller.- The tests cover every trigger named in the PR body, including waiting for the grant flow (
TestComputerPermissionsWaitsForTheGrantFlow).
Process notes
- None. The branch contains
origin/main, and its single commit's author is linked (Lumea-art).
CI
- Passed: computer-go, computer-go-windows, desktop, web, repository-gate, changes. The rest were skipped by path. CI runs the Go tests without
-race. - Ran locally:
go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions, which passed.
Automated review by Claude Code
Automated review of be631ea by Claude Code.
7782483 to
418d51e
Compare
|
Added the missing recovery path in
So the prompt path waits for the grant flow, and the Settings path now has an explicit relaunch after the owner returns; neither needs polling restarts. |
There was a problem hiding this comment.
Approve with nits (2 P3)
Scope: follow-up on be631ea. Base main, merge base 6a511c15, 1 commit (418d51e), 12 files reviewed. Loaded coderbook / ponytail-review / karpathy-guidelines guidance from the review skill; ran in a separate session.
Previous findings
- Resolved: the grant made in System Settings after the grant flow times out is never seen.
cuaRestartDuenow keepscuaRestartPendingarmed untilCuaGrantRunning()reports that the flow has exited (computer_permission.go:381-406,cua_service.go:243-247). The flow's 10-minute kill also clearscuaGrant(cua_service.go:227-235). The card now offers "Relaunch CuaDriver" once the owner has opened the Screen Recording pane (decision-computer-permission-view.tsx:97-109), and that maps tocuaAction→RestartCua(computer_permission.go:307-313). Covered byTestComputerPermissionsWaitsForTheGrantFlowand the new web test.
Findings
P3
apps/web/src/features/rooms/cards/decision-computer-permission-view.tsx:97:settingsOpenedonly ever becomes true, andonMutatesets it even when theopen_settingscall then fails. After that, a denied Screen Recording row only offers "Relaunch CuaDriver", including after the relaunch itself. If the owner closed the pane without granting, or the open failed, the card has no way back to "Open Settings" until the component remounts (page reload). Fix: set the flag inonSuccess, or show the relaunch next to Open Settings instead of replacing it.- PR description is out of date with the head commit. It does not mention four things: the pending restart now waits for CuaDriver's grant flow to exit (
CuaGrantRunning), the new "Relaunch CuaDriver" card step, theComputerPermissionActioncontract description change, andTestComputerPermissionsWaitsForTheGrantFlow. The commit message describes these; please copy that into the body.
Verified as fine
- Restart state (
cuaRestartPending,cuaLingerGranted) changes only whilep.muis held (computer_permission.go:182-183).CuaGrantRunningreadscuaGrantundercuaGrantMu(cua_service.go:243-247), and the backgroundWaitgoroutine clears it under the same lock. - Each trigger restarts at most once. A Desktop-app grant transition clears the pending flag, and a granted CUA reading also clears it (
computer_permission.go:365-377). The standalone daemon (lingerAnswered=false) restarts only after a prompt it issued. - A local desktop
relaunchforcomputer_usefalls through to the TeamHub API, becausedesktopStepreturns undefined for it (decision-computer-permission-view.tsx:124-128). The request therefore reaches the daemon'sRestartCua. - Generated contracts match the YAML description change in both Go and TS consumers.
- No CJK outside the locale catalog; the commit message is English.
Process notes
- None.
CI
changespassed. All other checks (computer-go, contracts, web tests, repository-gate, …) were still pending at review time. I rango test -race -count=1 ./internal/linger/localtools -run ComputerPermissionsmyself; it passed. CI's computer-go job does not use-race.
Automated review by Claude Code
Automated review of 418d51e by Claude Code.
A permission status poll restarted CuaDriver on every denied read, so a card polled while the owner was granting kept killing another Run's in-flight Cua calls. Restart only once per stale-grant trigger: the Desktop app's Screen Recording grant appearing, or a prompt followed by the exit of CuaDriver's background grant flow, so the grant the owner made later is seen. The permission card now offers Open Settings first and a CuaDriver relaunch after it, so a grant made in System Settings is picked up too.
418d51e to
170b120
Compare
|
Both P3s in
|
There was a problem hiding this comment.
Approve (0 findings). This is a follow-up on 418d51e.
Scope: merge base 6a511c15, 1 commit (170b1207), 12 files reviewed.
- Resolved: the card can reopen Settings.
settingsOpenedis now set only inonSuccessand reset after acomputer_userelaunch (apps/web/src/features/rooms/cards/decision-computer-permission-view.tsx:207-217). The test now checks that Open Settings comes back. - Resolved: the PR description now covers the grant-flow wait, the Relaunch CuaDriver step, the contract text and
TestComputerPermissionsWaitsForTheGrantFlow.
Verified as fine
CuaGrantRunningturns false when the grant flow exits. TheWaitgoroutine clearscuaGrant, and the 10-minute limit kills an abandoned flow (apps/computer/local-daemon/internal/linger/localtools/cua_service.go:226-236). A prompt's pending restart therefore always fires once and can't stay armed forever (computer_permission.go:403).- The new restart state (
cuaRestartPending,cuaLingerGranted) is read and written only underp.mu(computer_permission.go:183). The restart path callsCua.CuaGrantRunning()only after thep.options.Cua == nilearly return. - The only CJK in the diff is in
apps/web/src/i18n/locales/zh-CN.json, which is allowed. The commit has no merge, fixup or CJK problems.
CI: changes passed. The other checks were still pending when I reviewed. I ran go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions locally, and it passed. CI doesn't run that with -race.
Automated review by Claude Code
Automated review of 170b120 by Claude Code.
Restart trigger and card recovery (170b120)
CuaPermissionChecker.CuaGrantRunning()keepscuaRestartPendingarmed whilecua-driver permissions grantis alive, and the first denied read after it exits restarts once. Status polls during the flow no longer consume the trigger.ComputerPermissionAction's contract description now saysrelaunchrestarts the Linger app or the CuaDriver service; contracts regenerated.TestComputerPermissionsWaitsForTheGrantFlowcovers the grant-flow wait, andoffers a CuaDriver relaunch after opening its settings panecovers the card path.What and why
Following #344, a stale Screen Recording grant makes CuaDriver's cached preflight read denied while the system still shows the grant.
cuaStatusrestarted the shared CuaDriver service on every status read (#499), so a permission card polling during a Run kept killing that Run's CUA calls. One call whose outcome could not be proven, plus a close error, then locks the Runtime inuncleanOperationsuntil the app restarts.A restart is now one-shot per stale-grant trigger:
cuaRestartPending), and that flag is consumed by the restart.A plain denied reading, a card polled while pending, or a standalone Daemon without the bridge no longer touches the shared service. The explicit
relaunchaction still restarts CuaDriver.How it was verified
TestComputerPermissionsDoesNotRestartCuaWithoutAStaleGrant: three denied status reads, zero restarts.TestComputerPermissionsRestartsCuaOncePerGrantedReading: five polls after the grant appears give exactly one restart.TestComputerPermissionsRestartsCuaWhenTheGrantAppears: no restart before the grant, one after, none on later polls.TestComputerPermissionsRestartsCuaAfterAPromptOnce: no unprompted restart; a prompt gives one, and three later polls give none.TestComputerPermissionsDoesNotRestartCuaWhenGranted.go test ./internal/linger/localtools -run ComputerPermissions,go test -race,go vet,gofmt.The full
localtoolspackage still has unrelatedui_runtimefailures on this machine (unexpected EOFfrom its fixture); they reproduce on a cleanmain, so this change does not introduce them.Boundary
uncleanOperationslockout after a genuinely unproven cleanup, is not changed here.