feat: add session.started event that triggers when a new session is created (#3413)

This commit is contained in:
Bernat Pericàs
2025-10-27 13:18:23 +01:00
committed by GitHub
parent db85f01eff
commit b562863fcc
2 changed files with 80 additions and 0 deletions

View File

@@ -78,6 +78,12 @@ export namespace Session {
export type ShareInfo = z.output<typeof ShareInfo>
export const Event = {
Started: Bus.event(
"session.started",
z.object({
info: Info,
}),
),
Updated: Bus.event(
"session.updated",
z.object({
@@ -167,6 +173,9 @@ export namespace Session {
}
log.info("created", result)
await Storage.write(["session", Instance.project.id, result.id], result)
Bus.publish(Event.Started, {
info: result,
})
const cfg = await Config.get()
if (!result.parentID && (Flag.OPENCODE_AUTO_SHARE || cfg.share === "auto"))
share(result.id)