Skip to content

fix(computer): stop CUA status polls from restarting CuaDriver - #527

Open
Lumea-art wants to merge 1 commit into
simplexai-labs:mainfrom
Lumea-art:fix/computer-use-cua-restart-debounce
Open

Lumea-art wants to merge 1 commit into
simplexai-labs:mainfrom
Lumea-art:fix/computer-use-cua-restart-debounce

Conversation

@Lumea-art

@Lumea-art Lumea-art commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Restart trigger and card recovery (170b120)

  • The pending restart now waits for CuaDriver's background grant flow: CuaPermissionChecker.CuaGrantRunning() keeps cuaRestartPending armed while cua-driver permissions grant is alive, and the first denied read after it exits restarts once. Status polls during the flow no longer consume the trigger.
  • The permission card offers Open Settings for CuaDriver first; after that step succeeds it offers Relaunch CuaDriver, and a CUA relaunch returns it to Open Settings if the grant still did not apply.
  • ComputerPermissionAction's contract description now says relaunch restarts the Linger app or the CuaDriver service; contracts regenerated.
  • TestComputerPermissionsWaitsForTheGrantFlow covers the grant-flow wait, and offers a CuaDriver relaunch after opening its settings pane covers 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. cuaStatus restarted 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 in uncleanOperations until the app restarts.

A restart is now one-shot per stale-grant trigger:

  • the Desktop app's Screen Recording state is tracked; only the transition from not granted to granted qualifies, or
  • this process asked CuaDriver for Screen Recording (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 relaunch action 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 localtools package still has unrelated ui_runtime failures on this machine (unexpected EOF from its fixture); they reproduce on a clean main, so this change does not introduce them.

Boundary

@linger-review linger-review 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.

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:

  1. 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:112 says "The signed application owns TCC permissions", and apps/desktop/AGENTS.md:424-426 describes 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 a computer_use / screen_recording permission card is pending. A restart cannot clear that state.
  2. cuaPrompted[PermissionScreenRecording] is never cleared. It is set at computer_permission.go:341 and 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 cuaRestartedAt are only touched under p.mu (computer_permission.go:182-183), so there is no data race. go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions passed locally.
  • The explicit relaunch action 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: RestartCua is a no-op when CuaEmbedded is 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) and changes passed. check (computer-go), check (desktop) and repository-gate were still pending at review time.
  • CI runs the daemon's Go tests without -race. I ran the touched ComputerPermissions tests locally with -race -count=1: pass.

Automated review by Claude Code


Automated review of 3404c34 by Claude Code.

@DolphinMiner

Copy link
Copy Markdown
Contributor

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.

@Lumea-art
Lumea-art force-pushed the fix/computer-use-cua-restart-debounce branch from 3404c34 to dd60a33 Compare November 26, 2026 15:05
@Lumea-art

Copy link
Copy Markdown
Contributor Author

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 dd60a332:

  • cuaRestartPending is set only by a Screen Recording prompt and is consumed by the restart. It is separate from cuaPrompted, so the denied/not-determined wording in cuaGroup is unchanged.
  • cuaLingerGranted stores the last bridge reading; only a not-granted → granted transition qualifies.
  • Removed cuaRestartedAt, now and cuaRestartInterval. No time-based restart path remains.

Tests now encode one-shot behavior:

  • TestComputerPermissionsRestartsCuaOncePerGrantedReading: five polls with the bridge granted and CuaDriver denied → exactly one restart.
  • TestComputerPermissionsRestartsCuaWhenTheGrantAppears: 0 before, 1 when it appears, 0 on later polls.
  • TestComputerPermissionsRestartsCuaAfterAPromptOnce: 0 unprompted, 1 after the prompt, 0 on three later polls.
  • go test -race ./internal/linger/localtools -run ComputerPermissions passes.

The full localtools package still has the unrelated ui_runtime failures on this machine; they reproduce on a clean main.

