Skip to content

The agent that grows with you

fix(desktop): route remote file requests by connection

Jakub Wolniewicz0b62c27bf13b
diff --git a/apps/desktop/src/lib/desktop-git.test.ts b/apps/desktop/src/lib/desktop-git.test.ts
index a9452766011..7dd23560798 100644
--- a/apps/desktop/src/lib/desktop-git.test.ts
+++ b/apps/desktop/src/lib/desktop-git.test.ts
@@ -1,5 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { setApiRequestConnection } from '@/hermes'
import { $connection } from '@/store/session'
import { desktopGit } from './desktop-git'
@@ -37,6 +38,7 @@ describe('desktop git facade', () => {
})
afterEach(() => {
+ setApiRequestConnection(null)
vi.unstubAllGlobals()
vi.clearAllMocks()
$connection.set(null)
@@ -90,6 +92,27 @@ describe('desktop git facade', () => {
})
})
+ it('routes remote git reads and writes through the active registered gateway', async () => {
+ setApiRequestConnection('remote-user')
+ $connection.set({ mode: 'remote', profile: 'default' } as never)
+
+ await desktopGit()?.repoStatus('/srv/work')
+ await desktopGit()?.review.stage('/srv/work', 'a.txt')
+
+ expect(api).toHaveBeenCalledWith({
+ connectionId: 'remote-user',
+ path: '/api/git/status?path=%2Fsrv%2Fwork',
+ profile: 'default'
+ })
+ expect(api).toHaveBeenCalledWith({
+ body: { file: 'a.txt', path: '/srv/work' },
+ connectionId: 'remote-user',
+ method: 'POST',
+ path: '/api/git/review/stage',
+ profile: 'default'
+ })
+ })
+
it('sends mutations as POST bodies on a remote gateway', async () => {
$connection.set({ mode: 'remote' } as never)
diff --git a/apps/desktop/src/lib/desktop-git.ts b/apps/desktop/src/lib/desktop-git.ts
index 98f41fbf87e..98e4fee7179 100644
--- a/apps/desktop/src/lib/desktop-git.ts
+++ b/apps/desktop/src/lib/desktop-git.ts
@@ -7,6 +7,7 @@ import type {
HermesReviewList,
HermesReviewShipInfo
} from '@/global'
+import { hermesApi } from '@/hermes'
import { desktopFsProfile, isDesktopFsRemoteMode } from './desktop-fs'
@@ -25,7 +26,7 @@ function desktopApi<T>(path: string, body?: Record<string, unknown>): Promise<T>
throw new Error('Hermes Desktop bridge is unavailable')
}
- return desktop.api<T>(
+ return hermesApi<T>(
body ? { body, method: 'POST', path, profile: desktopFsProfile() } : { path, profile: desktopFsProfile() }
)
}