Skip to content

The agent that grows with you

fix(desktop): stamp the focused profile on projects RPCs and refresh a remote scan

Brooklyn Nicholsonf98382807750
diff --git a/apps/desktop/src/store/projects.test.ts b/apps/desktop/src/store/projects.test.ts
index d91882032de..5e0e4473436 100644
--- a/apps/desktop/src/store/projects.test.ts
+++ b/apps/desktop/src/store/projects.test.ts
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { NO_PROJECT_ID, type SidebarProjectTree } from '@/app/chat/sidebar/projects/workspace-groups'
import { $sidebarAgentsGrouped, setSidebarAgentsGrouped } from '@/store/layout'
-import { $activeGatewayProfile } from '@/store/profile'
+import { $activeGatewayProfile, setShowAllProfiles } from '@/store/profile'
import { $currentCwd, $selectedStoredSessionId, $sessions, applyConfiguredDefaultProjectDir } from '@/store/session'
import {
@@ -21,6 +21,7 @@ import {
endSessionMutation,
enterProject,
exitProjectScope,
+ fetchProjectSessions,
openProjectCreate,
pickProjectFolder,
projectIdForCwd,
@@ -63,6 +64,7 @@ vi.mock('@/lib/desktop-git', async importOriginal => ({
vi.mock('@/hermes', () => ({
getHermesConfig: vi.fn(),
getProfiles: vi.fn(),
+ hermesApi: vi.fn(),
setApiRequestProfile: vi.fn(),
STARTUP_REQUEST_TIMEOUT_MS: 1000
}))
@@ -84,6 +86,16 @@ const getHermesConfig = vi.mocked(hermes.getHermesConfig)
const notifications = await import('@/store/notifications')
const notify = vi.mocked(notifications.notify)
+function deferred<T>() {
+ let resolve!: (value: T) => void
+
+ const promise = new Promise<T>(done => {
+ resolve = done
+ })
+
+ return { promise, resolve }
+}
+
describe('project scope', () => {
beforeEach(() => {
window.localStorage.clear()
@@ -118,6 +130,50 @@ describe('project scope', () => {
})
})
+describe('projects RPC profile forwarding', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ $activeGatewayProfile.set('default')
+ $activeProjectId.set(null)
+ $projectTree.set([])
+ setShowAllProfiles(false)
+ })
+
+ it('forwards the normalized active profile to project read RPCs', async () => {
+ const request = vi.fn(async () => ({ active_id: null, projects: [], scoped_session_ids: [] }))
+ const gateway = { connectionState: 'open', request }
+ activeGateway.mockReturnValue(gateway as never)
+ gatewayAtom.set(gateway as never)
+ $activeGatewayProfile.set(' coder ')
+
+ await refreshProjects()
+ await refreshProjectTree()
+ await fetchProjectSessions('p_123')
+
+ expect(request).toHaveBeenNthCalledWith(1, 'projects.list', { profile: 'coder' })
+ expect(request).toHaveBeenNthCalledWith(2, 'projects.tree', { preview_limit: 3, profile: 'coder' })
+ expect(request).toHaveBeenNthCalledWith(3, 'projects.project_sessions', {
+ profile: 'coder',
+ project_id: 'p_123'
+ })
+ })
+
+ it('skips project reads in the all-profiles view rather than forwarding its sentinel', async () => {
+ const request = vi.fn()
+ const gateway = { connectionState: 'open', request }
+ activeGateway.mockReturnValue(gateway as never)
+ gatewayAtom.set(gateway as never)
+ setShowAllProfiles(true)
+
+ await refreshProjects()
+ await refreshProjectTree()
+ await fetchProjectSessions('p_123')
+
+ expect(request).not.toHaveBeenCalled()
+ setShowAllProfiles(false)
+ })
+})
+
describe('resolveNewSessionCwd', () => {
beforeEach(() => {
$projectScope.set(ALL_PROJECTS)
@@ -478,6 +534,7 @@ describe('repository discovery policy', () => {
expect(scanRepos).not.toHaveBeenCalled()
expect(request).toHaveBeenCalledWith('projects.record_repos', {
discovery_policy: { enabled: false, exclude_paths: [], roots: [] },
+ profile: 'default',
repos: []
})
})
@@ -513,24 +570,154 @@ describe('repository discovery policy', () => {
exclude_paths: ['/work/vendor'],
roots: ['/work']
},
+ profile: 'default',
repos: [{ label: 'repo', root: '/work/repo' }]
})
})
- it('does not scan the local filesystem for remote connections', async () => {
+ it('does not scan the local filesystem for remote connections but still refreshes the project tree', async () => {
isDesktopFsRemoteMode.mockReturnValue(true)
const scanRepos = vi.fn()
desktopGit.mockReturnValue({ scanRepos } as never)
+ const request = vi.fn(async (method: string) =>
+ method === 'projects.tree'
+ ? { active_id: null, projects: [], scoped_session_ids: [] }
+ : { accepted: false, repos: [] }
+ )
+ gatewayWith(request)
+ $projectTree.set([{ id: 'seed', label: 'seed', path: null, repos: [], sessionCount: 0 } satisfies SidebarProjectTree])
await scanAndRecordRepos(true)
expect(scanRepos).not.toHaveBeenCalled()
expect(getHermesConfig).not.toHaveBeenCalled()
+ // The desktop can't crawl the remote host's filesystem, so it asks the
+ // host to scan its own discovery roots (`projects.discover_repos` with
+ // `scan: true`) — repos with zero Hermes sessions must still surface —
+ // then refreshes the tree to pick up the merged list. Regression for
+ // #81723: the sidebar used to go silent in remote mode and never
+ // refresh again.
+ expect(request).toHaveBeenCalledWith('projects.discover_repos', { profile: 'default', scan: true })
+ expect(request).toHaveBeenCalledWith(
+ 'projects.tree',
+ expect.objectContaining({ preview_limit: expect.any(Number), profile: 'default' })
+ )
+ // A successful scan refreshes the tree (here to the empty list the mock
+ // tree returns), so a later discover-repos call replaces it instead of
+ // keeping the stale seed.
+ expect($projectTree.get()).toEqual([])
+ })
+
+ it('surfaces a reject from remote discover_repos without clearing the sidebar', async () => {
+ // Backend error (RPC `error` frame) rejects the request — the sidebar must
+ // keep its last known list and flag the failure, not go silently blank.
+ isDesktopFsRemoteMode.mockReturnValue(true)
+ desktopGit.mockReturnValue({ scanRepos: vi.fn() } as never)
+ const request = vi.fn(async (method: string) => {
+ if (method === 'projects.discover_repos') {
+ throw new Error('discover_repos failed')
+ }
+ if (method === 'projects.tree') {
+ return { active_id: null, projects: [], scoped_session_ids: [] }
+ }
+ return { accepted: false, repos: [] }
+ })
+ gatewayWith(request)
+ $projectTree.set([{ id: 'seed', label: 'seed', path: null, repos: [], sessionCount: 0 } satisfies SidebarProjectTree])
+
+ await scanAndRecordRepos(true)
+
+ // The tree refresh must NOT run against a failed remote scan ...
+ expect(request).not.toHaveBeenCalledWith(
+ 'projects.tree',
+ expect.objectContaining({ preview_limit: expect.any(Number) })
+ )
+ // ... the cached tree is preserved ...
+ expect($projectTree.get()).toEqual([
+ { id: 'seed', label: 'seed', path: null, repos: [], sessionCount: 0 }
+ ])
+ })
+
+ it('does not treat an error-shaped discover_repos response as a successful refresh', async () => {
+ // A resolved-but-error-shaped body (`{accepted:false}` / no `repos`) must
+ // be treated as a failure: keep the old list rather than refreshing into
+ // the silent, empty sidebar of #81723.
+ isDesktopFsRemoteMode.mockReturnValue(true)
+ desktopGit.mockReturnValue({ scanRepos: vi.fn() } as never)
+ const request = vi.fn(async (method: string) =>
+ method === 'projects.tree'
+ ? { active_id: null, projects: [], scoped_session_ids: [] }
+ : { accepted: false }
+ )
+ gatewayWith(request)
+ $projectTree.set([{ id: 'seed', label: 'seed', path: null, repos: [], sessionCount: 0 } satisfies SidebarProjectTree])
+
+ await scanAndRecordRepos(true)
+
+ expect(request).not.toHaveBeenCalledWith(
+ 'projects.tree',
+ expect.objectContaining({ preview_limit: expect.any(Number) })
+ )
+ expect($projectTree.get()).toEqual([
+ { id: 'seed', label: 'seed', path: null, repos: [], sessionCount: 0 }
+ ])
+ })
+
+ it('records repos under the profile the scan started with, not one focused mid-scan', async () => {
+ const { promise: scanResult, resolve: resolveScan } = deferred<Array<{ label: string; root: string }>>()
+ const { promise: scanStarted, resolve: markScanStarted } = deferred<void>()
+
+ const request = vi.fn(async (method: string) =>
+ method === 'projects.tree'
+ ? {
+ active_id: null,
+ projects: [{ id: 'p_lured', label: 'Lured', path: null, repos: [], sessionCount: 0 }],
+ scoped_session_ids: []
+ }
+ : { accepted: true, repos: [] }
+ )
+
+ gatewayWith(request)
+ const scanRepos = vi.fn(() => {
+ markScanStarted()
+ return scanResult
+ })
+ desktopGit.mockReturnValue({ scanRepos } as never)
+ getHermesConfig.mockResolvedValue({
+ desktop: {
+ repo_scan_enabled: true,
+ repo_scan_exclude_paths: [],
+ repo_scan_roots: ['/work']
+ }
+ })
+ $activeGatewayProfile.set('launch')
+ $projectTree.set([])
+
+ const pending = scanAndRecordRepos()
+ await scanStarted
+ $activeGatewayProfile.set('coder')
+ resolveScan([{ label: 'repo', root: '/work/repo' }])
+ await pending
+
+ expect(request).toHaveBeenCalledWith('projects.record_repos', {
+ discovery_policy: { enabled: true, exclude_paths: [], roots: ['/work'] },
+ profile: 'launch',
+ repos: [{ label: 'repo', root: '/work/repo' }]
+ })
+ expect(request).not.toHaveBeenCalledWith('projects.record_repos', expect.objectContaining({ profile: 'coder' }))
+ expect($projectTree.get()).toEqual([])
})
})
describe('project tree profile isolation', () => {
- it('does not publish a late response from the previous profile', async () => {
+ beforeEach(() => {
+ setShowAllProfiles(false)
+ $activeGatewayProfile.set('default')
+ $projects.set([])
+ $projectTree.set([])
+ })
+
+ it('does not publish a late response from the previous gateway', async () => {
let resolveA: ((value: unknown) => void) | undefined
const responseA = new Promise(resolve => {
@@ -566,6 +753,84 @@ describe('project tree profile isolation', () => {
expect($projectTree.get().map(project => project.id)).toEqual(['profile-b'])
})
+
+ it('does not publish a late projects.list response from the previous profile', async () => {
+ const { promise: defaultResponse, resolve: resolveDefault } = deferred<unknown>()
+ const request = vi.fn((_method: string, params: Record<string, unknown>) =>
+ params.profile === 'default'
+ ? defaultResponse
+ : Promise.resolve({
+ active_id: null,
+ projects: [{ id: 'profile-b', label: 'Profile B' }]
+ })
+ )
+ const gateway = { connectionState: 'open', request }
+ activeGateway.mockReturnValue(gateway as never)
+ gatewayAtom.set(gateway as never)
+
+ const pendingDefault = refreshProjects()
+ $activeGatewayProfile.set('profile-b')
+ await refreshProjects()
+ resolveDefault({
+ active_id: null,
+ projects: [{ id: 'profile-a', label: 'Profile A' }]
+ })
+ await pendingDefault
+
+ expect($projects.get().map(project => project.id)).toEqual(['profile-b'])
+ })
+
+ it('does not publish a late projects.tree response from the previous profile', async () => {
+ const { promise: defaultResponse, resolve: resolveDefault } = deferred<unknown>()
+ const request = vi.fn((_method: string, params: Record<string, unknown>) =>
+ params.profile === 'default'
+ ? defaultResponse
+ : Promise.resolve({
+ active_id: null,
+ projects: [{ id: 'profile-b', label: 'Profile B', path: null, repos: [], sessionCount: 0 }],
+ scoped_session_ids: []
+ })
+ )
+ const gateway = { connectionState: 'open', request }
+ activeGateway.mockReturnValue(gateway as never)
+ gatewayAtom.set(gateway as never)
+
+ const pendingDefault = refreshProjectTree()
+ $activeGatewayProfile.set('profile-b')
+ await refreshProjectTree()
+ resolveDefault({
+ active_id: null,
+ projects: [{ id: 'profile-a', label: 'Profile A', path: null, repos: [], sessionCount: 0 }],
+ scoped_session_ids: []
+ })
+ await pendingDefault
+
+ expect($projectTree.get().map(project => project.id)).toEqual(['profile-b'])
+ })
+
+ it('drops a late hydrated-project response from the previous profile', async () => {
+ const { promise: defaultResponse, resolve: resolveDefault } = deferred<unknown>()
+ const request = vi.fn((_method: string, params: Record<string, unknown>) =>
+ params.profile === 'default'
+ ? defaultResponse
+ : Promise.resolve({
+ project: { id: 'profile-b', label: 'Profile B', path: null, repos: [], sessionCount: 0 }
+ })
+ )
+ const gateway = { connectionState: 'open', request }
+ activeGateway.mockReturnValue(gateway as never)
+ gatewayAtom.set(gateway as never)
+
+ const pendingDefault = fetchProjectSessions('p_123')
+ $activeGatewayProfile.set('profile-b')
+ const profileB = await fetchProjectSessions('p_123')
+ resolveDefault({
+ project: { id: 'profile-a', label: 'Profile A', path: null, repos: [], sessionCount: 0 }
+ })
+
+ expect(profileB?.id).toBe('profile-b')
+ await expect(pendingDefault).resolves.toBeNull()
+ })
})
describe('tombstone pruning', () => {
diff --git a/apps/desktop/src/store/projects.ts b/apps/desktop/src/store/projects.ts
index b904b0f34e6..eced3fe82b5 100644
--- a/apps/desktop/src/store/projects.ts
+++ b/apps/desktop/src/store/projects.ts
@@ -16,7 +16,13 @@ import { persistentAtom } from '@/lib/persisted'
import { $gateway, activeGateway, ensureActiveGatewayOpen } from '@/store/gateway'
import { setSidebarAgentsGrouped } from '@/store/layout'
import { notify } from '@/store/notifications'
-import { $activeGatewayProfile, $profileScope, ALL_PROFILES, requestFreshSession } from '@/store/profile'
+import {
+ $activeGatewayProfile,
+ $profileScope,
+ ALL_PROFILES,
+ normalizeProfileKey,
+ requestFreshSession
+} from '@/store/profile'
import {
$selectedStoredSessionId,
$sessions,
@@ -341,6 +347,23 @@ async function gatewayRequest<T>(method: string, params: Record<string, unknown>
return gateway.request<T>(method, params)
}
+function projectProfile(): null | string {
+ const profile = normalizeProfileKey($activeGatewayProfile.get())
+
+ return $profileScope.get() === ALL_PROFILES || profile === ALL_PROFILES ? null : profile
+}
+
+function projectParams(
+ params: Record<string, unknown> = {},
+ profile: null | string = projectProfile()
+): Record<string, unknown> {
+ if (!profile) {
+ throw new Error('Projects are unavailable while viewing all profiles')
+ }
+
+ return { ...params, profile }
+}
+
async function gatewayRequestOn<T>(
gateway: HermesGateway,
method: string,
@@ -354,15 +377,24 @@ interface ActiveProjectsContext {
profile: string
}
+function stillOnProjectsContext(context: ActiveProjectsContext): boolean {
+ return activeGateway() === context.gateway && projectProfile() === context.profile
+}
+
async function activeProjectsContext(): Promise<ActiveProjectsContext> {
- const profile = $activeGatewayProfile.get() || 'default'
+ const profile = projectProfile()
+
+ if (!profile) {
+ throw new Error('Projects are unavailable while viewing all profiles')
+ }
+
let gateway = activeGateway()
if (!gateway || gateway.connectionState !== 'open') {
gateway = await ensureActiveGatewayOpen()
}
- if (!gateway || gateway !== activeGateway() || profile !== ($activeGatewayProfile.get() || 'default')) {
+ if (!gateway || gateway !== activeGateway() || profile !== projectProfile()) {
throw new Error('Active Hermes profile changed while connecting')
}
@@ -380,20 +412,24 @@ let projectsRefreshGeneration = 0
// not up yet) leaves the cached atoms intact so the sidebar doesn't flicker.
export async function refreshProjects(): Promise<void> {
const generation = ++projectsRefreshGeneration
- let gateway: HermesGateway | null = null
+ let context: ActiveProjectsContext | null = null
try {
- gateway = (await activeProjectsContext()).gateway
- const payload = await gatewayRequestOn<ProjectsPayload>(gateway, 'projects.list')
+ context = await activeProjectsContext()
+ const payload = await gatewayRequestOn<ProjectsPayload>(
+ context.gateway,
+ 'projects.list',
+ projectParams({}, context.profile)
+ )
- if (generation !== projectsRefreshGeneration || activeGateway() !== gateway) {
+ if (generation !== projectsRefreshGeneration || !stillOnProjectsContext(context)) {
return
}
applyPayload(payload)
markProjectsRpcSuccess()
} catch (err) {
- if (generation === projectsRefreshGeneration && (!gateway || activeGateway() === gateway)) {
+ if (context && generation === projectsRefreshGeneration && stillOnProjectsContext(context)) {
markProjectsRpcFailure(err)
}
// Backend may not be ready; keep the last known list.
@@ -433,26 +469,29 @@ function applyProjectTreePayload(res: ProjectTreePayload): void {
}
}
-async function refreshProjectTreeOn(gateway: HermesGateway): Promise<void> {
+async function refreshProjectTreeOn(context: ActiveProjectsContext): Promise<void> {
const generation = ++projectTreeRefreshGeneration
+ const { gateway, profile } = context
if (activeGateway() === gateway) {
$projectTreeLoading.set(true)
}
try {
- const res = await gatewayRequestOn<ProjectTreePayload>(gateway, 'projects.tree', {
- preview_limit: PROJECT_TREE_PREVIEW_LIMIT
- })
+ const res = await gatewayRequestOn<ProjectTreePayload>(
+ gateway,
+ 'projects.tree',
+ projectParams({ preview_limit: PROJECT_TREE_PREVIEW_LIMIT }, profile)
+ )
- if (generation !== projectTreeRefreshGeneration || activeGateway() !== gateway) {
+ if (generation !== projectTreeRefreshGeneration || !stillOnProjectsContext(context)) {
return
}
applyProjectTreePayload(res)
markProjectsRpcSuccess()
} catch (err) {
- if (activeGateway() === gateway) {
+ if (generation === projectTreeRefreshGeneration && stillOnProjectsContext(context)) {
markProjectsRpcFailure(err)
}
} finally {
@@ -473,8 +512,7 @@ export async function refreshProjectTree(): Promise<void> {
}
try {
- const { gateway } = await activeProjectsContext()
- await refreshProjectTreeOn(gateway)
+ await refreshProjectTreeOn(await activeProjectsContext())
} catch {
// Backend may not be ready; keep the last known tree.
}
@@ -514,11 +552,22 @@ async function refreshProjectTreeAcrossProfiles(): Promise<void> {
// Fully hydrated lanes (repo -> lane -> session rows) for one project, fetched
// when the user enters it. Same backend grouping as `projects.tree`, so ids and
// membership match exactly.
+let projectSessionsRefreshGeneration = 0
+
export async function fetchProjectSessions(projectId: string): Promise<SidebarProjectTree | null> {
+ const generation = ++projectSessionsRefreshGeneration
+
try {
- const res = await gatewayRequest<{ project: SidebarProjectTree | null }>('projects.project_sessions', {
- project_id: projectId
- })
+ const context = await activeProjectsContext()
+ const res = await gatewayRequestOn<{ project: SidebarProjectTree | null }>(
+ context.gateway,
+ 'projects.project_sessions',
+ projectParams({ project_id: projectId }, context.profile)
+ )
+
+ if (generation !== projectSessionsRefreshGeneration || !stillOnProjectsContext(context)) {
+ return null
+ }
return res.project ?? null
} catch {
@@ -616,6 +665,41 @@ $gateway.subscribe(syncReposScanning)
export async function scanAndRecordRepos(force = false): Promise<void> {
if (isDesktopFsRemoteMode()) {
+ // On a remote backend the desktop can't crawl the host filesystem.
+ // Ask the host to scan its own discovery roots (`projects.discover_repos`
+ // with `scan: true` — added in #81723) so repos with zero Hermes
+ // sessions still surface, then refresh the tree so the sidebar picks up
+ // the merged session-derived + scanned list.
+ try {
+ const context = await activeProjectsContext()
+ const discovered = await gatewayRequestOn<{
+ repos?: unknown
+ discovery_policy?: unknown
+ }>(context.gateway, 'projects.discover_repos', projectParams({ scan: true }, context.profile))
+
+ // A resolved response must be the discovery shape. Anything else (an
+ // error/`accepted:false` body, or a backend that ignored `scan` and
+ // returned no repo list) means the scan didn't happen — bail out without
+ // touching the tree so the sidebar keeps its last known list instead of
+ // being blanked back to the silent, unpopulated state of #81723.
+ if (discovered?.repos === undefined) {
+ markProjectsRpcFailure(new Error('projects.discover_repos returned no repo list'))
+ return
+ }
+
+ // Remote scan succeeded: refresh the tree so the merged session-derived +
+ // scanned list surfaces. Skip if the user moved on — a stale scan must
+ // not publish into the newly focused profile.
+ if (stillOnProjectsContext(context)) {
+ await refreshProjectTreeOn(context)
+ }
+ } catch (err) {
+ // Surface the failure (stale backend, RPC error, gateway drop) instead
+ // of swallowing it: a silent return is exactly the "sidebar goes quiet"
+ // symptom `scan:true` was meant to fix (#81723). Keep the old list and
+ // let the sidebar show the error/absent state.
+ markProjectsRpcFailure(err)
+ }
return
}
@@ -649,10 +733,11 @@ export async function scanAndRecordRepos(force = false): Promise<void> {
state.runningSignature = signature
if (!policy.enabled) {
- await gatewayRequestOn(context.gateway, 'projects.record_repos', {
- discovery_policy: policy,
- repos: []
- })
+ await gatewayRequestOn(
+ context.gateway,
+ 'projects.record_repos',
+ projectParams({ discovery_policy: policy, repos: [] }, context.profile)
+ )
} else {
scanningGatewayGenerations.set(context.gateway, generation)
syncReposScanning()
@@ -666,10 +751,11 @@ export async function scanAndRecordRepos(force = false): Promise<void> {
return
}
- await gatewayRequestOn(context.gateway, 'projects.record_repos', {
- discovery_policy: policy,
- repos
- })
+ await gatewayRequestOn(
+ context.gateway,
+ 'projects.record_repos',
+ projectParams({ discovery_policy: policy, repos }, context.profile)
+ )
}
if (state.generation !== generation) {
@@ -677,10 +763,13 @@ export async function scanAndRecordRepos(force = false): Promise<void> {
}
state.completedSignature = signature
- // Scope-aware on purpose: the scan records into one profile, but folding
- // its result back in through the active scope keeps an all-profiles tree
- // from being overwritten by the scanned profile's own.
- await refreshProjectTree()
+ // Completion refresh only when the focused profile still matches the one
+ // the scan was captured under. refreshProjectTree() re-derives the current
+ // context, so skipping on mismatch keeps a stale scan from publishing into
+ // the newly focused profile.
+ if (stillOnProjectsContext(context)) {
+ await refreshProjectTree()
+ }
} catch {
state.completedSignature = undefined
} finally {
@@ -808,17 +897,20 @@ export async function createProject(input: CreateProjectInput): Promise<ProjectI
let res: { project: ProjectInfo | null }
try {
- res = await gatewayRequest<{ project: ProjectInfo | null }>('projects.create', {
- name: input.name,
- folders: input.folders ?? [],
- primary_path: input.primaryPath,
- slug: input.slug,
- description: input.description,
- icon: input.icon,
- color: input.color,
- board_slug: input.boardSlug,
- use: input.use ?? false
- })
+ res = await gatewayRequest<{ project: ProjectInfo | null }>(
+ 'projects.create',
+ projectParams({
+ name: input.name,
+ folders: input.folders ?? [],
+ primary_path: input.primaryPath,
+ slug: input.slug,
+ description: input.description,
+ icon: input.icon,
+ color: input.color,
+ board_slug: input.boardSlug,
+ use: input.use ?? false
+ })
+ )
} catch (err) {
if (isMissingRpcMethod(err)) {
$projectsRpcAvailable.set(false)
@@ -891,12 +983,15 @@ export async function updateProject(
// Backend treats null/undefined as "leave unchanged"; "" clears (stores NULL).
// Map explicit null → "" so "no color"/"no icon" actually clear.
await persistOrRollback(snap, () =>
- gatewayRequest('projects.update', {
- id,
- ...patch,
- ...(patch.color === null && { color: '' }),
- ...(patch.icon === null && { icon: '' })
- })
+ gatewayRequest(
+ 'projects.update',
+ projectParams({
+ id,
+ ...patch,
+ ...(patch.color === null && { color: '' }),
+ ...(patch.icon === null && { icon: '' })
+ })
+ )
)
}
@@ -967,7 +1062,10 @@ export async function addProjectFolder(
}
await persistOrRollback(snap, () =>
- gatewayRequest('projects.add_folder', { id, path, label: opts.label, is_primary: opts.isPrimary ?? false })
+ gatewayRequest(
+ 'projects.add_folder',
+ projectParams({ id, path, label: opts.label, is_primary: opts.isPrimary ?? false })
+ )
)
reconcileProjects()
}
@@ -1010,13 +1108,13 @@ export async function deleteProject(id: string): Promise<void> {
}
await persistOrRollback(snap, async () => {
- applyPayload(await gatewayRequest<ProjectsPayload>('projects.delete', { id }))
+ applyPayload(await gatewayRequest<ProjectsPayload>('projects.delete', projectParams({ id })))
})
void refreshProjectTree()
}
export async function setActiveProject(id: null | string): Promise<void> {
- const res = await gatewayRequest<{ active_id: null | string }>('projects.set_active', { id })
+ const res = await gatewayRequest<{ active_id: null | string }>('projects.set_active', projectParams({ id }))
$activeProjectId.set(res.active_id ?? null)
}