Skip to content

Commit 41de913

Browse files
committed
use pathKey everywhere
1 parent da436ce commit 41de913

5 files changed

Lines changed: 20 additions & 12 deletions

File tree

packages/app/src/components/dialog-select-mcp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { List } from "@opencode-ai/ui/list"
77
import { Switch } from "@opencode-ai/ui/switch"
88
import { useLanguage } from "@/context/language"
99
import { useQueryOptions } from "@/context/global-sync"
10+
import { pathKey } from "@/utils/path-key"
1011

1112
const statusLabels = {
1213
connected: "mcp.status.connected",
@@ -33,7 +34,7 @@ export const DialogSelectMcp: Component = () => {
3334
if (sync.data.mcp[name]?.status === "connected") await sdk.client.mcp.disconnect({ name })
3435
else await sdk.client.mcp.connect({ name })
3536
},
36-
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(sync.directory)),
37+
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(pathKey(sync.directory))),
3738
}))
3839

3940
const enabledCount = createMemo(() => items().filter((i) => i.status === "connected").length)

packages/app/src/components/prompt-input.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { promptPlaceholder } from "./prompt-input/placeholder"
5656
import { ImagePreview } from "@opencode-ai/ui/image-preview"
5757
import { useQueries } from "@tanstack/solid-query"
5858
import { useQueryOptions } from "@/context/global-sync"
59+
import { pathKey } from "@/utils/path-key"
5960

6061
interface PromptInputProps {
6162
class?: string
@@ -1254,7 +1255,11 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
12541255
}
12551256

12561257
const [agentsQuery, globalProvidersQuery, providersQuery] = useQueries(() => ({
1257-
queries: [queryOptions.agents(sdk.directory), queryOptions.providers(null), queryOptions.providers(sdk.directory)],
1258+
queries: [
1259+
queryOptions.agents(pathKey(sdk.directory)),
1260+
queryOptions.providers(null),
1261+
queryOptions.providers(pathKey(sdk.directory)),
1262+
],
12581263
}))
12591264

12601265
const agentsLoading = () => agentsQuery.isLoading

packages/app/src/components/status-popover-body.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { normalizeServerUrl, ServerConnection, useServer } from "@/context/serve
1616
import { useSync } from "@/context/sync"
1717
import { useCheckServerHealth, type ServerHealth } from "@/utils/server-health"
1818
import { useQueryOptions } from "@/context/global-sync"
19+
import { pathKey } from "@/utils/path-key"
1920

2021
const pollMs = 10_000
2122

@@ -146,7 +147,7 @@ const useMcpToggleMutation = () => {
146147
const status = sync.data.mcp[name]
147148
await (status?.status === "connected" ? sdk.client.mcp.disconnect({ name }) : sdk.client.mcp.connect({ name }))
148149
},
149-
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(sync.directory)),
150+
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(pathKey(sync.directory))),
150151
onError: (err) => {
151152
showToast({
152153
variant: "error",

packages/app/src/context/global-sync.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { formatServerError } from "@/utils/server-errors"
3535
import { queryOptions, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/solid-query"
3636
import { createRefreshQueue } from "./global-sync/queue"
3737
import { directoryKey } from "./global-sync/utils"
38+
import { PathKey } from "@/utils/path-key"
3839

3940
type GlobalStore = {
4041
ready: boolean
@@ -62,17 +63,17 @@ export const loadLspQuery = (directory: string, sdk: OpencodeClient) =>
6263
queryFn: () => sdk.lsp.status().then((r) => r.data ?? []),
6364
})
6465

65-
function makeQueryOptionsApi(globalSDK: () => OpencodeClient, sdkFor: (dir: string) => OpencodeClient) {
66+
function makeQueryOptionsApi(globalSDK: () => OpencodeClient, sdkFor: (dir: PathKey) => OpencodeClient) {
6667
return {
6768
globalConfig: () => loadGlobalConfigQuery(globalSDK()),
6869
projects: () => loadProjectsQuery(globalSDK()),
69-
providers: (directory: string | null) =>
70+
providers: (directory: PathKey | null) =>
7071
loadProvidersQuery(directory, directory === null ? globalSDK() : sdkFor(directory)),
71-
path: (directory: string | null) => loadPathQuery(directory, directory === null ? globalSDK() : sdkFor(directory)),
72-
agents: (directory: string) => loadAgentsQuery(directory, sdkFor(directory)),
73-
mcp: (directory: string) => loadMcpQuery(directory, sdkFor(directory)),
74-
lsp: (directory: string) => loadLspQuery(directory, sdkFor(directory)),
75-
sessions: (directory: string) => ({ queryKey: [directory, "loadSessions"] as const }),
72+
path: (directory: PathKey | null) => loadPathQuery(directory, directory === null ? globalSDK() : sdkFor(directory)),
73+
agents: (directory: PathKey) => loadAgentsQuery(directory, sdkFor(directory)),
74+
mcp: (directory: PathKey) => loadMcpQuery(directory, sdkFor(directory)),
75+
lsp: (directory: PathKey) => loadLspQuery(directory, sdkFor(directory)),
76+
sessions: (directory: PathKey) => ({ queryKey: [directory, "loadSessions"] as const }),
7677
}
7778
}
7879
export type QueryOptionsApi = ReturnType<typeof makeQueryOptionsApi>

packages/app/src/pages/layout/sidebar-workspace.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export const SortableWorkspace = (props: {
321321
const boot = createMemo(() => open() || active())
322322
const count = createMemo(() => sessions()?.length ?? 0)
323323
const hasMore = createMemo(() => workspaceStore.sessionTotal > count())
324-
const fetching = useIsFetching(() => queryOptions.sessions(props.directory))
324+
const fetching = useIsFetching(() => queryOptions.sessions(pathKey(props.directory)))
325325
const busy = createMemo(() => props.ctx.isBusy(props.directory))
326326
const loading = () => fetching() > 0 && count() === 0
327327
const touch = createMediaQuery("(hover: none)")
@@ -456,7 +456,7 @@ export const LocalWorkspace = (props: {
456456
const slug = createMemo(() => base64Encode(props.project.worktree))
457457
const sessions = createMemo(() => sortedRootSessions(workspace().store, props.sortNow()))
458458
const count = createMemo(() => sessions()?.length ?? 0)
459-
const fetching = useIsFetching(() => queryOptions.sessions(props.project.worktree))
459+
const fetching = useIsFetching(() => queryOptions.sessions(pathKey(props.project.worktree)))
460460
const hasMore = createMemo(() => workspace().store.sessionTotal > count())
461461
const loading = () => fetching() > 0 && count() === 0
462462
const loadMore = async () => {

0 commit comments

Comments
 (0)