The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): single owner predicate and live edit scope key
kshitijk4poorb6f9255a2cc9
diff --git a/apps/desktop/src/app/chat/right-rail/preview-file-save-scope.test.tsx b/apps/desktop/src/app/chat/right-rail/preview-file-save-scope.test.tsxindex 2468e84efdf..b2283546257 100644--- a/apps/desktop/src/app/chat/right-rail/preview-file-save-scope.test.tsx+++ b/apps/desktop/src/app/chat/right-rail/preview-file-save-scope.test.tsx@@ -3,7 +3,7 @@ import { tmpdir } from 'node:os'import path from 'node:path'import { EditorView } from '@codemirror/view'-import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'import { expect, it, vi } from 'vitest'import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'@@ -139,11 +139,7 @@ it.each(['connection', 'profile', 'local', 'api-route'] as const)(releaseRead()})- await waitFor(() =>- expect(- screen.queryByRole('button', { name: 'Edit' }) || screen.queryByText(/original connection/)- ).not.toBeNull()- )+ await screen.findByText(/original connection/)expect(await readFile(otherFile, 'utf8')).toBe('unrelated valuable contents')expect(writes).toEqual([])expect(editor.dom.isConnected).toBe(true)diff --git a/apps/desktop/src/app/chat/right-rail/preview-file.tsx b/apps/desktop/src/app/chat/right-rail/preview-file.tsxindex 7eac4a8b737..d47e7fa4ad5 100644--- a/apps/desktop/src/app/chat/right-rail/preview-file.tsx+++ b/apps/desktop/src/app/chat/right-rail/preview-file.tsx@@ -191,10 +191,10 @@ function isTypableElement(el: Element | null): boolean {return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || (el as HTMLElement).isContentEditable}-function fileEditScopeKey(fsKey = desktopFsCacheKey()) {+function fileEditScopeKey() {// The REST wrapper has its own routing authority. Include it while the// resolved connection descriptor is catching up with an activation.- return JSON.stringify([fsKey, getApiRequestConnection()])+ return JSON.stringify([desktopFsCacheKey(), getApiRequestConnection()])}function filePathForTarget(target: PreviewTarget) {@@ -966,7 +966,7 @@ export function LocalFilePreview({const beginEdit = () => {const text = state.text ?? ''- editorScopeRef.current = fileEditScopeKey(fsCacheKey)+ editorScopeRef.current = fileEditScopeKey()baselineRef.current = textdraftRef.current = textsetDirty(false)diff --git a/apps/desktop/src/store/projects.ts b/apps/desktop/src/store/projects.tsindex 73ea9a31dd1..92f69bcad96 100644--- a/apps/desktop/src/store/projects.ts+++ b/apps/desktop/src/store/projects.ts@@ -365,7 +365,7 @@ async function activeProjectsContext(profile = projectProfile()): Promise<Activegateway = await ensureActiveGatewayOpen()}- if (!gateway || gateway !== activeGateway() || profile !== normalizeProfileKey($activeGatewayProfile.get())) {+ if (!gateway || !stillOnWritableProjectOwner({ gateway, profile })) {throw new Error('Active Hermes profile changed while connecting')}