Repository navigation
Conversation
There was a problem hiding this comment.
Approve with nits (5 P2, 1 P3)
Scope: base main, merge base 53f7d21a; 1 commit, 5 files reviewed (linux.go, linux_native.go, local_linux.py and both new test files). Loaded ponytail-review. coderbook and karpathy-guidelines were not loaded, so their review criteria were applied from the review instructions only. Ran in a separate session.
The fix works. Go now refuses type_text/press_key when active-window is empty, both before the first step and between steps, and Python's active_window() returns "" while GNOME's Overview is open. The findings below are about the size of the change: a second error envelope, a second guard in the driver, and a fallback that can never run.
Findings
P2
-
finishDesktop's new branch andnotSentErrorcopytoolError(linux.go:300,linux.go:427-444)server.go:208toolErroralready turns any error that wrapserrNotSentinto{"isError": true, ..., "structuredContent": {"outcome": "not_dispatched"}}. The rest of the package marks refusals the same way:fmt.Errorf("COMPUTER_...: %w", errNotSent)(for examplecua.go:1546).- The new branch builds that envelope again with its own outcome mapping. It also changes every existing
err != nil && state == nilpath, such asWINDOW_CHANGEDwhenreadWindowStatereturns nil (linux_elements.go:77), from a Go error into this second format. - Fix: define
errNoActiveWindowasfmt.Errorf("NO_ACTIVE_WINDOW: ...: %w", errNotSent)and return it as a Go error. Then deletenotSentErrorand the new branch infinishDesktop(about 25 lines). The{"completed": false, "completed_steps": 0}report adds nothing beyond the error text.
-
The driver repeats the guard, and Go matches its error text (
local_linux.py:768,local_linux.py:795-800,linux.go:326)- Go's
checkWindowand the between-step check already call the driver'sactive-window, which runs the sameactive_window()with the Overview check.native_actionthen runs it again before everytype/key. That is a second D-Bus call plusxdotoolper keystroke, and a second copy of the allowed-key list:OVERVIEW_ESCAPE_KEYSvsallowKeyWithoutActiveWindow. - When the driver refuses, it replies with
status: "unsupported"and only prose.linuxActiontherefore returns a plain error, noterrNotSent, so the Agent sees outcomefailed("may have taken effect") for input that was never sent. Go then has to recognise the case withstrings.Contains(err.Error(), "NO_ACTIVE_WINDOW:"). That keys behavior on human-readable text, which the repo rules forbid. - The settle also exists twice: 150 ms in Python and 200 ms in Go, so a batch waits 350 ms after Escape/Super.
- Fix: drop the driver guard and the Python sleep. Keep one settle in Go, sized to the 100-300 ms delay the PR body describes. If a driver-side refusal must stay, give it a structured receipt status that
linuxActionmaps toerrNotSent, and deleteisNoActiveWindowError. - Not P1: both copies must pass, so if they drift the result is an extra refusal, never leaked input.
- Go's
-
The
gdbusfallback can never run in production (local_linux.py:120-155)- It runs only when
Giois not importable. In that casemissingis set (local_linux.py:547-550) andprobefails with "AT-SPI is unavailable" (local_linux.py:725). The driver never starts, so no action can reachgnome_overview_active. - The
globals().get("Gio")indirection exists only for the tests. - Fix: call
Gio/GLibdirectly, asscreen_locked()does (local_linux.py:41-48). Delete thegdbusbranch and its test (about 20 + 25 lines).
- It runs only when
-
The new Python tests never run (
local_linux_guard_test.py)- No CI job or make target picks them up. The only Python unittest target is
Makefile:139(apps/desktop/packaging). - To support these tests, the production script also gained
if __name__ == "__main__"gates andprotocol = sys.stdout. These are harmless because the daemon runs the script with-c(linux_native.go:42), but they only pay off if the tests run. - Fix: add
python3 -m unittestfor this directory tomake check-computer, or drop the file.
- No CI job or make target picks them up. The only Python unittest target is
-
The README does not document the new refusal (
apps/computer/local-daemon/README.md:1075-1092)- The README documents
WINDOW_CHANGEDandSCREEN_LOCKEDbut notNO_ACTIVE_WINDOW: which inputs are refused with no active window or with Overview open, which bare keys are allowed, and the Overview settle. - This is Agent-visible failure behavior, so it belongs in the same PR.
- The README documents
P3
- Sleep-based race test (
linux_guard_test.go:719-735)TestLinuxF2RunActionsSuperWaitsOverviewSettleBeforeTyperelies on a 20 ms goroutine sleep finishing within a 50 ms settle. Under load the goroutine can be scheduled late, and the test fails without any code change.- Fix: flip the fake's active window from a hook on the settle sleep, or wait on a channel, instead of racing wall-clock time.
Verified as fine
- The between-step check runs before the window-changed check, so
[Super, type_text]stops withNO_ACTIVE_WINDOWand not a generic stop (linux.go:250beforelinux.go:254). - A failed
active-windowread between steps now stops the batch instead of comparing againstnil(linux.go:241-245). - A bare Escape/Super with an empty active window skips
WINDOW_CHANGED, while a different non-empty window is still refused (linux.go:364-370). ANO_ACTIVE_WINDOWrefusal skips observation, soop.linuxWindowis kept (linux.go:266-268;finishDesktoponly overwrites it from a non-nilstate). - The refusal releases the input journal as confirmed, so it does not block later input:
finishDesktoppassesconfirmed = !errors.Is(err, errOutcomeUnknown)tolease.Finish. - The Go and Python key lists match after normalization:
super/win/metamap toSuper_Landescmaps toEscape(local_linux.py:561-565), and Go lowercases before comparing (linux.go:318). - The
__main__gates do not change production startup: the script runs viapython3 -u -c(linux_native.go:42), where__name__ == "__main__". linuxHostis a pure test seam with the same production value (linux_native.go:22).- No CJK in the added lines or the commit message, and no merge commits.
- Unverified: the real GNOME timing for
_NET_ACTIVE_WINDOWandOverviewActive. I relied on the PR's QA numbers, because the fakes cannot show it.
Process notes
- The branch is 10 commits behind
main, andmainrequires up-to-date branches, so it needs a rebase. - Commit
a9db0ed4is authored asyunhe <>with an empty email, so it is not linked to a GitHub account. - The PR body says this PR and WHI-1047 will conflict on one line in
linux_native.go; whichever merges second must resolve it.
CI
- All checks pass.
check (computer-go)runs without-raceand does not run the Python tests. - I ran all 13 tests in
linux_guard_test.gowith-race -count=1: pass (1.5 s). - I ran
python3 -m unittest local_linux_guard_test: 9/9 pass.
Automated review by Claude Code
Automated review of a9db0ed by Claude Code.
758e7ff to
b86983c
Compare
There was a problem hiding this comment.
Approve with nits (1 P2)
Scope: base main, merge base 19cdc336, 1 commit, 7 files reviewed. Follow-up on a9db0ed; the branch was rebased, so the PR-only diff (19cdc336..b86983c) was compared with the earlier PR diff rather than a9db0ed..HEAD. Loaded coderbook, ponytail-review and karpathy-guidelines. Ran in a separate session.
Previous findings
- P2 duplicate
toolErrorbranch infinishDesktop: Resolved.errNoActiveWindownow wrapserrNotSent(linux.go:292), andnotSentErrorand the extra branch are gone. - P2 duplicated Python guard plus text matching: Resolved. The Python guard, the 150 ms sleep and
isNoActiveWindowErrorare gone. Go is the only gate. - P2 unreachable
gdbusfallback: Resolved. Only the Gio path is left (local_linux.py:111). Theglobals().get("Gio")guard stays only so the unit test can run without Gio, which is harmless. - P2 Python tests not wired into CI: Resolved.
Makefile:149. Thecheck (computer-go)log showsRan 6 tests ... OK. - P2 README missing
NO_ACTIVE_WINDOW: Resolved. Seeapps/computer/local-daemon/README.md:1094. - P3 sleep-timed test: Resolved.
TestLinuxRunActionsSuperWaitsOverviewSettleBeforeTypenow uses thelinuxSleepseam to switch state deterministically.
Findings
P2
apps/computer/local-daemon/internal/linger/localtools/linux.go:248: when a mid-batchNO_ACTIVE_WINDOWrefusal stops a batch after some steps already ran, the result says nothing was sent.- What happens: in
runActions, when the step after a dispatched step needs a window and the active window is empty, the code setserr = errNoActiveWindowwithdone > 0. It then skips observation (state == nil), sofinishDesktopreturns the bare error.server.go:toolErrorseeserrNotSentand reportsstructuredContent.outcome = "not_dispatched". Thecompleted_steps/total_stepsreport and the window description are dropped. - Example:
run_actions [type_text "hello", press_key Super, type_text "x"]with Overview opening afterSuper. "hello" andSuperwere both sent, but the structured outcome says the call was not dispatched. Code that treatsnot_dispatchedas safe to resend would type "hello" twice.TestLinuxRunActionsSuperWaitsOverviewSettleBeforeTypeasserts this outcome afterSuperwas sent. - Fix: keep the
errNotSentrefusal for thedone == 0precheck. Handle the mid-batch case like the other mid-batch stops: setstopped = "NO_ACTIVE_WINDOW: ..."and let the existing observe path return the steps that completed. Keepingop.linuxWindowis still possible by not overwriting it when the observed window is empty.
- What happens: in
Verified as fine
- The driver runs as
python3 -u -c <program>(linux_native.go:42), so__name__ == "__main__". The newif __name__ == "__main__"guards around fd redirection, signal handlers and the RPC loop do not change behaviour in production. gnome_overview_activeusesNO_AUTO_STARTwith a 300 ms timeout and returnsFalseon any exception (local_linux.py:111-143), so non-GNOME desktops are not affected.active_windownormalises X11None("0") to"".checkWindow(linux.go:340) only refusestype/non-exemptkeyactions when the active window is empty. Bare Escape/Super can still get the Agent out of Overview.WINDOW_CHANGEDstill fires for a different non-empty window. Before any observation, pointer actions still skip the check.- The single-call refusal passes
state == nil, soop.linuxWindowis kept (linux.go:110-112, andfinishDesktoponly updates it fromstate). The action journal is released throughlease.Finish(true). - An inter-step
active-windowread failure now stops the batch instead of being ignored (linux.go:239-243). go test -race -run Linux ./internal/linger/localtoolspassed locally.- There are no CJK characters in added lines or in the commit message.
Process notes
- One commit. No merge or fixup commits. The merge base is the current
mainhead. The PR is blocked only on required review.
CI
All checks pass, including check (computer-go), which now runs the Python unit tests. CI runs the daemon's Go tests without -race, so I ran the Linux guard tests locally with -race, and they passed.
Automated review by Claude Code
Automated review of b86983c by Claude Code.
b86983c to
4035b06
Compare
There was a problem hiding this comment.
Approve with nits (1 P2)
Scope: follow-up on b86983c, reviewing head 4035b06 against main (merge base 19cdc336); 1 commit and 7 files reviewed, with the changes since b86983c (README, linux.go, linux_guard_test.go) read closely. I applied the review rules from the coderbook, ponytail-review (sections 1–3) and karpathy-guidelines (sections 2–3) skills directly; their files were not loaded separately in this run. The review ran in a separate session.
Previous findings (follow-up on b86983c)
- Resolved: a mid-batch refusal was reported as
not_dispatched.linux.go:248now setsstopped = noActiveWindowStoppedinstead of returningerrNoActiveWindow.linux.go:261-269takes a desktop screenshot and reportscompleted_steps/total_stepswith astoppedreason.TestLinuxRunActionsFocusedToEmptyStopsBeforeSubsequentTypeAndKeychecks that only step 1 was sent, that the journal is not blocked, and thatop.linuxWindowis kept.
Findings
P2
apps/computer/local-daemon/internal/linger/localtools/linux.go:417:finishDesktopnow skips an emptystate.windowIDwheneverop.linuxWindowis non-empty.get_window_statealso goes throughfinishDesktop(linux.go:89-99), so this read can no longer update the window baseline to "no active window". The baseline stays on the old window even when the Agent's latest observation shows the desktop with no active window. Every later pointer input then failscheckWindow(linux.go:365:current == "",op.linuxWindow == A) withWINDOW_CHANGED. That error's window state is empty too, so the baseline stays at A.- Failure scenario (I reproduced it with a throwaway test on the PR's fake harness): observe gedit (
16777348), the desktop goes to Overview, then callget_window_state.op.linuxWindowstays"16777348". Both followingclickcalls returnWINDOW_CHANGEDand send 0 inputs. - The same happens after the
alt+F4path thatTestLinuxRunActionsFocusedToEmptyStopsBeforeSubsequentTypeAndKeyexercises when the closed window was the last one. The baseline points at a window that no longer exists, so a click on the dock or desktop is refused until the Agent happens to callscreenshot(which setsop.linuxWindowdirectly atlinux.go:77) oropen_application. The error text ("act on it or bring back the window you meant") points the Agent toward retrying, not toward that recovery. - This also goes against the README's statement that pointer tools stay allowed while no window is active.
TestLinuxNoActiveWindowAllowsPointerActionsonly coversop.linuxWindow = []byte{}. - Fix: keep the window-preservation rule for refused or stopped input only. The
NO_ACTIVE_WINDOWpaths already passstate == niland skip the update (linux.go:110-112,187-189,261). So the extra condition infinishDesktopcan probably be dropped, and an explicit observation would then record what it saw. Add a test for: observe A → Overview →get_window_state→clicksucceeds.
- Failure scenario (I reproduced it with a throwaway test on the PR's fake harness): observe gedit (
Verified as fine
- The single gate in
checkWindow(linux.go:357-369) refusestype_textand non-bare keys, including chords andReturn, before any input when the active window is empty. BareEscape/Superskip theWINDOW_CHANGEDcomparison only when the active window is empty (linux.go:362-364). - Single-step and first-step
NO_ACTIVE_WINDOWrefusals passstate == nil, sofinishDesktopreturns the bare error that wrapserrNotSent(linux.go:110-112,187-189,424-426). - The inter-step pause uses
overviewSettleonly after a bare overview key, through thelinuxSleepseam (linux.go:223-227). The test replaces wall-clock sleeps with that hook. - A failure to read the active window mid-batch now stops the batch instead of comparing an empty reply (
linux.go:239-243). - The Python
__name__ == "__main__"guards don't change runtime behavior: the daemon runs the program withpython3 -u -c(linux_native.go:42), where__name__is"__main__".gnome_overview_activereads the module-levelGio/GLibimported atlocal_linux.py:531and returnsFalseif they are missing or the D-Bus call fails. - The
check-computer-goMakefile target now runs the Python unit tests, and CI'scheck (computer-go)passed with them. - No CJK characters in added lines or in the commit message, and no merge commits.
Process notes
- The branch is 10 commits behind
main, andmainrequires up-to-date branches, so it needs a rebase before merging. - Commit
4035b06has authoryunhewith an empty email, so it isn't linked to a GitHub account.
CI
All checks pass, including check (computer-go), check (computer-go-windows) and repository-gate. CI runs the Go tests without -race. This PR doesn't add goroutines or locks, so I didn't run a race pass. I ran one throwaway probe test (go test -run TestZZProbe on the localtools package, then deleted it) to reproduce the P2 above.
Automated review by Claude Code
Automated review of 4035b06 by Claude Code.
4035b06 to
445303f
Compare
There was a problem hiding this comment.
Approve with nits (1 P2 carried over, 1 P3)
Scope: follow-up on 4035b06. Base main, merge base 19cdc336; 1 commit, 7 files reviewed (full merge-base diff plus the incremental diff 4035b06..445303f, which touches linux.go, linux_guard_test.go and the README). Helper skills coderbook, ponytail-review and karpathy-guidelines were used as the rubric. Ran in a separate session.
Previous findings
- Not resolved: get_window_state keeps the stale window, so clicks are refused again and again (P2).
finishDesktopstill only adopts an observed window when it is non-empty or the stored one is already empty (linux.go:439). After the Agent observes window A and then opens the Overview,clickreachescheckWindow(linux.go:387):"" != A→WINDOW_CHANGED. ThereadWindowStatethat follows returns an emptywindowID, soop.linuxWindowstays A and every later click is refused until A becomes active again. The new commit makes this state more likely: a batch now always stops after a bareSuper(linux.go:254), which leaves the Agent in the Overview. There, the "click a target window" advice inerrNoActiveWindowgets refused. The README now documents the preserved window as intentional, but the stuck-click case isn't addressed.
Findings
P3
apps/computer/local-daemon/internal/linger/localtools/linux.go:336:isOverviewToggleKeyrepeats thesuper/super_l/super_r/win/metalist thatallowKeyWithoutActiveWindow(linux.go:323) already has. If someone adds a key to one list and not the other, the "allowed without a window" rule and the "stop the batch" rule drift apart. Fix: haveallowKeyWithoutActiveWindowmatchescape/escand delegate the rest to one shared toggle-key check.
Verified as fine
- The new toggle stop runs only when a next step exists and that step needs a window (
linux.go:209breaks on the last step before reachinglinux.go:254). BareEscapeis excluded, soEscape→type_textinside a focused app still completes (TestLinuxRunActionsFocusedEscapeContinuesToNextType). - On a toggle stop, the report keeps the completed steps, captures only a screenshot, and passes
state=nil.op.linuxWindowis preserved and the journal is not blocked (linux.go:268-276,TestLinuxRunActionsBareSuperAlwaysStopsEvenIfActiveWindowLags). - No code branches on the
NO_ACTIVE_WINDOWtext. The refusal path useserrors.Is(err, errNoActiveWindow), anderrNoActiveWindowwrapserrNotSent(linux.go:305). Thestoppedstrings are only shown to the Agent.
Process notes
- The branch is 17 commits behind
main, which requires up-to-date branches, so it needs a rebase. - The author of commit
445303f3(yunhe, empty email) is not linked to a GitHub account.
CI
All checks pass, including check (computer-go) and repository-gate. I also ran go test -count=1 -p 4 ./internal/linger/localtools -run Linux (pass) and the Python unittest discover for localtools (6/6 pass). I didn't run -race: the change adds no concurrency.
Automated review by Claude Code
Automated review of 445303f by Claude Code.
…empty active window
Refuse type_text and non-exempt press_key actions on Linux X11 when no application window is active or GNOME Shell's OverviewActive D-Bus property is true, preventing keystrokes from landing in the Activities Overview search box and reporting false-positive completion.
- Query org.gnome.Shell OverviewActive via in-process Gio/GLib session D-Bus (NO_AUTO_START, 300 ms timeout) in local_linux.py:active_window(), returning empty while Overview is open even when a single Escape restores _NET_ACTIVE_WINDOW to a background window, and normalizing X11 None ("0") to empty.
- Gate single-step actions and step 0 of run_actions in Go checkWindow with errNoActiveWindow wrapping errNotSent so server.go reports isError:true and outcome:not_dispatched without altering finishDesktop.
- When run_actions hits an empty active window mid-batch (done > 0) before a keyboard/text step—or immediately after a bare Super/Meta/Win overview toggle key regardless of compositor latency—stop cleanly via the existing stopped/report path (reporting completed_steps, total_steps, a screenshot, and NO_ACTIVE_WINDOW in stopped rather than outcome:not_dispatched) while preserving op.linuxWindow. Focused Escape sequences (such as Vim or dialogs) continue normally when the active window stays focused.
- Keep bare overview-dismiss/toggle keys (Escape, Esc, Super, Super_L, Super_R, win, meta) and pointer/observation/launch/semantic tools allowed while no window is active, preserve op.linuxWindow across NO_ACTIVE_WINDOW refusals and empty-window observations so returning to the previously observed window does not trigger WINDOW_CHANGED, and wait a single 250 ms settle pause in Go runActions after bare overview keys.
- Wire Python driver unit tests into Makefile check-computer-go, add deterministic Go and Python unit tests, and document NO_ACTIVE_WINDOW in apps/computer/local-daemon/README.md.
445303f to
62dcc74
Compare
There was a problem hiding this comment.
Approve (0 findings)
Follow-up on 445303f. Reviewed 62dcc74 against merge base 19cdc336 (1 commit, 7 files).
Previous findings
- Resolved: the Super/Meta/Win key table was duplicated. Both callers now use
isOverviewToggleKeyName(apps/computer/local-daemon/internal/linger/localtools/linux.go:322,:336,:348). The allowed key set is unchanged.
Verified as fine
- The
__name__ == "__main__"guards keep the driver working. The daemon runs the script aspython3 -u -c <program>(linux_native.go:42), where__name__is"__main__". So the protocol fd swap, the signal handlers and the RPC loop all still run in production. gnome_overview_active()readsGio/GLibfrom the module-levelgiimport (local_linux.py:531). If that import fails, the function returnsFalse, so the guard falls back to the plain X11 check and does not crash.finishDesktoponly overwrites a non-emptyop.linuxWindowwith an empty window ID when the stored one is also empty (linux.go:442). This keeps the last observed window through the Overview, so returning to it does not trigger a spuriousWINDOW_CHANGED.
CI: 6 checks passed (including repository-gate and teamhub). check (computer-go) and 8 others were still pending at review time. I ran go test -count=1 -p 4 ./internal/linger/localtools -run Linux (pass) and the Python unittest discover (6/6 pass) locally.
Automated review by Claude Code
Automated review of 62dcc74 by Claude Code.
Summary
Fixes WHI-1046 (Linux GNOME Activities Overview / unfocused desktop causing
type_textandpress_keyto type into the Overview search box while reportingcompleted: true).Root Cause
linux.go,checkWindowandrunActionsonly compared current vs previously observed active window, so"" == ""passed andxdotoolexit code0was reported ascompleted: true.Escapeonce to clear Overview search leaves Overview open while restoring_NET_ACTIVE_WINDOWto the underlying app window, andSuperhas a 100–300ms async delay before_NET_ACTIVE_WINDOWclears.Changes
apps/computer/local-daemon/internal/linger/localtools/local_linux.py:gnome_overview_active()using in-processgi.repository.Gio/GLibsession D-Bus (org.gnome.ShellOverviewActive,NO_AUTO_START, 300ms timeout, no unsafe mode, noXDG_CURRENT_DESKTOPgate), cleanly returningFalseon non-GNOME desktops.active_window()to normalize X11None("0") to""and return""whenevergnome_overview_active()isTrue.apps/computer/local-daemon/internal/linger/localtools/linux.go&linux_native.go:errNoActiveWindow = fmt.Errorf("NO_ACTIVE_WINDOW: ...: %w", errNotSent)directly (reusingserver.go:toolErrorforisError: trueandoutcome: "not_dispatched"without altering othererr != nil && state == nilpaths).checkWindow, single-steplinuxComputerCall, andrunActionsbefore step 0 and between steps with a single250mssettle after bare overview-escape keys). Allows bareEscape/Esc/Super/Super_L/Super_R/win/metaand pointer/observation/launch tools; blockstype_text,Return, letters, and all chords before dispatching any input.op.linuxWindowonNO_ACTIVE_WINDOWrefusal while bypassingWINDOW_CHANGEDfor bareEscape/Superwhen active window is empty—preventing spuriousWINDOW_CHANGEDwhen returning to the original window while preserving cross-window protection.apps/computer/local-daemon/README.md&Makefile:NO_ACTIVE_WINDOWalongsideWINDOW_CHANGEDandSCREEN_LOCKEDin README.python3 -m unittest discover -s apps/computer/local-daemon/internal/linger/localtools -p '*_test.py'intocheck-computer-go(make check-computer& CI).linux_guard_test.go&local_linux_guard_test.py: Full Go and Python unit test suites (with deterministiclinuxSleephook replacing wall-clock sleep racing).Review Updates
errNoActiveWindowwrappingerrNotSent, removednotSentErrorand extrafinishDesktopbranch), P2-2 (removed duplicate Python guard, Python 150ms sleep, andisNoActiveWindowError; single Go gate + single 250ms Go settle), P2-3 (removed deadgdbusfallback and tests), P2-4 (Makefilecheck-computer-goruns Python tests), P2-5 (README updated), P3-6 (deterministiclinuxSleephook inTestLinuxRunActionsSuperWaitsOverviewSettleBeforeType), and rebased onto latestmain(29ad855e).Verification
unittest discover6/6,py_compile, JSON-RPCinitialize), Go (go vet, Go unit tests inlocaltools), andGOOS=linux GOARCH=amd64cross-compile all PASS.118: Overview input guard and 30xrun_actions [Super, type_text]under the single Go gate + 250ms settle.linux_native.gowith a 1-line test seam alongside PR fix(computer): launch Linux apps in transient scope and surface launch errors (WHI-1047) #779; whichever merges second will have a trivial 1-line conflict to unify.