sessions: the Antigravity app connected to WSL has its usage read from the distro (@guyng35955 on X)
@guyng35955 on X: on Windows, with the Antigravity app connected to a
WSL Ubuntu, magpie showed no Antigravity usage.
Why. Antigravity 2.x (dist/wsl.js and languageServer.js in its
app.asar) runs a Linux language server in the distro when it is
connected to WSL ($HOME/.antigravity-server/bin/<version>/
language_server, started through wsl.exe with --app_data_dir
antigravity), so the conversations go to the distro's
~/.gemini/antigravity, not %USERPROFILE%\.gemini\antigravity. magpie
read Antigravity's conversations only from this computer's folder:
- sessions.wslAgents had no antigravity (nor agy, whose
~/.gemini/antigravity-cli in a distro wasn't read either);
- internal/agent kept a distro for the Sessions page only when one of
wslKinds or the Copilot CLI's folder was there, so a distro with only
the app's data never reached sessions.WSLHomes;
- and, found on the Windows box: no SQLite database under
\\wsl.localhost opens in place. Every form (file: URI, plain path,
mode=ro, provider.OpenReadOnly) answers SQLITE_BUSY after its 3s
busy_timeout, since the share doesn't take the locks a WAL database
needs. So listing the files alone would have shown nothing still.
What changed.
- agent: wslKept keeps a distro with ~/.gemini/antigravity(-insiders),
and the probe looks for them (no agent row for them).
- sessions: wslAgents reads the app's conversations (insiders under
their own key) and agy's in a distro; their summary rows name the
distro's folders as Linux does (agyFolder with goos "linux", so
/home/me/site, not a Windows path). The distro's calls count in
Calls (wslFiles("antigravity"), wslCallFiles("agy")). The listing
kept on disk (sessions-wsl.json) carries each file's row, rev and
read-only, so a stopped distro keeps its titles and folders. A
distro's ~/.gemini that is this computer's own (a link) is read once,
as this computer's (sameDir).
- sessions: openAppStore opens agy's and the app's databases read only
in place, or, under \\wsl.localhost or \\wsl$, as OpenUntouched does
(immutable with no -wal, else from a copy of the db and its -wal).
- docs/subsystems/agent-wiring.md says which distros are kept for reads
only.
Not changed: session-read consent ("allow selected" names agents found
on this computer) doesn't look in WSL, as before for every WSL agent.
OpenCode's and ZCode's SQLite readers aren't used for a distro (not in
wslAgents), so they keep provider.OpenReadOnly.
Run (at the tree rebased on dc85a7ca5; then rebased on c8290df25, which
changes nothing under internal/sessions or internal/agent):
- mote: gofmt -l internal (clean); GOOS=linux go vet -tags nogui ./...
and GOOS=windows go vet ./... ok; go test -tags nogui -count=1
-timeout 45m ./internal/sessions/ ./internal/agent/: ok (sessions 104s,
agent 223s).
- Windows 11 (xiaomi-gpu, win-run): go test -run TestWSL
./internal/sessions/ ok.
- Real \\wsl.localhost read on xiaomi-gpu: a fixture conversation
(WAL) and conversation_summaries.db, and agy's conversations, written
in the WSL distro magpie-desktop's real ~/.gemini from inside Linux;
a throwaway test on Windows with WSLHomes at
\\wsl.localhost\magpie-desktop\home\yeton. Before openAppStore: agy
listed with no folders, the app's conversation missing, 0
antigravity calls, listing 6.4s (each open waits 3s for BUSY).
After: the conversation listed with the distro, its title, folder
/home/me/site, tokens and 4 calls; agy's folders read; listing
0.21s. With a writer in the distro holding a title only in the -wal
(wal_autocheckpoint=0, db held open), Windows read the -wal's title.
The fixture and binaries were removed after.
Broken by hand:
- the three wslAgents entries and the Calls line out:
TestWSLAntigravityApp red (no antigravity session from the distro);
- sameDir check out: TestWSLAntigravityLinkedHomeOnce red (listed as
the distro's);
- the listing's row (m.agy, m.rev) not carried: TestWSLAntigravityApp
red (no title or folder);
- wslKept without the Antigravity dirs: TestWSLAntigravityHome red
(no homes).
Not tried: a real Antigravity sign-in connected to WSL (the box's app
isn't signed in, and the connection needs its GUI), so the language
server's own files are this fixture, laid out as its source writes
them; the full suite (five full suites were queued on mote's
suite.lock and two on mica's).
This commit is contained in:
@@ -38,7 +38,7 @@ something else shows up as drift.
|
||||
| Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/<name>` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#<name>` on Windows, `omp#<name>@wsl:<distro>` in a distro — so each can be connected, drifted and disconnected on its own. They share omp's model lists (`ListsFor`), and the default `omp` row is the folder `ompDir`/`ompIn` already pick, so an `OMP_PROFILE` that row is already pointed at is not listed twice. A name omp refuses is not a row: `default`, a trailing dot, or a Windows reserved device name (`aux`, `nul`, `com1`, `lpt9.x`, `con.work`), on every platform (`ompProfileOK`). A distro's profile names come from its probe and are kept in `wsl.json`; a stopped distro is never started to list them, its profile rows showing what was last seen (`asleep`). | [`omp.go`](../../internal/agent/omp.go), [`wsl.go`](../../internal/agent/wsl.go) |
|
||||
| omp's advisor | omp's advisor (`src/advisor`) is a second model, on the `advisor` role, that reviews the main agent's work and sends it notes; it runs only while `advisor.enabled` is true, which omp leaves off (#6408, Awad_Yoo on X). A model picked for the advisor role turns it on when the user hasn't set it, and the role's reset takes back only what that pick wrote (`ompAdvisorTurnedOn`, a stash mark). Three Quiet fields write the rest of `config.yml`'s `advisor` block as omp reads it (`ompAdvisorFields` in [`omp_advisor.go`](../../internal/agent/omp_advisor.go)): `advisor_review` (off, `turn`, `agent-end`: `enabled` with `reviewMode`; off keeps the mode), `advisor_wait` (`syncBacklog`: `off`, `"1"`, `"3"`, `"5"`, `strict`, written as strings since omp's enum settings take strings only) and `advisor_wake` (`continueSeverity`: `nit`, `concern`, `blocker`, omp 18.12.1 or later). They show in omp's opened row and sheet as three rows (`ompAdvisorIn`, drawn by `ompadvisor.js`, imported the first time), the last two only while it reviews; the roles square's advisor line says " · off" when it is off. A `WATCHDOG.yml` roster sets each advisor's own review and wait over these, and is not shown. Taking over from the main model after repeated failures is not omp's advisor's: omp has no such setting, and an omp extension (`pi.on("tool_result")`, `pi.setModel`) is where it goes. `TestOmpAdvisorPickTurnsItOn`, `TestOmpAdvisorSettings`, `omp-advisor.test.cjs`. |
|
||||
| Claude Code in more than one folder | A Claude Code kept elsewhere with `CLAUDE_CONFIG_DIR` (an alias per account or workspace) has its own settings.json. The claude row is the folder the variable names, else `~/.claude`; every other folder under the home folder named `.claude…` that holds Claude Code's own files (`settings.json`, `.credentials.json` or `projects/`) is a row of its own, `claude#<name>` (`.claude-work` → `Claude Code · work`; the default `~/.claude` is `claude#default` while the variable points elsewhere), made by `claudeIn` at that folder (`place.dir`, as the `claude#launch` file is) and connected, set and checked there alone. The file `~/.claude.json`, another tool's `.claude-…` folder with none of those files and the launch file's folder are not listed. A folder outside the home folder is not found (BieJian21872 on X; `TestClaudeCodeInMoreThanOneFolder`). | [`claude_dirs.go`](../../internal/agent/claude_dirs.go) |
|
||||
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). The probe runs `sh -l`, which reads `~/.profile` but not `~/.bashrc`, so a command off its PATH is looked for where Node's managers and installers keep one, as `proc.UserBinDirs` does here (`wslbin`): bun, `~/.local/bin`, volta, pnpm, nvm's default then the highest, fnm's default then the highest (`FNM_DIR`, `~/.local/share/fnm`, `~/.fnm`), mise's installs and shims, asdf, `~/.npmrc`'s prefix, cargo, deno and Homebrew (千里不再 on Discord: a Pi from fnm, not run yet so with no `~/.pi`, wasn't found). One on a Windows drive, which WSL's PATH reaches first when the distro's isn't on it, is looked past rather than taken as the only one (`wslcmd`, `wslwin`; `TestWSLProbeFindsNodeManagersBins`, `TestWSLProbeLooksPastWindowsCommand`). The shell isn't asked interactively for `~/.bashrc`'s PATH: under `timeout` such a bash stops itself on WSL and outlives the timeout. Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Antigravity CLI is found by its own `~/.gemini/antigravity-cli` or its `agy` command (mimi001234 on Discord). Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). Under NAT the key is the gateway's WSL key (`gateway.WSLKey`, `-<agent>` after it where the agent's key names it), sharing on or off; the gateway listens at that address itself (gateway-routing's WSL under NAT). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). While Codex on Windows is connected, `ConnectCodexTwins` (run by `SyncCatalog`, [`codex_wsl_auto.go`](../../internal/agent/codex_wsl_auto.go)) connects each running distro's Codex once, because the Codex app's work mode on a WSL project runs its app-server on the distro's `~/.codex`, not Windows': the twin is skipped when it is already connected or disconnected, when its config names a provider or base URL of the user's own, or when the distro is stopped; a mark in the stash (`<id>.autoconnected`) keeps it from being done again after a Disconnect. With Settings' Detect agents in WSL off (`NoWSLAgents`, #1264) magpie starts no wsl.exe at all: `proc.Command`, `CommandContext` and `ProbeContext` refuse one by any name or path with `proc.ErrWSLOff` (`wslOff` in [`proc/wsl.go`](../../internal/proc/wsl.go)), where every command magpie runs is made, so a path past agent's and wslrun's own gates (a request's Claude Code stand-in and classifier, #4872: on a computer without WSL each ask put up Windows' install window) asks nothing either (`TestWSLOffStartsNoWSL`, `TestWSLRunnerRefusedWhenOff`, `TestRunRefusedWhenOff`, `TestWSLStandInAsksNothingWhenOff`). With detection on, the same gate refuses wsl.exe with `proc.ErrNoWSLDistro` while the registry has no distro for the user (`HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`, a key with a `DistributionName` each, read at every start, so one installed later is listed at once; a read that fails is unknown and wsl.exe is asked as before), and agent's and wslrun's listings take that as none (TraderX219 on X: Windows' own wsl.exe without WSL's package put up its update console every 20 to 30 seconds). A failed run whose output says WSL must be installed or updated (`wsl.exe --update`, the inbox prompt, the optional component missing; `proc.WSLSaid`, told by agent's and wslrun's runners) writes `wsl-update` beside settings.json, and wsl.exe is then refused with `proc.ErrWSLNeedsUpdate` for six hours, by every magpie process, unless WSL's package version or the registered distros change; a refused listing is unknown, so nothing remembered of a distro is forgotten (`TestNoWSLDistroStartsNoWSL`, `TestWSLUpdateBacksOff`, `TestNoWSLDistroRunsNoWSL`, `TestWSLUpdateKeepsDistros`). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go), [`proc/wsl.go`](../../internal/proc/wsl.go) |
|
||||
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A distro with none of them is still kept, with no agent row, for what magpie only reads there: the Copilot CLI's folder (its sign-in, #723) and the Antigravity app's `~/.gemini/antigravity` (or `-insiders`), which the Windows app connected to WSL keeps in the distro, since its language server runs there (`wslKept`, `TestWSLAntigravityHome`; the Sessions page reads its conversations, `sessions.wslAgents`). A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). The probe runs `sh -l`, which reads `~/.profile` but not `~/.bashrc`, so a command off its PATH is looked for where Node's managers and installers keep one, as `proc.UserBinDirs` does here (`wslbin`): bun, `~/.local/bin`, volta, pnpm, nvm's default then the highest, fnm's default then the highest (`FNM_DIR`, `~/.local/share/fnm`, `~/.fnm`), mise's installs and shims, asdf, `~/.npmrc`'s prefix, cargo, deno and Homebrew (千里不再 on Discord: a Pi from fnm, not run yet so with no `~/.pi`, wasn't found). One on a Windows drive, which WSL's PATH reaches first when the distro's isn't on it, is looked past rather than taken as the only one (`wslcmd`, `wslwin`; `TestWSLProbeFindsNodeManagersBins`, `TestWSLProbeLooksPastWindowsCommand`). The shell isn't asked interactively for `~/.bashrc`'s PATH: under `timeout` such a bash stops itself on WSL and outlives the timeout. Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Antigravity CLI is found by its own `~/.gemini/antigravity-cli` or its `agy` command (mimi001234 on Discord). Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). Under NAT the key is the gateway's WSL key (`gateway.WSLKey`, `-<agent>` after it where the agent's key names it), sharing on or off; the gateway listens at that address itself (gateway-routing's WSL under NAT). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). While Codex on Windows is connected, `ConnectCodexTwins` (run by `SyncCatalog`, [`codex_wsl_auto.go`](../../internal/agent/codex_wsl_auto.go)) connects each running distro's Codex once, because the Codex app's work mode on a WSL project runs its app-server on the distro's `~/.codex`, not Windows': the twin is skipped when it is already connected or disconnected, when its config names a provider or base URL of the user's own, or when the distro is stopped; a mark in the stash (`<id>.autoconnected`) keeps it from being done again after a Disconnect. With Settings' Detect agents in WSL off (`NoWSLAgents`, #1264) magpie starts no wsl.exe at all: `proc.Command`, `CommandContext` and `ProbeContext` refuse one by any name or path with `proc.ErrWSLOff` (`wslOff` in [`proc/wsl.go`](../../internal/proc/wsl.go)), where every command magpie runs is made, so a path past agent's and wslrun's own gates (a request's Claude Code stand-in and classifier, #4872: on a computer without WSL each ask put up Windows' install window) asks nothing either (`TestWSLOffStartsNoWSL`, `TestWSLRunnerRefusedWhenOff`, `TestRunRefusedWhenOff`, `TestWSLStandInAsksNothingWhenOff`). With detection on, the same gate refuses wsl.exe with `proc.ErrNoWSLDistro` while the registry has no distro for the user (`HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`, a key with a `DistributionName` each, read at every start, so one installed later is listed at once; a read that fails is unknown and wsl.exe is asked as before), and agent's and wslrun's listings take that as none (TraderX219 on X: Windows' own wsl.exe without WSL's package put up its update console every 20 to 30 seconds). A failed run whose output says WSL must be installed or updated (`wsl.exe --update`, the inbox prompt, the optional component missing; `proc.WSLSaid`, told by agent's and wslrun's runners) writes `wsl-update` beside settings.json, and wsl.exe is then refused with `proc.ErrWSLNeedsUpdate` for six hours, by every magpie process, unless WSL's package version or the registered distros change; a refused listing is unknown, so nothing remembered of a distro is forgotten (`TestNoWSLDistroStartsNoWSL`, `TestWSLUpdateBacksOff`, `TestNoWSLDistroRunsNoWSL`, `TestWSLUpdateKeepsDistros`). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go), [`proc/wsl.go`](../../internal/proc/wsl.go) |
|
||||
| WSL folders that are links | Through `\\wsl.localhost` Windows can't follow a link the distro has: with `~/.codex` a link to `/mnt/c/Users/<user>/.codex`, a mkdir of it says it exists and nothing below it can be made, written, read or listed (#4502, linusxiong). The probe asks `readlink -f` there where each agent folder, its `skills` and the folders beside them lead (`wslLinkPaths`, `distro.Links`; a `$HOME` that is itself through a link is left as it was) and which drive each Windows mount is (`distro.Drives`). `distro.open` opens a path at or below a link where it leads: on a Windows drive the drive's own path (`C:\Users\<user>\.codex`), elsewhere in the distro through its root again; `native` spells such a path back through the link for the agent. A link `readlink -f` couldn't resolve is never guessed at: its agent is unreached (`Agent.Unreached`), says why in its notice and refuses each change and sync. Every writer goes through it: the agents' own files (`place.join`, `place.open`), the library's targets (`wslOpen`, a `wsl` problem per agent), RTK (`rtkAt`, `agent.WSLOpen`), the Sessions page's reads (`sessions.WSLHome.Open`) and the Copilot CLI's sign-in (`provider.CopilotWSLDirs`). Links deeper than the probed paths aren't resolved (`TestWSLOpenThroughLinks`, `TestWSLAgentFolderIsALink`, `TestWSLAgentFolderLinkUnresolved`, `TestWSLProbeLinks`, `TestWSLFolderIsALinkToC`, `TestRTKWSLFolderIsALink`). | [`wsl.go`](../../internal/agent/wsl.go), [`targets.go`](../../internal/library/targets.go), [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) |
|
||||
| WSL CLI versions and updates | A twin's CLI is read and updated in its distro, as the host's is (`cliupdate_wsl.go`; mewcoder on X): the Agents row shows the version, the newest and an Update button for every `cliSpecs` kind a distro has a command for, and Update all takes them in. Where the binary is comes from the probe (`distro.Paths`, else the command asked of the distro's PATH); one `wsl.exe -d <distro> -e sh` script says where its links lead, its `--version` and exit code (`wslCLIScript`, kept ten minutes in `wslProbes`, asked again by Rescan and after an update), with the CLI's own folder, its npm prefix, `~/.local/bin` and `~/.bun/bin` first on PATH, since `wsl.exe -e` has no login PATH and a node CLI would not find node. How it was installed is read from that Linux path by the same rules (`wslHowInstalled`: its own updater via `cliSpec.self`, Homebrew's Cellar, npm, bun or pnpm; volta, yarn and an npm prefix the user can't write, `/usr/lib`, are left alone), and the update runs in the distro through wsl.exe (`wslRunUpdate`) with a Linux brew asked for its newest in the distro too. A distro that isn't running is never started to be asked: its rows show no version and an update says to start it. Not carried over: the host's proxy settings (the distro has its own network), and Grok Build's newest is read from this computer's channel setting. Kinds with no command of their own (Goose, mu) show nothing, as on the host. | [`cliupdate_wsl.go`](../../internal/agent/cliupdate_wsl.go), [`cliupdate.go`](../../internal/agent/cliupdate.go) |
|
||||
| Settings tuned from use | Usage › Context's "Tuned for you" advises, per agent, the settings that would have spent the fewest tokens on the user's own calls of the range, and puts one in on a click. Package `tune` replays the calls `sessions.Calls` reads from the agents' session files under each candidate value (`Compact`, `CacheTTL`), each model's tokens weighed at what magpie bills them where the agent asked for a model magpie wrote (a provider/model id resolves as the gateway resolves it and is weighed at that provider's price, `pricedWeights`, so a Claude model on Copilot has its 1-hour cache write at the 5-minute one Copilot bills, #3435), else at its maker's list ratios (`tune.WeightsFor`); `tuneOf` picks the agents and models (Claude Code per model, Codex pooled). `TuneRead`, `TuneApply` and `TuneUndo` know where each setting lives: Claude Code's `modelSettings.<model>.autoCompactWindow` (where its `/autocompact` saves), `promptCacheTtl` and `subagentPromptCacheTtl` in `~/.claude/settings.json`. Where Codex compacts, and Claude Code wherever magpie's own window is what it runs at, is one value with Long conversations in the agents' settings sheet (`settings.CompactAt`/`FullContext`, source `long`; 7eleven on Discord): the card reads it, Use sets it through `provider.SetCompactAt`, and Sync writes it into each agent's config as it does for the sheet; the note says it is Long conversations, shared by Codex and Claude Code (`compact-one-value.test.cjs`). The advice is weighed by tokens alone: it is labelled "Fewest tokens", and a compaction window it would change says it doesn't measure how well the agent keeps the task after a compaction, and that a lower window compacts more often (#1854, `context-tune.test.cjs`). A compaction row's "Other window…" opens the app menu with every value of the curve, each with its estimated tokens against the setting now (fewer or more, the setting itself marked "Your setting now", hayden4608 on Discord), "Fewest tokens" beside the leanest, and about how many compactions it would have made (`Point.compacts`, from the same replay), and puts the one picked in like Use (#1860). An agent whose files time its compactions also has their wait weighed (HirotaNagai on X): Claude Code's `compact_boundary` line says `compactMetadata.durationMs`, which `sessions` puts on the first call after it, and Codex compacts by a call of its own (the record a `compacted` line names, in rollouts since 2026-09), whose time is the compaction's (`Call.Compact`; an older rollout's compaction has no call and stays untimed). With 3 or more timed for a model (`minTimed`), `Facts.took` is their median seconds, each window says its wait (`Point.wait`, its compactions × `took`), and the row says what a compaction took, the wait at the advice against the window now, and the cheaper window the advice passed over for waiting longer (`Compaction.cheapest`, `wait_cheapest`) when it saves 3% or more; the advice is labelled "Tokens + wait", its caveat says tokens and waiting only, and the picker says each window's wait with "Fewest tokens" on the cheapest (`context-tune.test.cjs`). An agent or model with fewer timed reads and is advised as before. | [`internal/tune`](../../internal/tune/tune.go), [`tune.go`](../../internal/agent/tune.go), [`internal/gui/tune.go`](../../internal/gui/tune.go) |
|
||||
|
||||
+23
-3
@@ -894,8 +894,12 @@ func wslFound(d distro) bool {
|
||||
}
|
||||
|
||||
// wslKept is whether magpie keeps a distro it probed: one of wslKinds is
|
||||
// there, or the Copilot CLI's folder, whose sign-in it reads (#723).
|
||||
func wslKept(d distro) bool { return wslFound(d) || d.Has["dir:"+wslCopilotDir] }
|
||||
// there, or the Copilot CLI's folder, whose sign-in it reads (#723), or
|
||||
// the Antigravity app's data, whose sessions it reads.
|
||||
func wslKept(d distro) bool {
|
||||
return wslFound(d) || d.Has["dir:"+wslCopilotDir] ||
|
||||
slices.ContainsFunc(wslAntigravityDirs, func(dir string) bool { return d.Has["dir:"+dir] })
|
||||
}
|
||||
|
||||
// ListsFor is whose model lists an agent's are (provider.CatalogFor): its
|
||||
// own id's, or, for one in a WSL distro, its Windows twin's (claude for
|
||||
@@ -1197,7 +1201,8 @@ func wslAgentsOf(ds []distro) []*Agent {
|
||||
return out
|
||||
}
|
||||
|
||||
// wslHomes are the distros agents (or the Copilot CLI's folder, wslKept)
|
||||
// wslHomes are the distros agents (or the Copilot CLI's folder, or the
|
||||
// Antigravity app's data, wslKept)
|
||||
// were found in, each user's home as magpie
|
||||
// opens it, for internal/sessions to read their sessions in; none off
|
||||
// Windows. A stopped distro's is its home as last probed.
|
||||
@@ -1235,6 +1240,18 @@ func wslAnswered() bool {
|
||||
// so a distro that has only it is kept as one agents are found in (#723).
|
||||
const wslCopilotDir = ".copilot"
|
||||
|
||||
// wslAntigravityDirs are the Antigravity app's data folders under a
|
||||
// distro's $HOME. The Windows app connected to a WSL distro runs its
|
||||
// language server there (`$HOME/.antigravity-server/bin/<version>/
|
||||
// language_server`, started through wsl.exe with --app_data_dir
|
||||
// antigravity, Antigravity 2.x's dist/wsl.js), which keeps the
|
||||
// conversations in the distro's ~/.gemini/antigravity, not Windows'
|
||||
// (@guyng35955 on X: no usage for Antigravity connected to WSL Ubuntu).
|
||||
// Not an agent magpie sets up, but sessions it reads
|
||||
// (sessions.wslAgents), so a distro that has only them is kept as one
|
||||
// agents are found in.
|
||||
var wslAntigravityDirs = []string{".gemini/antigravity", ".gemini/antigravity-insiders"}
|
||||
|
||||
// copilotWSLDirs are the Copilot CLI's folders, as magpie opens them (where
|
||||
// a link leads, #4502), in the running distros it was found in, for
|
||||
// provider to read its sign-in in; none off Windows. A stopped distro is
|
||||
@@ -1763,6 +1780,9 @@ var wslProbeScript = sync.OnceValue(func() string {
|
||||
}
|
||||
}
|
||||
s += `[ -d "$HOME/` + wslCopilotDir + `" ] && echo dir:` + wslCopilotDir + `; `
|
||||
for _, dir := range wslAntigravityDirs {
|
||||
s += `[ -d "$HOME/` + dir + `" ] && echo dir:` + dir + `; `
|
||||
}
|
||||
// where each agent folder that leads elsewhere leads (distro.open):
|
||||
// "link:.codex /mnt/c/Users/me/.codex", or "link:.codex" alone where
|
||||
// readlink -f couldn't say
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A distro with no agent magpie sets up, only the data of the Antigravity
|
||||
// app connected to it from Windows (its language server runs there and
|
||||
// keeps ~/.gemini/antigravity in the distro; @guyng35955 on X), is kept,
|
||||
// so internal/sessions reads its conversations; one with neither isn't.
|
||||
func TestWSLAntigravityHome(t *testing.T) {
|
||||
syncHome(t)
|
||||
for _, dir := range []string{".gemini/antigravity", ".gemini/antigravity-insiders"} {
|
||||
if want := `[ -d "$HOME/` + dir + `" ] && echo dir:` + dir + `; `; !strings.Contains(wslProbeScript(), want) {
|
||||
t.Fatalf("the probe doesn't look for %s:\n%s", dir, wslProbeScript())
|
||||
}
|
||||
}
|
||||
root := t.TempDir()
|
||||
t.Cleanup(FakeWSL(
|
||||
map[string]string{"Ubuntu": "home:/home/me\ndir:.gemini/antigravity\n", "Debian": "home:/home/me\n"},
|
||||
map[string]string{"Ubuntu": root, "Debian": t.TempDir()}))
|
||||
|
||||
hs := wslHomes()
|
||||
if len(hs) != 1 || hs[0].Distro != "Ubuntu" || hs[0].Home != filepath.Join(root, "home", "me") || !hs[0].Running {
|
||||
t.Fatalf("homes %+v, want Ubuntu's alone", hs)
|
||||
}
|
||||
if len(wslAgents()) != 0 {
|
||||
t.Fatalf("the Antigravity app's data made an agent row: %v", wslAgents())
|
||||
}
|
||||
}
|
||||
+20
-13
@@ -14,7 +14,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/dirent"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// Antigravity CLI's (agy's) conversations, on the Sessions page (RickyWei on
|
||||
@@ -74,7 +73,11 @@ type agySummaryRead struct {
|
||||
}
|
||||
|
||||
// agySummariesOf are the rows of the conversation_summaries.db in dir.
|
||||
func agySummariesOf(dir string) map[string]agySummary {
|
||||
func agySummariesOf(dir string) map[string]agySummary { return agySummariesOn(dir, runtime.GOOS) }
|
||||
|
||||
// agySummariesOn is agySummariesOf with the folders the rows name read as
|
||||
// goos names them: "linux" for a WSL distro's, read from Windows.
|
||||
func agySummariesOn(dir, goos string) map[string]agySummary {
|
||||
path := filepath.Join(dir, "conversation_summaries.db")
|
||||
rev := ""
|
||||
for _, p := range []string{path, path + "-wal"} {
|
||||
@@ -90,7 +93,7 @@ func agySummariesOf(dir string) map[string]agySummary {
|
||||
if seen && was.rev == rev {
|
||||
return was.rows
|
||||
}
|
||||
rows, ok := readAgySummaries(path)
|
||||
rows, ok := readAgySummaries(path, goos)
|
||||
if !ok {
|
||||
return was.rows
|
||||
}
|
||||
@@ -103,18 +106,21 @@ func agySummariesOf(dir string) map[string]agySummary {
|
||||
|
||||
// readAgySummaries opens the database for the one read and closes it: it
|
||||
// is read again only when it changed.
|
||||
func readAgySummaries(path string) (map[string]agySummary, bool) {
|
||||
db, err := provider.OpenReadOnly(path)
|
||||
func readAgySummaries(path, goos string) (map[string]agySummary, bool) {
|
||||
db, done, err := openAppStore(path)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
defer db.Close()
|
||||
return agyRows(db)
|
||||
defer done()
|
||||
return agyRowsOn(db, goos)
|
||||
}
|
||||
|
||||
// agyRows reads the rows; a database made before preview was a column is
|
||||
// read without it.
|
||||
func agyRows(db *sql.DB) (map[string]agySummary, bool) {
|
||||
func agyRows(db *sql.DB) (map[string]agySummary, bool) { return agyRowsOn(db, runtime.GOOS) }
|
||||
|
||||
// agyRowsOn is agyRows with the folders read as goos names them.
|
||||
func agyRowsOn(db *sql.DB, goos string) (map[string]agySummary, bool) {
|
||||
rows, err := db.Query("SELECT conversation_id, title, preview, workspace_uris, last_modified_time FROM conversation_summaries")
|
||||
if err != nil {
|
||||
rows, err = db.Query("SELECT conversation_id, title, '', workspace_uris, last_modified_time FROM conversation_summaries")
|
||||
@@ -135,7 +141,7 @@ func agyRows(db *sql.DB) (map[string]agySummary, bool) {
|
||||
json.Unmarshal([]byte(ws.String), &uris)
|
||||
s := agySummary{Title: t.String, Preview: p.String, Last: agyTime(last)}
|
||||
for _, u := range uris {
|
||||
if s.Cwd = agyFolder(u, runtime.GOOS); s.Cwd != "" {
|
||||
if s.Cwd = agyFolder(u, goos); s.Cwd != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -211,18 +217,19 @@ func agyTranscripts(dir string) []file {
|
||||
// agyFiles are agy's conversations on this computer, each with its row of
|
||||
// conversation_summaries.db: rev is that row, so a title agy writes after
|
||||
// the transcript reads the conversation again, and only that one.
|
||||
func agyFiles() []file { return agyFilesIn(AgyDir()) }
|
||||
func agyFiles() []file { return agyFilesIn(AgyDir(), runtime.GOOS) }
|
||||
|
||||
// agyFilesIn is agyFiles of the agy data folder dir. A conversation with a
|
||||
// agyFilesIn is agyFiles of the agy data folder dir, whose rows name
|
||||
// folders as goos does. A conversation with a
|
||||
// row and no transcript (#1718: agy keeps each one's
|
||||
// steps in conversations/<id>.db too, protobuf this doesn't read) is
|
||||
// listed from its row alone: its title, folder and time, and no tokens.
|
||||
func agyFilesIn(dir string) []file {
|
||||
func agyFilesIn(dir, goos string) []file {
|
||||
if !Reads("agy") {
|
||||
return nil
|
||||
}
|
||||
out := agyTranscripts(dir)
|
||||
rows := agySummariesOf(dir)
|
||||
rows := agySummariesOn(dir, goos)
|
||||
if len(out) == 0 && len(rows) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/dirent"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// The Antigravity app's (the desktop IDE's, agent "antigravity") own
|
||||
@@ -82,19 +82,26 @@ func antigravityConversations() string {
|
||||
// have their own prefix so a UUID present in both stores is two sessions
|
||||
// with separate summaries and call ids. Stable's existing ids stay the same.
|
||||
func antigravityFiles() []file {
|
||||
out := antigravityFilesIn(antigravityConversations())
|
||||
insiders := antigravityFilesIn(filepath.Join(AntigravityInsidersDir(), "conversations"))
|
||||
for i := range insiders {
|
||||
insiders[i].key = "antigravity:insiders-" + strings.TrimPrefix(insiders[i].key, "antigravity:")
|
||||
return append(antigravityFilesIn(antigravityConversations(), runtime.GOOS),
|
||||
antigravityInsiders(filepath.Join(AntigravityInsidersDir(), "conversations"), runtime.GOOS)...)
|
||||
}
|
||||
|
||||
// antigravityInsiders are the Insiders app's conversation databases in dir,
|
||||
// keyed apart from stable's.
|
||||
func antigravityInsiders(dir, goos string) []file {
|
||||
out := antigravityFilesIn(dir, goos)
|
||||
for i := range out {
|
||||
out[i].key = "antigravity:insiders-" + strings.TrimPrefix(out[i].key, "antigravity:")
|
||||
}
|
||||
return append(out, insiders...)
|
||||
return out
|
||||
}
|
||||
|
||||
// antigravityFilesIn are the conversation databases in dir. A file's size
|
||||
// and time are the database's and its write-ahead log's together, so a
|
||||
// write that is in the log alone still reads the conversation again; rev
|
||||
// is its summary row, so a title the app gives it later does too.
|
||||
func antigravityFilesIn(dir string) []file {
|
||||
// is its summary row, so a title the app gives it later does too. The
|
||||
// row's folders are read as goos names them ("linux" in a WSL distro).
|
||||
func antigravityFilesIn(dir, goos string) []file {
|
||||
if !Reads("antigravity") {
|
||||
return nil
|
||||
}
|
||||
@@ -102,7 +109,7 @@ func antigravityFilesIn(dir string) []file {
|
||||
if len(entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
rows := agySummariesOf(filepath.Dir(dir))
|
||||
rows := agySummariesOn(filepath.Dir(dir), goos)
|
||||
var out []file
|
||||
for _, e := range entries {
|
||||
id, ok := strings.CutSuffix(e.Name(), ".db")
|
||||
@@ -148,11 +155,11 @@ var errAgApp = errors.New("antigravity: unreadable metadata")
|
||||
// A call whose response id came before is the later step of that response,
|
||||
// and replaces it.
|
||||
func antigravityRead(path string) ([]agAppCall, error) {
|
||||
db, err := provider.OpenReadOnly(path)
|
||||
db, done, err := openAppStore(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer db.Close()
|
||||
defer done()
|
||||
tx, err := db.BeginTx(context.Background(), &sql.TxOptions{ReadOnly: true})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -345,8 +345,9 @@ func callSourcesWith(codex []file) []file { return callSourcesInto(nil, codex) }
|
||||
func callSourcesInto(out []file, codex []file) []file {
|
||||
lists := append(callFileLists(codex), openCodeCallFiles(), zcodeCallFiles(), dshCallFiles(),
|
||||
minimaxCallFiles(), kimiCallFiles(), wslFiles("kimi"), piCallFiles(), codebuddyCallFiles(), workbuddyAIFiles(),
|
||||
agyCallFiles(), // #2097
|
||||
antigravityCallFiles(), // #2190
|
||||
agyCallFiles(), // #2097
|
||||
antigravityCallFiles(), // #2190
|
||||
wslFiles("antigravity"), wslCallFiles("agy"), // @guyng35955 on X
|
||||
devinCallFiles(), // aohan0905 on X
|
||||
workbuddyCallFiles(), grokCallFiles()) // #4423
|
||||
if out == nil {
|
||||
|
||||
@@ -13,8 +13,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// Antigravity CLI's (agy's) calls (#2097, parkavenue9639: a call agy made
|
||||
@@ -61,16 +59,22 @@ func AgyDir() string {
|
||||
func agyCallFiles() []file {
|
||||
out := agyTranscripts(AgyDir())
|
||||
for i := range out {
|
||||
for _, p := range agyDBFiles(out[i].path) {
|
||||
if fi, err := os.Stat(p); err == nil {
|
||||
out[i].size += fi.Size()
|
||||
if fi.ModTime().After(out[i].mod.Time()) {
|
||||
out[i].mod = modOf(fi.ModTime())
|
||||
}
|
||||
agyCallStat(&out[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// agyCallStat adds the transcript f's conversation database and its
|
||||
// write-ahead log to f's size and time, as a call source.
|
||||
func agyCallStat(f *file) {
|
||||
for _, p := range agyDBFiles(f.path) {
|
||||
if fi, err := os.Stat(p); err == nil {
|
||||
f.size += fi.Size()
|
||||
if fi.ModTime().After(f.mod.Time()) {
|
||||
f.mod = modOf(fi.ModTime())
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// agyConversationDB is the database of the conversation whose transcript
|
||||
@@ -94,11 +98,11 @@ func agyStepModels(path string) map[int]string {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return nil
|
||||
}
|
||||
db, err := provider.OpenReadOnly(path)
|
||||
db, done, err := openAppStore(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer db.Close()
|
||||
defer done()
|
||||
tx, err := db.BeginTx(context.Background(), &sql.TxOptions{ReadOnly: true})
|
||||
if err != nil {
|
||||
return nil
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/yetone/magpie/internal/appdir"
|
||||
"github.com/yetone/magpie/internal/lazyre"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// Cursor's CLI (cursor-agent) keeps a chat in a folder of its own under its
|
||||
@@ -210,6 +211,30 @@ func OpenUntouched(path string) (db *sql.DB, closeDB func(), err error) {
|
||||
return db, func() { db.Close(); os.RemoveAll(tmp) }, nil
|
||||
}
|
||||
|
||||
// openAppStore opens another app's SQLite database at path to read it:
|
||||
// read only, in place; or, in a WSL distro read through \\wsl.localhost
|
||||
// (or \\wsl$), as OpenUntouched does. SQLite can't take the locks a WAL
|
||||
// database needs over that share, so an open in place there answers
|
||||
// SQLITE_BUSY, every time, after its busy_timeout (the Antigravity app
|
||||
// connected to WSL, @guyng35955 on X; tried on Windows 11). done closes it.
|
||||
func openAppStore(path string) (db *sql.DB, done func(), err error) {
|
||||
if onWSLShare(path) {
|
||||
return OpenUntouched(path)
|
||||
}
|
||||
db, err = provider.OpenReadOnly(path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return db, func() { db.Close() }, nil
|
||||
}
|
||||
|
||||
// onWSLShare is whether path is in a WSL distro, read through Windows'
|
||||
// share of it.
|
||||
func onWSLShare(path string) bool {
|
||||
p := strings.ToLower(strings.ReplaceAll(path, `\`, "/"))
|
||||
return strings.HasPrefix(p, "//wsl.localhost/") || strings.HasPrefix(p, "//wsl$/")
|
||||
}
|
||||
|
||||
// openSQLite opens the SQLite database at p, with query as its URI's.
|
||||
func openSQLite(p, query string) (*sql.DB, error) {
|
||||
u := url.URL{Scheme: "file", Path: filepath.ToSlash(p), RawQuery: query}
|
||||
|
||||
@@ -989,7 +989,7 @@ func allFilesWith(kept *filesKept, zcode func() []file) []file {
|
||||
filesHook()
|
||||
}
|
||||
lists := callFileLists(codexFiles())
|
||||
lists = append(lists, openCodeFiles(), piFiles(), raftFiles(), cindyFiles(), wslFiles("pi", "raft", "omp", "kimi"), zcode())
|
||||
lists = append(lists, openCodeFiles(), piFiles(), raftFiles(), cindyFiles(), wslFiles("pi", "raft", "omp", "kimi", "antigravity", "agy"), zcode())
|
||||
lists = append(lists, dshFiles(), clineFiles(), ccFiles("qoder", QoderDir("qoder")), ccFiles("qoder-cn", QoderDir("qoder-cn")),
|
||||
grokFiles(), workbuddyFiles(), workbuddyAIFiles(), codebuddyFiles(), droidFiles(), ompFiles(), cursorFiles(), hermesFiles(), almaFiles(), kimiFiles(), agyFiles(),
|
||||
antigravityFiles()) // #2190
|
||||
|
||||
@@ -22,6 +22,9 @@ import (
|
||||
// sets; this one can't import it). Claude Code's, Codex's, Pi's and omp's
|
||||
// session files there are read as this computer's are, each session marked
|
||||
// with its distro (Session.WSL) and resumed through wsl.exe (wslResume).
|
||||
// So are agy's, and the Antigravity app's when it is connected to the
|
||||
// distro: its language server runs there and keeps the conversations in
|
||||
// the distro's ~/.gemini/antigravity (@guyng35955 on X).
|
||||
//
|
||||
// Reading over \\wsl.localhost is slow, and looking at a stopped distro's
|
||||
// files starts it. So the distros' files are listed behind, at most every
|
||||
@@ -82,6 +85,9 @@ var wslAgents = []struct{ agent, dir string }{
|
||||
{"raft", ".slock"},
|
||||
{"omp", filepath.Join(".omp", "agent")},
|
||||
{"kimi", ".kimi-code"},
|
||||
{"antigravity", filepath.Join(".gemini", "antigravity")},
|
||||
{"antigravity", filepath.Join(".gemini", "antigravity-insiders")},
|
||||
{"agy", filepath.Join(".gemini", "antigravity-cli")},
|
||||
}
|
||||
|
||||
// wslScan lists the session files under a distro's home.
|
||||
@@ -105,6 +111,20 @@ func wslScan(h WSLHome) []file {
|
||||
out = append(out, ompFilesIn(dir)...)
|
||||
case "kimi":
|
||||
out = append(out, kimiFilesIn(filepath.Join(dir, "sessions"))...)
|
||||
case "antigravity":
|
||||
// the rows name the distro's own folders (file:///home/…)
|
||||
conv := filepath.Join(dir, "conversations")
|
||||
if filepath.Base(a.dir) == "antigravity-insiders" {
|
||||
if !sameDir(dir, AntigravityInsidersDir()) {
|
||||
out = append(out, antigravityInsiders(conv, "linux")...)
|
||||
}
|
||||
} else if !sameDir(dir, AntigravityAppDir()) {
|
||||
out = append(out, antigravityFilesIn(conv, "linux")...)
|
||||
}
|
||||
case "agy":
|
||||
if !sameDir(dir, AgyDir()) {
|
||||
out = append(out, agyFilesIn(dir, "linux")...)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
@@ -118,6 +138,34 @@ type wslEntry struct {
|
||||
Main bool `json:"main,omitempty"`
|
||||
Size int64 `json:"size"`
|
||||
Mod time.Time `json:"mod"`
|
||||
// ReadOnly: the Antigravity app's conversations, which magpie lists
|
||||
// and never moves or deletes
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
// Agy and Rev: an agy or Antigravity conversation's summary row and
|
||||
// what tells it changed (file.more's agy and rev)
|
||||
Agy *agySummary `json:"agy,omitempty"`
|
||||
Rev string `json:"rev,omitempty"`
|
||||
// Calls is an agy transcript's size and time as a call source, its
|
||||
// conversation's database taken in (agyCallStat); nil for a file that
|
||||
// isn't one (a conversation listed from its row alone)
|
||||
Calls *wslStat `json:"calls,omitempty"`
|
||||
}
|
||||
|
||||
// wslStat is a file's size and time.
|
||||
type wslStat struct {
|
||||
Size int64 `json:"size"`
|
||||
Mod time.Time `json:"mod"`
|
||||
}
|
||||
|
||||
// wslEntryOf is f as a listing keeps it.
|
||||
func wslEntryOf(f file) wslEntry {
|
||||
e := wslEntry{Agent: f.agent, Key: f.key, Path: f.path, Main: f.main, Size: f.size, Mod: f.mod.Time(), ReadOnly: f.readOnly, Agy: f.m().agy, Rev: f.m().rev}
|
||||
if f.agent == "agy" && !agyRowOnly(f.path) {
|
||||
c := file{path: f.path, size: f.size, mod: f.mod}
|
||||
agyCallStat(&c)
|
||||
e.Calls = &wslStat{Size: c.size, Mod: c.mod.Time()}
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// wslListing is a distro's files as last listed.
|
||||
@@ -150,7 +198,14 @@ func wslListPath() string { return filepath.Join(filepath.Dir(CachePath()), "ses
|
||||
// wslFiles are the session files of the given agents in the WSL distros,
|
||||
// as last listed; a listing is started behind when the last is older than
|
||||
// wslRelist.
|
||||
func wslFiles(agents ...string) []file {
|
||||
func wslFiles(agents ...string) []file { return wslFilesAs(false, agents...) }
|
||||
|
||||
// wslCallFiles are wslFiles as call sources: an agy transcript with its
|
||||
// conversation's database taken into its size and time, as agyCallFiles
|
||||
// has it, and none of agy's conversations listed from their row alone.
|
||||
func wslCallFiles(agents ...string) []file { return wslFilesAs(true, agents...) }
|
||||
|
||||
func wslFilesAs(calls bool, agents ...string) []file {
|
||||
agents = slices.DeleteFunc(slices.Clone(agents), func(a string) bool { return !Reads(a) })
|
||||
if len(agents) == 0 || !wslLooking() {
|
||||
return nil
|
||||
@@ -211,9 +266,21 @@ func wslFiles(agents ...string) []file {
|
||||
cold := !l.Running || !up[n]
|
||||
in := &fileMore{wsl: n} // the distro's files share it
|
||||
for _, e := range l.Files {
|
||||
if want[e.Agent] {
|
||||
out = append(out, file{agent: e.Agent, key: e.Key, path: e.Path, main: e.Main, size: e.Size, mod: modOf(e.Mod), more: in, cold: cold})
|
||||
if !want[e.Agent] {
|
||||
continue
|
||||
}
|
||||
f := file{agent: e.Agent, key: e.Key, path: e.Path, main: e.Main, size: e.Size, mod: modOf(e.Mod), more: in, cold: cold, readOnly: e.ReadOnly}
|
||||
if calls && e.Agent == "agy" {
|
||||
if e.Calls == nil {
|
||||
continue
|
||||
}
|
||||
f.size, f.mod = e.Calls.Size, modOf(e.Calls.Mod)
|
||||
}
|
||||
if e.Agy != nil || e.Rev != "" {
|
||||
m := f.w()
|
||||
m.agy, m.rev = e.Agy, e.Rev
|
||||
}
|
||||
out = append(out, f)
|
||||
}
|
||||
}
|
||||
return out
|
||||
@@ -244,7 +311,7 @@ func wslList(gen uint64, done chan struct{}) {
|
||||
}
|
||||
l := &wslListing{Home: h.Home, Running: true, Files: []wslEntry{}}
|
||||
for _, f := range wslScan(h) {
|
||||
l.Files = append(l.Files, wslEntry{Agent: f.agent, Key: f.key, Path: f.path, Main: f.main, Size: f.size, Mod: f.mod.Time()})
|
||||
l.Files = append(l.Files, wslEntryOf(f))
|
||||
}
|
||||
lists[h.Distro] = l
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package sessions
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// wslAntigravity puts an Antigravity app conversation, with its summary
|
||||
// row naming a folder in the distro, and agy's three conversations in the
|
||||
// distro's home, as the Windows app connected to WSL leaves them: its
|
||||
// language server runs in the distro, so ~/.gemini is the distro's.
|
||||
func wslAntigravity(t *testing.T, home string) (id string) {
|
||||
t.Helper()
|
||||
id = "37c3c786-9a11-44be-97df-b8fc1ccebc78"
|
||||
antigravityFixture(t, home, id)
|
||||
db, err := sql.Open("sqlite", filepath.Join(home, ".gemini", "antigravity", "conversation_summaries.db")+"?_pragma=journal_mode(WAL)")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
if _, err := db.Exec(antigravitySummariesSchema); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := db.Exec("INSERT INTO conversation_summaries (conversation_id, title, preview, step_count, last_modified_time, workspace_uris, status, project_id, last_user_input_time, app_data_dir) VALUES (?, 'Login redirect fix', 'Login redirect fix', 2, '2026-11-07 00:12:46.60116+00:00', '[\"file:///home/me/site\"]', 'CASCADE_RUN_STATUS_IDLE', 'default-project', '2026-11-07 00:12:43.784481+00:00', 'antigravity')", id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
copyTree(t, "testdata/agy-sessions", filepath.Join(home, ".gemini", "antigravity-cli"))
|
||||
return id
|
||||
}
|
||||
|
||||
// @guyng35955 on X: the Antigravity app on Windows connected to a WSL
|
||||
// Ubuntu showed no usage. Its conversations, in the distro's
|
||||
// ~/.gemini/antigravity, are listed with the distro, read only, under the
|
||||
// distro's own folder (not a Windows path), and their calls count; so do
|
||||
// agy's in the distro's ~/.gemini/antigravity-cli.
|
||||
func TestWSLAntigravityApp(t *testing.T) {
|
||||
inZone(t, 0)
|
||||
home, _ := wslDistro(t)
|
||||
id := wslAntigravity(t, home)
|
||||
|
||||
ss := List(0)
|
||||
s := find(t, ss, "antigravity", id)
|
||||
if s.WSL != "Ubuntu" || s.Title != "Login redirect fix" || s.Cwd != "/home/me/site" || !s.ReadOnly || s.Resume != "" || s.Tokens.zero() {
|
||||
t.Fatalf("the distro's Antigravity conversation: %+v", s)
|
||||
}
|
||||
if n := count(ss, "agy"); n != 3 {
|
||||
t.Fatalf("want agy's 3 conversations in the distro, got %d", n)
|
||||
}
|
||||
two := find(t, ss, "agy", agyTwoTurns)
|
||||
if two.WSL != "Ubuntu" || two.Title != "Hello from the fake." || two.Cwd != "/work/proj" || two.Tokens.zero() {
|
||||
t.Fatalf("the distro's agy conversation: %+v", two)
|
||||
}
|
||||
if want := `wsl.exe -d 'Ubuntu' --cd '/work/proj' -e sh -lc 'exec ${SHELL:-sh} -lic ''agy --conversation ` + agyTwoTurns + `'''`; two.Resume != want {
|
||||
t.Fatalf("agy resume\n got %s\nwant %s", two.Resume, want)
|
||||
}
|
||||
|
||||
want, err := antigravityRead(filepath.Join(home, ".gemini", "antigravity", "conversations", id+".db"))
|
||||
if err != nil || len(want) == 0 {
|
||||
t.Fatalf("the fixture's calls: %v %v", want, err)
|
||||
}
|
||||
calls := map[string]int{}
|
||||
for _, c := range Calls(time.Time{}) {
|
||||
calls[c.Agent]++
|
||||
}
|
||||
if calls["antigravity"] != len(want) {
|
||||
t.Fatalf("the distro's Antigravity calls: %d, want %d (%v)", calls["antigravity"], len(want), calls)
|
||||
}
|
||||
if calls["agy"] == 0 {
|
||||
t.Fatalf("the distro's agy calls aren't counted: %v", calls)
|
||||
}
|
||||
|
||||
// magpie starts again: the listing kept on disk is read first, and
|
||||
// carries the conversation's row, so it keeps its name and folder
|
||||
wslSettle()
|
||||
Saved()
|
||||
Reset()
|
||||
s = find(t, List(0), "antigravity", id)
|
||||
if s.WSL != "Ubuntu" || s.Title != "Login redirect fix" || s.Cwd != "/home/me/site" || !s.ReadOnly {
|
||||
t.Fatalf("after a restart: %+v", s)
|
||||
}
|
||||
}
|
||||
|
||||
// A distro whose ~/.gemini/antigravity is this computer's own (a link to
|
||||
// Windows' folder, which distro.open opens there) is read once, as this
|
||||
// computer's: its calls aren't counted twice.
|
||||
func TestWSLAntigravityLinkedHomeOnce(t *testing.T) {
|
||||
home, _ := wslDistro(t)
|
||||
own, _ := os.UserHomeDir()
|
||||
id := "37c3c786-9a11-44be-97df-b8fc1ccebc78"
|
||||
antigravityFixture(t, own, id)
|
||||
WSLHomes = func() []WSLHome {
|
||||
return []WSLHome{{Distro: "Ubuntu", Home: home, Running: true, Open: func(p string) string {
|
||||
if rel, err := filepath.Rel(filepath.Join(home, ".gemini"), p); err == nil && filepath.IsLocal(rel) {
|
||||
return filepath.Join(own, ".gemini", rel)
|
||||
}
|
||||
return p
|
||||
}}}
|
||||
}
|
||||
Reset()
|
||||
n := 0
|
||||
for _, s := range List(0) {
|
||||
if s.Agent == "antigravity" {
|
||||
n++
|
||||
if s.WSL != "" {
|
||||
t.Fatalf("listed as the distro's: %+v", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
if n != 1 {
|
||||
t.Fatalf("want the conversation once, got %d", n)
|
||||
}
|
||||
}
|
||||
|
||||
// A database in a distro is read through Windows' share of it, where an
|
||||
// open in place answers SQLITE_BUSY (openAppStore), so it is read as
|
||||
// OpenUntouched does; this computer's own, and a distro's folder that
|
||||
// leads to Windows' drive, are read in place.
|
||||
func TestOnWSLShare(t *testing.T) {
|
||||
for p, want := range map[string]bool{
|
||||
`\\wsl.localhost\Ubuntu\home\me\.gemini\antigravity\conversation_summaries.db`: true,
|
||||
`\\WSL.LOCALHOST\Ubuntu-24.04\home\me\x.db`: true,
|
||||
`\\wsl$\Ubuntu\home\me\x.db`: true,
|
||||
`//wsl.localhost/Ubuntu/home/me/x.db`: true,
|
||||
`C:\Users\me\.gemini\antigravity\conversation_summaries.db`: false,
|
||||
`\\server\wsl.localhost\x.db`: false,
|
||||
`/home/me/.gemini/antigravity/conversation_summaries.db`: false,
|
||||
} {
|
||||
if got := onWSLShare(p); got != want {
|
||||
t.Errorf("onWSLShare(%s) = %v, want %v", p, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user