@linger-review linger-review 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.

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. TestComputerPermissionsRestartsCuaOncePerGrantedReading shows 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). After prompt computer_use screen_recording sets cuaRestartPending, the next status read (≤2 s later) still reads denied, clears the flag and restarts CuaDriver. Your own TestComputerPermissionsRestartsCuaAfterAPromptOnce shows 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 grant flow waits up to cuaGrantLimit = 10m (cua_service.go:205). The service started by the next read caches the denial again. Per the comment at computer_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's open_settings step for computer_use (desktop-computer.ts:93-96): that path never sets the flag.
    • The card has no way out. It offers relaunch only for linger (desktop-computer.ts:97, decision-computer-permission-view.tsx:91), so the computer_use screen_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 grant process started by RequestCuaPermissions exits (cua_service.go:228-235 already 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.

Verified as fine

  • All state is guarded by the lock. Every read and write of cuaRestartPending / cuaLingerGranted happens under p.mu, taken in ComputerPermission (computer_permission.go:178). go test -race -run ComputerPermissions passes.
  • Explicit relaunch is unchanged. The relaunch action still calls RestartCua (computer_permission.go:302-308).
  • Embedded hosts are untouched. RestartCua is a no-op there (cua_service.go:250-253).
  • Fixture still exercises the restart path. TestComputerPermissionsRestartCuaAfterMissingScreenRecording was 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 ComputerPermissions passed (CI's computer-go job runs without -race).

Automated review by Claude Code


Automated review of dd60a33 by Claude Code.

@Lumea-art
Lumea-art force-pushed the fix/computer-use-cua-restart-debounce branch from dd60a33 to 06d656f Compare November 27, 2026 00:07
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Reworked the trigger in 06d656f0 so it fires after the owner's grant, not on the first poll:

  • Manager now exposes CuaGrantRunning(), which reports whether the background cua-driver permissions grant process is still running.
  • cuaRestartPending stays armed while that flow runs; the next denied status read after it exits restarts CuaDriver once. A status poll during the flow no longer consumes the trigger.
  • Added TestComputerPermissionsWaitsForTheGrantFlow: prompt with the flow running → three denied polls restart nothing; flow exits → one restart; three more polls do not restart again. Existing prompt/one-shot tests still pass.
  • go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions passes.

The open_settings entry for computer_use still has no grant process to observe, so it behaves as before; the prompt path is the one the card's first step takes. If you want that path covered too, I can add an explicit CuaDriver relaunch step or a bounded retry window after open_settings, but I did not want to reintroduce polling restarts without a grant signal.

@linger-review linger-review 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.

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. cuaRestartDue now keeps cuaRestartPending armed while Manager.CuaGrantRunning() reports that the cua-driver permissions grant process is still alive (computer_permission.go:406, cua_service.go:243). It restarts once, on the first denied read after the process exits. TestComputerPermissionsWaitsForTheGrantFlow covers 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: cuaGrantFlow is an optional interface with one implementation, *Manager. That is also the only production CuaPermissionChecker, wired at cmd/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: add CuaGrantRunning() bool to CuaPermissionChecker and drop the assertion. The compiler then requires it on every implementation and fake.

Verified as fine

  • Production passes the real *Manager as options.Cua (main.go:315), so the assertion succeeds today and the wait applies.
  • cuaGrant is cleared under cuaGrantMu, and only after command.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 ComputerPermissions state (cuaRestartPending, cuaLingerGranted) changes under p.mu (computer_permission.go:186). CuaGrantRunning takes only cuaGrantMu, so the two locks can't be taken in opposite orders.
  • In the newGrant branch, clearing cuaRestartPending matches the old behavior: cuaStatus already cleared it after any restart.
  • Unverified: whether the external cua-driver permissions grant binary 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. The relaunch action still covers that case.

Process notes

  • main has moved past the merge base (d4dd9255 vs 6a511c15), 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 on main. The commit lands on main as 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.

@Lumea-art
Lumea-art force-pushed the fix/computer-use-cua-restart-debounce branch from 06d656f to be631ea Compare November 27, 2026 00:11
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Took the P3 in be631ea1:

  • CuaGrantRunning() bool is now part of CuaPermissionChecker, so every implementation and fake must provide it; removed the optional interface and type assertion.
  • Reworded the commit to describe the whole change on main (status polls no longer restart CuaDriver; each stale-grant trigger restarts once, after the grant flow exits).
  • Rebased onto 6a511c15. go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions passes.

@linger-review linger-review 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.

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. CuaGrantRunning is now part of CuaPermissionChecker (computer_permission.go:116), and cuaRestartDue calls 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 and cuaGrant becomes nil (cua_service.go:229-236). The next poll consumes cuaRestartPending and restarts CuaDriver while it is still denied. The card now reads denied, because cuaPrompted is set, so nextAction offers Open Settings (decision-computer-permission-view.tsx:101). The owner turns on CuaDriver's Screen Recording in System Settings. No trigger is left: cuaAction's open_settings branch 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 relaunch for computer_use, but the card offers relaunch only for subject === "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 cuaRestartPending on open_settings for computer_use/screen_recording and 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 cuaRestartPending and cuaLingerGranted are only touched under p.mu, which ComputerPermission holds for the whole action (computer_permission.go:182-183). CuaGrantRunning takes cuaGrantMu (cua_service.go:243-247), the same mutex the Wait goroutine uses to clear cuaGrant.
  • Embedded hosts are unaffected. RequestCuaPermissions returns ErrCuaUnavailable when CuaEmbedded is set, so the prompt falls back to settings without arming a restart (cua_service.go:213, computer_permission.go:333-335). RestartCua is a no-op there (cua_service.go:260).
  • A granted reading clears the pending flag (computer_permission.go:373-375). The explicit relaunch action still restarts unconditionally (computer_permission.go:306-313).
  • Manager is the only production implementation of CuaPermissionChecker, wired at cmd/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.

@Lumea-art
Lumea-art force-pushed the fix/computer-use-cua-restart-debounce branch 2 times, most recently from 7782483 to 418d51e Compare November 27, 2026 00:20
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Added the missing recovery path in 418d51e3:

  • The permission card now offers Open Settings for CuaDriver's Screen Recording first. After that step, the same row offers Relaunch CuaDriver instead of reopening the same pane.
  • The daemon already supports relaunch for computer_use; the web was the missing part (nextAction only offered relaunch for linger). DesktopPermissionStep still routes CUA relaunch through TeamHub to the daemon, not the desktop app.
  • Added offers a CuaDriver relaunch after opening its settings pane: denied CUA Screen Recording → Open Settings sends open_settings/computer_use/screen_recording, then Relaunch CuaDriver sends relaunch/computer_use; the card test file is 14/14.
  • Updated the contract description (relaunch restarts the Linger app or CuaDriver service) and added Relaunch CuaDriver to the zh-CN locale. Contracts regenerated and contracts:verify passes.

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.

@linger-review linger-review 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.

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. cuaRestartDue now keeps cuaRestartPending armed until CuaGrantRunning() reports that the flow has exited (computer_permission.go:381-406, cua_service.go:243-247). The flow's 10-minute kill also clears cuaGrant (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 to cuaAction → RestartCua (computer_permission.go:307-313). Covered by TestComputerPermissionsWaitsForTheGrantFlow and the new web test.

Findings

P3

  • apps/web/src/features/rooms/cards/decision-computer-permission-view.tsx:97: settingsOpened only ever becomes true, and onMutate sets it even when the open_settings call 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 in onSuccess, 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, the ComputerPermissionAction contract description change, and TestComputerPermissionsWaitsForTheGrantFlow. The commit message describes these; please copy that into the body.

Verified as fine

  • Restart state (cuaRestartPending, cuaLingerGranted) changes only while p.mu is held (computer_permission.go:182-183). CuaGrantRunning reads cuaGrant under cuaGrantMu (cua_service.go:243-247), and the background Wait goroutine 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 relaunch for computer_use falls through to the TeamHub API, because desktopStep returns undefined for it (decision-computer-permission-view.tsx:124-128). The request therefore reaches the daemon's RestartCua.
  • 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

  • changes passed. All other checks (computer-go, contracts, web tests, repository-gate, …) were still pending at review time. I ran go test -race -count=1 ./internal/linger/localtools -run ComputerPermissions myself; 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.
@Lumea-art
Lumea-art force-pushed the fix/computer-use-cua-restart-debounce branch from 418d51e to 170b120 Compare November 27, 2026 00:24
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Both P3s in 170b1207:

  • settingsOpened now flips in onSuccess for the CUA open_settings action, not in onMutate, so a failed open keeps the Open Settings button. A CUA relaunch success resets it, so if the relaunch did not pick up a grant the row goes back to Open Settings instead of only offering relaunch. The card test now asserts that return.
  • Updated the PR body with the grant-flow wait, the Relaunch CuaDriver step, the contract description change, and TestComputerPermissionsWaitsForTheGrantFlow.

decision-computer-permission-view.test.tsx 14/14, web typecheck and prettier clean.

@linger-review linger-review 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.

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. settingsOpened is now set only in onSuccess and reset after a computer_use relaunch (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

  • CuaGrantRunning turns false when the grant flow exits. The Wait goroutine clears cuaGrant, 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 under p.mu (computer_permission.go:183). The restart path calls Cua.CuaGrantRunning() only after the p.options.Cua == nil early 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.

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.

2 participants