fix(tui): keep global event routing unchanged
This commit is contained in:
parent
1d11bf84c9
commit
7d277f931e
2 changed files with 1 additions and 68 deletions
|
|
@ -104,7 +104,6 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
const [defaultLocation, setDefaultLocation] = createSignal<LocationRef>({
|
||||
directory: process.cwd(),
|
||||
})
|
||||
let defaultLocationReady = false
|
||||
const messageIndex = new Map<string, Map<string, number>>()
|
||||
let bootstrapping: Promise<void> | undefined
|
||||
let connected = false
|
||||
|
|
@ -234,16 +233,6 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
}
|
||||
|
||||
function handleEvent(event: OpenCodeEvent) {
|
||||
if (
|
||||
defaultLocationReady &&
|
||||
event.type.startsWith("session.") &&
|
||||
"sessionID" in event.data &&
|
||||
typeof event.data.sessionID === "string" &&
|
||||
!store.session.info[event.data.sessionID] &&
|
||||
event.location &&
|
||||
locationKey(event.location) !== locationKey(defaultLocation())
|
||||
)
|
||||
return
|
||||
switch (event.type) {
|
||||
case "session.created":
|
||||
void result.session.refresh(event.data.sessionID)
|
||||
|
|
@ -923,10 +912,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
const location = await sdk.api.location.get({ location: locationQuery(ref ?? defaultLocation()) })
|
||||
const key = locationKey(location)
|
||||
if (!store.location[key]) setStore("location", key, {})
|
||||
if (!ref) {
|
||||
setDefaultLocation({ directory: location.directory, workspaceID: location.workspaceID })
|
||||
defaultLocationReady = true
|
||||
}
|
||||
if (!ref) setDefaultLocation({ directory: location.directory, workspaceID: location.workspaceID })
|
||||
},
|
||||
agent: {
|
||||
list(location?: LocationRef) {
|
||||
|
|
|
|||
|
|
@ -122,59 +122,6 @@ test("refreshes resources into reactive getters", async () => {
|
|||
}
|
||||
})
|
||||
|
||||
test("does not materialize messages for unknown sessions in other locations", async () => {
|
||||
const events = createEventStream()
|
||||
const sessionID = "ses_unloaded"
|
||||
const calls = createFetch((url) => {
|
||||
if (url.pathname === `/api/session/${sessionID}/message`) return json({ data: [], cursor: {} })
|
||||
}, events)
|
||||
let data!: ReturnType<typeof useData>
|
||||
|
||||
function Probe() {
|
||||
data = useData()
|
||||
return <box />
|
||||
}
|
||||
|
||||
const app = await testRender(() => (
|
||||
<TestTuiContexts>
|
||||
<SDKProvider client={createClient(calls.fetch)} api={createApi(calls.fetch)}>
|
||||
<ProjectProvider>
|
||||
<DataProvider>
|
||||
<Probe />
|
||||
</DataProvider>
|
||||
</ProjectProvider>
|
||||
</SDKProvider>
|
||||
</TestTuiContexts>
|
||||
))
|
||||
|
||||
const started = (id: string, seq: number): OpenCodeEvent => ({
|
||||
id: `evt_${id}`,
|
||||
created: seq,
|
||||
type: "session.step.started",
|
||||
durable: durable(sessionID, seq),
|
||||
data: {
|
||||
sessionID,
|
||||
assistantMessageID: id,
|
||||
agent: "build",
|
||||
model: { providerID: "provider", id: "model" },
|
||||
},
|
||||
})
|
||||
|
||||
try {
|
||||
await wait(() => data.location.default().directory === directory)
|
||||
events.emit({ ...started("msg_ignored", 1), location: { directory: "/tmp/other" } })
|
||||
await Bun.sleep(20)
|
||||
expect(data.session.message.ids(sessionID)).toEqual([])
|
||||
|
||||
await data.session.message.refresh(sessionID)
|
||||
emitEvent(events, started("msg_loaded", 2))
|
||||
await wait(() => data.session.message.ids(sessionID).length === 1)
|
||||
expect(data.session.message.ids(sessionID)).toEqual(["msg_loaded"])
|
||||
} finally {
|
||||
app.renderer.destroy()
|
||||
}
|
||||
})
|
||||
|
||||
test("applies absolute usage events to session info", async () => {
|
||||
const events = createEventStream()
|
||||
const sessionID = "ses_usage_refresh"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue