Revert "Preserve OpenCode session across command completion, control SessionS…" (#14943)

This reverts commit 1da1bdc01c.
This commit is contained in:
Jinjing
2026-08-16 12:33:28 -07:00
committed by GitHub
parent bf6dc6fcba
commit ef1224c4f7
10 changed files with 20 additions and 411 deletions
@@ -131,22 +131,6 @@ describe('OpenCode plugin lifecycle delivery', () => {
})
}
it('maps only root session.created to SessionStart', async () => {
const handler = await loadHandler()
await handler({
event: { type: 'session.created', properties: { info: { id: 'root' } } }
})
await handler({
event: {
type: 'session.created',
properties: { info: { id: 'child', parentID: 'root' } }
}
})
expect(posts).toEqual([{ hook_event_name: 'SessionStart', sessionID: 'root' }])
})
it('preserves FIFO lifecycle order while the first session lookup is delayed', async () => {
let releaseFirstLookup: (() => void) | undefined
const firstLookup = new Promise<void>((resolve) => {
+2 -19
View File
@@ -36,13 +36,10 @@ function toSafeDirName(id: string): string {
}
export function getOpenCodePluginSource(): string {
return getOpenCodeFamilyPluginSource('/hook/opencode', { emitSessionStart: true })
return getOpenCodeFamilyPluginSource('/hook/opencode')
}
export function getOpenCodeFamilyPluginSource(
hookPathname: string,
options: { emitSessionStart: boolean }
): string {
export function getOpenCodeFamilyPluginSource(hookPathname: string): string {
// Why: the plugin posts PTY environment data from OpenCode to the shared hooks server.
return [
'// Why: process-lifetime guard so a recurring parse error on a malformed',
@@ -838,20 +835,6 @@ export function getOpenCodeFamilyPluginSource(
'',
' const sessionID = event.properties?.sessionID;',
' const updatedPart = event.properties?.part;',
...(options.emitSessionStart
? [
' if (event.type === "session.created") {',
' const info = event.properties?.info;',
' if (!info?.id || info.parentID) return;',
' rememberSessionRoot(info.id, info.id);',
' await enqueueLifecycle(() =>',
' disposed ? undefined : post("SessionStart", { sessionID: info.id })',
' );',
' return;',
' }',
''
]
: []),
' if (',
' event.type === "message.part.updated" &&',
' updatedPart?.type === "tool" &&',