app: inherit owner when creating prompt session

This commit is contained in:
Brendan Allan 2026-03-17 19:47:06 +08:00
parent b07b5a9b7f
commit 0afeaea21f
No known key found for this signature in database
GPG Key ID: 41E835AEA046A32E

View File

@ -1,10 +1,10 @@
import { createStore, type SetStoreFunction } from "solid-js/store"
import { createSimpleContext } from "@opencode-ai/ui/context" import { createSimpleContext } from "@opencode-ai/ui/context"
import { batch, createMemo, createRoot, onCleanup } from "solid-js" import { checksum } from "@opencode-ai/util/encode"
import { useParams } from "@solidjs/router" import { useParams } from "@solidjs/router"
import { batch, createMemo, createRoot, getOwner, onCleanup } from "solid-js"
import { createStore, type SetStoreFunction } from "solid-js/store"
import type { FileSelection } from "@/context/file" import type { FileSelection } from "@/context/file"
import { Persist, persisted } from "@/utils/persist" import { Persist, persisted } from "@/utils/persist"
import { checksum } from "@opencode-ai/util/encode"
interface PartBase { interface PartBase {
content: string content: string
@ -250,6 +250,7 @@ export const { use: usePrompt, provider: PromptProvider } = createSimpleContext(
} }
} }
const owner = getOwner()
const load = (dir: string, id: string | undefined) => { const load = (dir: string, id: string | undefined) => {
const key = `${dir}:${id ?? WORKSPACE_KEY}` const key = `${dir}:${id ?? WORKSPACE_KEY}`
const existing = cache.get(key) const existing = cache.get(key)
@ -259,10 +260,13 @@ export const { use: usePrompt, provider: PromptProvider } = createSimpleContext(
return existing.value return existing.value
} }
const entry = createRoot((dispose) => ({ const entry = createRoot(
value: createPromptSession(dir, id), (dispose) => ({
dispose, value: createPromptSession(dir, id),
})) dispose,
}),
owner,
)
cache.set(key, entry) cache.set(key, entry)
prune() prune()