fix(tui): use event union for data handling
This commit is contained in:
parent
7a17925495
commit
3ed91c6ae9
1 changed files with 7 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type {
|
||||
AgentV2Info,
|
||||
CommandV2Info,
|
||||
Event,
|
||||
IntegrationInfo,
|
||||
LocationRef,
|
||||
ModelV2Info,
|
||||
|
|
@ -16,7 +17,6 @@ import type {
|
|||
SessionMessageAssistantTool,
|
||||
SessionV2Info,
|
||||
SkillV2Info,
|
||||
V2Event,
|
||||
} from "@opencode-ai/sdk/v2"
|
||||
import { createStore, produce } from "solid-js/store"
|
||||
import { createSimpleContext } from "./helper"
|
||||
|
|
@ -47,6 +47,10 @@ type Data = {
|
|||
location: Record<string, LocationData>
|
||||
}
|
||||
|
||||
type DataEvent = {
|
||||
[Item in Event as Item["type"]]: Item & { data: Item["properties"]; location: LocationRef }
|
||||
}[Event["type"]]
|
||||
|
||||
function locationKey(location: LocationRef) {
|
||||
return JSON.stringify([location.directory, location.workspaceID])
|
||||
}
|
||||
|
|
@ -121,7 +125,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
},
|
||||
}
|
||||
|
||||
function handleEvent(event: V2Event) {
|
||||
function handleEvent(event: DataEvent) {
|
||||
switch (event.type) {
|
||||
case "catalog.updated":
|
||||
void Promise.all([
|
||||
|
|
@ -408,7 +412,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
...event,
|
||||
data: event.properties,
|
||||
location: { directory: metadata.directory, workspaceID: metadata.workspace },
|
||||
} as V2Event)
|
||||
} as DataEvent)
|
||||
})
|
||||
onCleanup(unsub)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue