The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): route relative remote artifacts to gateway download
Tekniumf9d05081d8f1
diff --git a/apps/desktop/src/app/artifacts/index.tsx b/apps/desktop/src/app/artifacts/index.tsxindex 73321f5ae78..3501369d77b 100644--- a/apps/desktop/src/app/artifacts/index.tsx+++ b/apps/desktop/src/app/artifacts/index.tsx@@ -276,7 +276,9 @@ export function ArtifactsView({ setStatusbarItemGroup: _setStatusbarItemGroup, .// lives on the gateway, not this disk). Opening that locally fails —// and an OAuth remote connection has no query token to build a download// URL. Fetch the bytes over the authenticated fs bridge instead.- if (isRemoteGateway() && /^file:/i.test(href)) {+ // Tilde/relative hrefs have no file URL form. Keep them gateway-owned:+ // expanding them on the client would target the wrong home or cwd.+ if (isRemoteGateway() && /^(?:file:|~\/|\.{1,2}\/)/i.test(href)) {await downloadGatewayMediaFile(href)returndiff --git a/apps/desktop/src/app/artifacts/remote-open.test.tsx b/apps/desktop/src/app/artifacts/remote-open.test.tsxnew file mode 100644index 00000000000..eac02ed5de2--- /dev/null+++ b/apps/desktop/src/app/artifacts/remote-open.test.tsx@@ -0,0 +1,36 @@+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { MemoryRouter } from 'react-router'+import { afterEach, expect, it, vi } from 'vitest'++import { $connection } from '@/store/session'++import { ArtifactsView } from './index'++vi.mock('@/hermes', async () => ({+ ...(await vi.importActual('@/hermes')),+ listAllProfileSessions: async () => ({ sessions: [{ id: 'artifact-session', title: 'Fixture' }] }),+ getAllSessionMessages: async () => ({ messages: [{ role: 'assistant', timestamp: 1000,+ content: '~/.hermes/memories/USER.md ./report.md ../parent.md' }] })+}))++afterEach(() => { cleanup(); $connection.set(null); vi.unstubAllGlobals() })++it('opens remote tilde and relative artifacts through their gateway without client path expansion', async () => {+ const saveGatewayFile = vi.fn().mockResolvedValue({ saved: true })+ const openExternal = vi.fn().mockRejectedValue(new Error('Invalid external URL'))+ vi.stubGlobal('hermesDesktop', { saveGatewayFile, openExternal })+ $connection.set({ isFullscreen: false, nativeOverlayWidth: 0, logs: [], windowButtonPosition: null, mode: 'remote', connectionId: 'remote-fixture', profile: 'writer', baseUrl: 'http://localhost', token: '', wsUrl: '' })+ render(<MemoryRouter><ArtifactsView /></MemoryRouter>)++ for (const name of ['USER.md', 'report.md', 'parent.md']) {+ fireEvent.click(await screen.findByRole('button', { name }))+ }++ await waitFor(() => expect(saveGatewayFile).toHaveBeenCalledTimes(3))+ expect(saveGatewayFile.mock.calls.map(([request]) => request)).toEqual([+ { connectionId: 'remote-fixture', profile: 'writer', path: '~/.hermes/memories/USER.md', suggestedName: 'USER.md' },+ { connectionId: 'remote-fixture', profile: 'writer', path: './report.md', suggestedName: 'report.md' },+ { connectionId: 'remote-fixture', profile: 'writer', path: '../parent.md', suggestedName: 'parent.md' }+ ])+ expect(openExternal).not.toHaveBeenCalled()+})