mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
fix(warp): discover Warp on Linux and Windows
Only the macOS group-container paths were tried, so Warp on Linux or Windows reported nothing unless WARP_DB_PATH was set. Adds the default locations from Warp's file-locations docs: $XDG_STATE_HOME/warp-terminal (and -preview) on Linux, %LOCALAPPDATA%\warp\Warp\data on Windows. Both variables join warp's cache fingerprint.
This commit is contained in:
parent
4f82716639
commit
46a521cc56
3 changed files with 32 additions and 3 deletions
|
|
@ -125,9 +125,19 @@ function warpDbPath(bundleId: string): string {
|
|||
)
|
||||
}
|
||||
|
||||
function getDbCandidates(dbPathOverride?: string): string[] {
|
||||
// Linux and Windows locations from Warp's file-locations docs; Linux Preview
|
||||
// appends -preview to the warp-terminal directory.
|
||||
export function getDbCandidates(dbPathOverride?: string, platform: string = process.platform): string[] {
|
||||
if (dbPathOverride) return [dbPathOverride]
|
||||
if (process.env['WARP_DB_PATH']) return [process.env['WARP_DB_PATH']]
|
||||
if (platform === 'win32') {
|
||||
const localAppData = process.env['LOCALAPPDATA'] || join(homedir(), 'AppData', 'Local')
|
||||
return [join(localAppData, 'warp', 'Warp', 'data', 'warp.sqlite')]
|
||||
}
|
||||
if (platform !== 'darwin') {
|
||||
const stateHome = process.env['XDG_STATE_HOME'] || join(homedir(), '.local', 'state')
|
||||
return [join(stateHome, 'warp-terminal', 'warp.sqlite'), join(stateHome, 'warp-terminal-preview', 'warp.sqlite')]
|
||||
}
|
||||
return [warpDbPath(WARP_STABLE_BUNDLE_ID), warpDbPath(WARP_PREVIEW_BUNDLE_ID)]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ export const PROVIDER_ENV_VARS: Record<string, string[]> = {
|
|||
grok: ['GROK_HOME'],
|
||||
grokbot: ['CODEBURN_GROKBOT_DIR', 'APPDATA'],
|
||||
crush: ['XDG_DATA_HOME', 'CRUSH_GLOBAL_DATA', 'LOCALAPPDATA'],
|
||||
warp: ['WARP_DB_PATH'],
|
||||
warp: ['WARP_DB_PATH', 'XDG_STATE_HOME', 'LOCALAPPDATA'],
|
||||
antigravity: ['CODEBURN_CACHE_DIR'],
|
||||
'kilo-code': ['XDG_DATA_HOME'],
|
||||
kimi: ['KIMI_SHARE_DIR', 'KIMI_MODEL_NAME'],
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { tmpdir } from 'os'
|
|||
import { createRequire } from 'node:module'
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { createWarpProvider } from '../../src/providers/warp.js'
|
||||
import { createWarpProvider, getDbCandidates } from '../../src/providers/warp.js'
|
||||
import { isSqliteAvailable } from '../../src/sqlite.js'
|
||||
import type { ParsedProviderCall } from '../../src/providers/types.js'
|
||||
|
||||
|
|
@ -507,3 +507,22 @@ skipUnlessSqlite('warp provider', () => {
|
|||
expect(calls[0]!.costIsEstimated).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('warp db locations', () => {
|
||||
const saved = { ...process.env }
|
||||
afterEach(() => { process.env = { ...saved } })
|
||||
|
||||
it('looks in the documented Linux and Windows locations', () => {
|
||||
delete process.env['WARP_DB_PATH']
|
||||
process.env['XDG_STATE_HOME'] = '/state'
|
||||
process.env['LOCALAPPDATA'] = 'C:\\Users\\me\\AppData\\Local'
|
||||
expect(getDbCandidates(undefined, 'linux')).toEqual([
|
||||
join('/state', 'warp-terminal', 'warp.sqlite'),
|
||||
join('/state', 'warp-terminal-preview', 'warp.sqlite'),
|
||||
])
|
||||
expect(getDbCandidates(undefined, 'win32')).toEqual([
|
||||
join('C:\\Users\\me\\AppData\\Local', 'warp', 'Warp', 'data', 'warp.sqlite'),
|
||||
])
|
||||
expect(getDbCandidates(undefined, 'darwin')[0]).toContain('Group Containers')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue