fix: RuntimeEnvironmentStoreError on orca cli `file open` (agent use case) (#4724)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
6379db5ecc
commit
db47575d18
|
|
@ -182,7 +182,7 @@ describe('RuntimeFileCommands', () => {
|
|||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('opens source control diffs through the renderer host', async () => {
|
||||
it('opens source control diffs through the renderer host (inheriting active runtime env)', async () => {
|
||||
const openDiff = vi.fn()
|
||||
const { commands } = createRuntimeFileCommands({ openDiff })
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ describe('RuntimeFileCommands', () => {
|
|||
'/repo/docs/readme.md',
|
||||
'docs/readme.md',
|
||||
true,
|
||||
'runtime-1'
|
||||
undefined
|
||||
)
|
||||
expect(result).toEqual({
|
||||
worktree: 'wt-1',
|
||||
|
|
@ -203,7 +203,7 @@ describe('RuntimeFileCommands', () => {
|
|||
})
|
||||
})
|
||||
|
||||
it('opens text files through the renderer host with the runtime owner', async () => {
|
||||
it('opens text files through the renderer host (inheriting active runtime env)', async () => {
|
||||
const openFile = vi.fn()
|
||||
const { commands } = createRuntimeFileCommands({ openFile })
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ describe('RuntimeFileCommands', () => {
|
|||
'wt-1',
|
||||
'/repo/docs/readme.md',
|
||||
'docs/readme.md',
|
||||
'runtime-1'
|
||||
undefined
|
||||
)
|
||||
expect(result).toEqual({
|
||||
worktree: 'wt-1',
|
||||
|
|
|
|||
|
|
@ -124,14 +124,14 @@ export type RuntimeFileCommandHost = {
|
|||
worktreeId: string,
|
||||
filePath: string,
|
||||
relativePath: string,
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string | null
|
||||
): void
|
||||
openDiff(
|
||||
worktreeId: string,
|
||||
filePath: string,
|
||||
relativePath: string,
|
||||
staged: boolean,
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string | null
|
||||
): void
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +184,13 @@ export class RuntimeFileCommands {
|
|||
return { worktree: worktree.id, relativePath, kind, opened: false }
|
||||
}
|
||||
const filePath = joinWorktreeRelativePath(worktree.path, relativePath)
|
||||
this.host.openFile(worktree.id, filePath, relativePath, this.host.getRuntimeId())
|
||||
// Why: the service's internal runtimeId is not a registered runtime env selector
|
||||
// (those live in orca-environments.json). Passing it caused Unknown environment
|
||||
// errors on content load for CLI-initiated opens (via files.open from orca cli
|
||||
// used by agents). Instead pass undefined so the renderer openFile falls back to
|
||||
// the current activeRuntimeEnvironmentId (or null), matching sidebar opens and
|
||||
// allowing correct routing for local vs remote envs.
|
||||
this.host.openFile(worktree.id, filePath, relativePath, undefined)
|
||||
return { worktree: worktree.id, relativePath, kind, opened: true }
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +209,8 @@ export class RuntimeFileCommands {
|
|||
? 'markdown'
|
||||
: 'text'
|
||||
const filePath = joinWorktreeRelativePath(worktree.path, relativePath)
|
||||
this.host.openDiff(worktree.id, filePath, relativePath, staged, this.host.getRuntimeId())
|
||||
// Why: see openMobileFile; avoid stamping internal runtimeId as runtimeEnvironmentId.
|
||||
this.host.openDiff(worktree.id, filePath, relativePath, staged, undefined)
|
||||
return { worktree: worktree.id, relativePath, kind, opened: true }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -790,14 +790,14 @@ type RuntimeNotifier = {
|
|||
worktreeId: string,
|
||||
filePath: string,
|
||||
relativePath: string,
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string | null
|
||||
): void
|
||||
openDiff?(
|
||||
worktreeId: string,
|
||||
filePath: string,
|
||||
relativePath: string,
|
||||
staged: boolean,
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string | null
|
||||
): void
|
||||
readMobileMarkdownTab?(worktreeId: string, tabId: string): Promise<RuntimeMarkdownReadTabResult>
|
||||
saveMobileMarkdownTab?(
|
||||
|
|
|
|||
|
|
@ -272,14 +272,14 @@ function registerRuntimeWindowLifecycle(
|
|||
closeSessionTab: (tabId, worktreeId) => send('ui:closeSessionTab', { tabId, worktreeId }),
|
||||
moveSessionTab: (worktreeId: string, move: RuntimeMobileSessionTabMove) =>
|
||||
send('ui:moveSessionTab', { worktreeId, ...move }),
|
||||
openFile: (worktreeId, filePath, relativePath, runtimeEnvironmentId) =>
|
||||
openFile: (worktreeId, filePath, relativePath, runtimeEnvironmentId?) =>
|
||||
send('ui:openFileFromMobile', {
|
||||
worktreeId,
|
||||
filePath,
|
||||
relativePath,
|
||||
runtimeEnvironmentId
|
||||
}),
|
||||
openDiff: (worktreeId, filePath, relativePath, staged, runtimeEnvironmentId) =>
|
||||
openDiff: (worktreeId, filePath, relativePath, staged, runtimeEnvironmentId?) =>
|
||||
send('ui:openDiffFromMobile', {
|
||||
worktreeId,
|
||||
filePath,
|
||||
|
|
|
|||
|
|
@ -2167,7 +2167,7 @@ export type PreloadApi = {
|
|||
worktreeId: string
|
||||
filePath: string
|
||||
relativePath: string
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}) => void
|
||||
) => () => void
|
||||
onOpenDiffFromMobile: (
|
||||
|
|
@ -2176,7 +2176,7 @@ export type PreloadApi = {
|
|||
filePath: string
|
||||
relativePath: string
|
||||
staged: boolean
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}) => void
|
||||
) => () => void
|
||||
onMobileMarkdownRequest: (
|
||||
|
|
|
|||
|
|
@ -2851,7 +2851,7 @@ const api = {
|
|||
worktreeId: string
|
||||
filePath: string
|
||||
relativePath: string
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}) => void
|
||||
): (() => void) => {
|
||||
const listener = (
|
||||
|
|
@ -2860,7 +2860,7 @@ const api = {
|
|||
worktreeId: string
|
||||
filePath: string
|
||||
relativePath: string
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}
|
||||
) => callback(data)
|
||||
ipcRenderer.on('ui:openFileFromMobile', listener)
|
||||
|
|
@ -2872,7 +2872,7 @@ const api = {
|
|||
filePath: string
|
||||
relativePath: string
|
||||
staged: boolean
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}) => void
|
||||
): (() => void) => {
|
||||
const listener = (
|
||||
|
|
@ -2882,7 +2882,7 @@ const api = {
|
|||
filePath: string
|
||||
relativePath: string
|
||||
staged: boolean
|
||||
runtimeEnvironmentId: string
|
||||
runtimeEnvironmentId?: string
|
||||
}
|
||||
) => callback(data)
|
||||
ipcRenderer.on('ui:openDiffFromMobile', listener)
|
||||
|
|
|
|||
Loading…
Reference in New Issue