Skip to content

feat(search): search every connected AO machine from Cmd+K - #7378

Draft
illegalcall wants to merge 2 commits into
ao/session-searchfrom
ao/session-search-machines
Draft

illegalcall wants to merge 2 commits into
ao/session-searchfrom
ao/session-search-machines

Conversation

@illegalcall

@illegalcall illegalcall commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Code changes: +436 -33
Tests: +364 -4
Others: +66 -0 (9 locale catalogs, OpenAPI + schema.ts for one field)

Two commits: namedForQuery on each result (backend and API), then the cross-machine search in Cmd+K.

Stacked on #7362, which adds session search on one machine. Review that first; this PR's diff is against its branch.

What

Cmd+K now searches this machine and every connected remote AO machine at once, and shows one merged list.

  • Remote rows show the machine's name and open on that machine (/host/$hostId/…). Find in chat opens there and searches that machine.
  • "Not searched on …" lists every machine that didn't answer, and why: offline, still connecting, no answer within 6 s, update AO there, saved password refused, or an error.

Why

You asked to search across your machines from one place. The design follows from also wanting cloud projects included later.

  • Cloud. Cloud sessions live in the control plane, and only the desktop holds the cloud sign-in.
  • Remote machines. Their credentials already live in the desktop's main process (the remote proxy behind clientForHost).

So the desktop does the fan-out, rather than a daemon reading other machines' passwords from remotes.json (the earlier proof of concept). Cloud projects become one more source later.

Before / After

