mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 14:52:25 +00:00
tui: fix SDK context usage and server port fallback
- Update SDK context to return client instead of event for proper usage - Add server port fallback to 4096 when port 0 is specified but unavailable - Fix SDK event listener usage in TUI app
This commit is contained in:
@@ -2601,13 +2601,19 @@ export namespace Server {
|
||||
}
|
||||
|
||||
export function listen(opts: { port: number; hostname: string }) {
|
||||
const server = Bun.serve({
|
||||
port: opts.port,
|
||||
const args = {
|
||||
hostname: opts.hostname,
|
||||
idleTimeout: 0,
|
||||
fetch: App().fetch,
|
||||
websocket: websocket,
|
||||
})
|
||||
return server
|
||||
} as const
|
||||
if (opts.port === 0) {
|
||||
try {
|
||||
return Bun.serve({ ...args, port: 4096 })
|
||||
} catch {
|
||||
// port 4096 not available, fall through to use port 0
|
||||
}
|
||||
}
|
||||
return Bun.serve({ ...args, port: opts.port })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user