Before (#7362) After
Cmd+K finds past sessions on this machine only It also searches every connected remote machine; remote rows show the machine's name, e.g. AzureLinux · you · app · codex
A remote machine's sessions can't be found from here Selecting a remote row opens it on that machine at the matched message, and find in chat there searches that machine
— An offline, slow or outdated machine is listed, e.g. "Not searched on Laptop (offline)." It never fails the search
GET /api/v1/search/sessions has no name-match field Each result carries namedForQuery when its session's name holds every typed word

No screenshots: this Mac can't build the Electron dev app (see Testing).

How

  • Fan-out (hooks/useRemoteMachineSearch.ts).
    • One TanStack query per connected remote, through clientForHost, each with a 6 s limit.
    • A remote daemon already serves /api/v1/search/* to an authenticated desktop; its LAN and tunnel listener blocks only control routes.
    • Saved machines that aren't connected are reported without being asked, from a snapshot useRemoteHosts publishes (lib/saved-remote-hosts.ts), so nothing connects a second time.
  • Merge (lib/session-search-machines.ts).
    • Bm25 scores depend on each machine's own index and are never compared. Lists take turns across machines, this machine first, as Orca's all-hosts search does.
    • Name rule: sessions named for the query come first, in turns, then the rest. Each machine says so via namedForQuery, so the desktop never judges words itself, and an older AO simply falls into the second tier.
    • Newest first: lists merge by time.
  • Display. This machine's answer shows at once. The merged list replaces it once every machine has answered or timed out, so rows don't jump while you read.
  • Classifying failures.
    • Offline: a gateway answer (502, 504, 520–527, 530 from a gone quick tunnel) or a network error.
    • Update AO there: 404, 405, 501. Saved password refused: 401, 403.
    • Error: anything else, including 503, which AO itself uses.
  • Keeping machines apart.
    • The same session id on two machines is two sessions: a remote row never hides this machine's chat row.
    • The resume command (⌘↵) is offered only for this machine's sessions.
  • Backend: one field. The store already computes the name tier per row; it now returns it.

Reviewers might focus on: useRemoteMachineSearch.ts (timeout, cancellation, outcomes), the merge, and the two consumers in CommandPalette.tsx and SessionSearchView.tsx.

Intentional omissions:

  • Cloud projects. They need a search endpoint in the control plane: text from ao_events in PostgreSQL full-text search, scoped to the organization. Deferred by request.
  • ao search and agents still search only the machine they run on.
  • Typo repair is deferred.

Also fixed: SessionSearchView.test.tsx's workspace mock pointed at ./useWorkspaceQuery, a path the component doesn't import, so it never applied. It now mocks ../hooks/useWorkspaceQuery, and the existing tests still pass.

Testing

On this head (restacked 10 Nov on #7362 002cf732e2, which is rebased onto main d429710c18):

  • No drift in the regenerated OpenAPI spec or schema.ts.
  • typecheck and typecheck:e2e are clean.
  • The frontend test files this PR touches, plus find in chat, the search hooks and the i18n checks: 15 files, 577 tests pass.
  • go build, go vet and the tests of store, sessionsearch, controllers and domain pass. The last restack only removed feat(search): search every past session from Cmd+K and ao search #7362's 43-search ranking suite and reworded comments under this PR, so the frontend results and apispec are from the restack before it.
  • Not rerun on this head: the full Vitest suite (last full run 7 Nov: 698 files, 12,080 passed and one failed, on a rule feat(search): search every past session from Cmd+K and ao search #7362 then fixed), the renderer Playwright gate, and golangci-lint for this PR's one backend field.

What changed in the restack:

The list below describes the tests this PR adds. Its run results are from when the PR was first pushed (28 Oct), on an 8 GB MacBook Air:

  • Backend (one new field):
    • go build ./... and go vet on the touched packages.
    • go test -race -count=1: domain, service/sessionsearch (including the name-tier test, which now also checks namedForQuery), httpd/controllers (the field on the wire), httpd/apispec (+ spec drift), storage/sqlite/store. All ok.
    • golangci-lint v2.13.2 on the touched packages: 0 issues.
    • The OpenAPI spec and schema.ts were regenerated: +3 lines.
  • New tests:
    • The merge: taking turns with this machine first; sessions named for the query first, in turns; newest-first by time; a missing machine dropped without losing the rest.
    • Failure classification: 401/403, 404/405/501, 502/504/521/530, 500/503, timeout, network error.
    • The hook: idle without words or while disabled; every connected machine asked the same words with labels; failures reported per machine; a slow machine gets 6 s (fake timers); saved machines that aren't connected reported without a request.
    • Cmd+K:
      • a remote row is labelled and opens on its machine at the matched message;
      • "Not searched on Old desk (update AO there to search it).";
      • this machine's answer stays until every machine has answered;
      • a remote standalone session opens on its machine's standalone route.
    • Palette model: a remote row offers no local resume command; a remote session never hides this machine's chat row.
    • Saved machines: useRemoteHosts publishes them for search.
  • Frontend:
  • Not verified here: the real desktop app, so there are no screenshots. This Mac can't build the Electron dev app (better-sqlite3 for Electron 44 needs C++20; Command Line Tools clang 14). A two-Mac test (28 Oct) checked the per-machine API across a tunnel, the merge rules and the outcomes, but through the earlier daemon fan-out, not this desktop path. A live check needs two machines running this branch's desktop.

CI: main's workflows now run only for non-draft PRs targeting main (!draft && base_ref == 'main'). This PR is stacked on #7362's branch, so its full CI runs once #7362 merges and this PR is retargeted to main. The last full run was 29/29 green on 14fcd67ff8, the previous head.

Checklist

  • Branched from main (or continuing an existing PR branch). Stacked on feat(search): search every past session from Cmd+K and ao search #7362's branch.
  • One focused change; links the related issue when applicable
  • Follows AGENTS.md conventions and PR hygiene
  • Before / After filled in; UI changes include screenshots or a recording
  • Tests added/updated for user-visible behavior where it makes sense
  • Relevant CI checks pass for the area touched (go, frontend, etc.)

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

🏆 Review leaderboard

Oct 21–28, 2026 · UTC

Rank Reviewer PRs reviewed Review rounds PR comments
🥇 @ronishrohan @ronishrohan 62 108 38
🥈 @Vaibhaav-Tiwari @Vaibhaav-Tiwari 25 44 9
🥉 @illegalcall @illegalcall 17 54 8
4 @nikhilachale @nikhilachale 13 27 2
5 @mohakchakraborty2004 @mohakchakraborty2004 12 14 6
6 @Rishet11 @Rishet11 8 18 7
7 @Pritom14 @Pritom14 8 8 22
8 @Prasad-D-Ware @Prasad-D-Ware 7 18 0
9 @somewherelostt @somewherelostt 5 16 3
10 @codebanditssss @codebanditssss 5 9 0

Ranked by distinct external PRs reviewed, then review rounds, then PR comments. Self-activity and bot activity are excluded.

Show 7 more reviewers
Rank Reviewer PRs reviewed Review rounds PR comments
11 @neversettle17-101 @neversettle17-101 4 11 2
12 @Annieeeee11 @Annieeeee11 3 11 2
13 @Meraj-08 @Meraj-08 3 10 2
14 @ApexYash11 @ApexYash11 3 9 3
15 @whoisasx @whoisasx 3 3 2
16 @OrcInc @OrcInc 1 1 15
17 @MohamedKamran @MohamedKamran 1 1 0

@OrcInc OrcInc added comp/desktop Electron main process and React renderer. enhancement New feature or request labels Oct 28, 2026
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from ab01af7 to 14fcd67 Compare October 28, 2026 15:51
@OrcInc OrcInc added this to the Desktop & UI milestone Oct 28, 2026
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 14fcd67 to 6ae6f81 Compare November 4, 2026 22:02
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 6ae6f81 to a9cb29c Compare November 5, 2026 07:24
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from a9cb29c to db0e4f6 Compare November 6, 2026 22:05

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. 2 correctness issues are recorded inline. Reviewed the requested head against its PR base (using the merge base for #7362). Static inspection only; project code, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from db0e4f6 to fd6b7a1 Compare November 6, 2026 22:35

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The previous host-identity and effective-sort findings are fixed. The new exhaustion check can hide remaining pages after deduplication; the required finding is recorded inline. Static inspection only; project code, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch 2 times, most recently from d3c6193 to 1e9735a Compare November 7, 2026 17:17

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The earlier host/sort and duplicate-row pagination cases are fixed. One remaining paging issue is recorded inline: exhausted sources can still have fetched matches beyond the displayed slice. Static inspection only; project code, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 1e9735a to 0466cdb Compare November 7, 2026 17:50

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for this stacked diff; no additional required changes found. The buffered-results fix keeps Show more available when exhausted machines have fetched matches beyond the displayed page, while preserving the earlier deduplication, host-identity, and effective-sort fixes. The separate base-PR review contains one remaining navigation finding. Static inspection only; project code, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch 2 times, most recently from d434340 to d2e388f Compare November 7, 2026 18:53

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready; approving this stacked diff with no required changes found. The restack retains the repeated-reveal fixes and host-qualified navigation, and the previously reviewed remote paging and effective-sort fixes remain intact. Static inspection only; project code, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch 2 times, most recently from 2edfb83 to 22f208a Compare November 8, 2026 15:06
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch 2 times, most recently from 12f74f9 to 8284f80 Compare November 8, 2026 16:47

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for the changes introduced by this stacked PR. No required findings in the remote search delta: fanout, pagination, merge order, cancellation, and host-qualified routing/reveal remain consistent with the updated base. The repeated-command reveal regression inherited from #7362 is reported on that base PR. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from e543ee7 to 6b4514c Compare November 11, 2026 21:15

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. The seven remote-search patches are unchanged from the previously reviewed version after restacking onto the repeated-command reveal fix in #7362. Reviewed the pinned head against its updated base and verified the patch series remains equivalent. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 6b4514c to df68a6e Compare November 11, 2026 21:28

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. The seven remote-search patches are unchanged from the approved version after restacking onto the unused-argument cleanup in #7362. Reviewed the pinned head against its updated base and verified the patch series remains equivalent. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from df68a6e to aa7818a Compare November 12, 2026 10:46
@illegalcall illegalcall changed the title feat(search): search every connected AO machine from Cmd+K and the Search page feat(search): search every connected AO machine from Cmd+K Nov 12, 2026

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. The remote search changes remain consistent after removing the dedicated Search page: Cmd+K sends the query and its fixed short limit, typed operators remain in q, and merging follows the local daemon's reported sort. Removed paging/filter infrastructure has no remaining callers or dangling imports. Reviewed the pinned head against its updated base and compared the revised series with the previously approved version. Static inspection only; project programs, tests, and builds were not executed.

illegalcall added a commit that referenced this pull request Nov 12, 2026
Every document recorded the daemon's host name so a machine: operator,
a --machine flag and a machine API parameter could filter on it. An index
only ever holds one machine's sessions, so the filter matched everything
or nothing, and no client read the field on a result. Searching across
machines (#7378) is a merge in the desktop, which labels rows by the host
it asked; it does not use this column.

Removed: the machine column in search.db, the two filter clauses and their
arguments, the operator, the CLI flag, the API parameter and the result
field (openapi.yaml and schema.ts regenerated), and the host label wiring
in the daemon. The schema version stays 1: nothing has shipped, and an
older development index only carries an unused column.

Also shortens the fourteen longest comment blocks in these files and three
that described earlier behaviour or one-off measurements. The stemmer's
comment no longer says it is checked against Porter's full vocabulary: that
was a manual test, removed in 8cab247; TestPorterStemKnownWords still
pins it.

Verified: go test for domain, sessionsearch, controllers, store, daemon and
telemetrymeta after the filter removal; go build, vet and gofmt after the
comment edits, which change no code. cli passes except
TestBrowserRequiresSessionAndValidWait, which reaches the live daemon and
fails the same way on main.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
illegalcall added a commit that referenced this pull request Nov 12, 2026
Every document recorded the daemon's host name so a machine: operator,
a --machine flag and a machine API parameter could filter on it. An index
only ever holds one machine's sessions, so the filter matched everything
or nothing, and no client read the field on a result. Searching across
machines (#7378) is a merge in the desktop, which labels rows by the host
it asked; it does not use this column.

Removed: the machine column in search.db, the two filter clauses and their
arguments, the operator, the CLI flag, the API parameter and the result
field (openapi.yaml and schema.ts regenerated), and the host label wiring
in the daemon. The schema version stays 1: nothing has shipped, and an
older development index only carries an unused column.

Also shortens the fourteen longest comment blocks in these files and three
that described earlier behaviour or one-off measurements. The stemmer's
comment no longer says it is checked against Porter's full vocabulary: that
was a manual test, removed in 8cab247; TestPorterStemKnownWords still
pins it.

Verified: go test for domain, sessionsearch, controllers, store, daemon and
telemetrymeta after the filter removal; go build, vet and gofmt after the
comment edits, which change no code. cli passes except
TestBrowserRequiresSessionAndValidWait, which reaches the live daemon and
fails the same way on main.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from aa7818a to c9ce61a Compare November 12, 2026 21:08

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. Reviewed the pinned head against its updated base and verified the five remote-search patches remain equivalent to the approved series apart from test import context. Host-qualified routing, reveal/reviewer focus, and reading-position scope remain consistent; palette import commands are preserved. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from c9ce61a to 4d91df2 Compare November 13, 2026 12:07

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. Reviewed the pinned head against its updated base and checked that squashing preserves the prior remote-search fixes. Runtime fanout, merge order, timeout/cancellation, host-qualified routing and reveal, and local-only resume actions remain intact; the updated base consumes the same reveal fields. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 4d91df2 to 99343b8 Compare November 13, 2026 15:18

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: one P2 integration issue with the new optional local index. A terminal local search failure causes the palette to discard otherwise successful remote results. The remaining remote-search patches preserve the previously reviewed behavior. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 99343b8 to 082a163 Compare November 13, 2026 15:33

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. The previous P2 finding is resolved: a terminal local search failure now allows successful remote answers to render while retaining the local error notice. Pending/placeholder isolation remains intact, and remote-only merging follows the daemon-reported sort. The added palette regression test covers local unavailability plus a healthy remote hit. Reviewed the pinned head against its base and the fix against the prior reviewed head. No remaining required findings. Static inspection only; project programs, tests, and builds were not executed.

@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 082a163 to 9407928 Compare November 13, 2026 17:58

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. Reviewed the pinned head against its updated base and compared the restacked patches with the approved version. The local-failure fallback, remote-applied sort, host-qualified routing/reveal, and remote connection behavior are preserved alongside the new main UI behavior. Static inspection only; project programs, tests, and builds were not executed.

illegalcall and others added 2 commits November 14, 2026 12:58
… query

namedForQuery is set when the session's name holds every typed word. A
caller merging results from several machines puts those sessions first
without judging words itself, and an older daemon without the field simply
falls into the second tier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cmd+K asks this machine and every connected remote AO machine at once and
shows one merged list.

- Fan-out from the desktop, which already holds each remote's credentials
  (clientForHost): one query per connected machine, each with a 6 s limit.
  Saved machines that are not connected are reported without being asked.
- Merge: machines' bm25 scores are never compared; lists take turns, this
  machine first, with sessions named for the query first. A sort:recent
  query merges by time.
- Remote rows name their machine and open there, at the matched message.
  "Not searched on ..." lists every machine that did not answer and why
  (offline, connecting, timed out, needs an AO update, password refused,
  error); a failing machine never fails the search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@illegalcall
illegalcall force-pushed the ao/session-search-machines branch from 9407928 to 94f55f4 Compare November 14, 2026 07:33

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. No required findings. Reviewed the pinned head against its updated base and compared the restacked patches with the approved version. Publishing the saved-host snapshot preserves the new host-list settled state and account cleanup. Remote query/reveal behavior and the local-failure fallback remain intact. Static inspection only; project programs, tests, and builds were not executed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron main process and React renderer. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants