feat(session): support unfocused agent windows (--no-focus) (#87)

`bsk session start --no-focus` opens the Agent Window in the background
without stealing focus. The flag threads focused=false through
CLI -> daemon IPC -> tool.session_start -> chrome.windows.create; an
omitted `focused` keeps the extension default (true) so older clients
are unaffected.

Reworked onto current main so it composes with #52 window sizing:
AgentWindowApi.create / SessionManager.start (extension), start_session
(CLI) and the daemon's session start now take options objects/structs
({ size, focused }) instead of colliding positional params.

Co-authored-by: alectimison-maker <alec.timison@gmail.com>
This commit is contained in:
BB-fatandalectimison-maker authored and GitHub committed 2026-08-12 19:58:53 +08:00
1 parent 0ce497f017
commit f443cfae74
17 files changed
+235 -43

No files matched your search

+10 -9
View File
@@ -25,6 +25,14 @@ export interface SessionManagerOptions {
now?: () => number;
}
/** Options for starting a session's Agent Window. */
export interface SessionStartOptions {
/** Optional Agent Window outer size in CSS pixels. */
size?: { width: number; height: number };
/** Defaults to true so existing clients keep visible Agent Windows. */
focused?: boolean;
}
/**
* Owner of all live agent sessions inside the extension.
*
@@ -128,18 +136,11 @@ export class SessionManager {
* Returns the created window id so callers can echo it back to the
* daemon in the `tool.session_start` reply.
*/
async start(
sessionId: string,
size?: { width: number; height: number },
): Promise<SessionContext> {
async start(sessionId: string, opts: SessionStartOptions = {}): Promise<SessionContext> {
if (this.sessions.has(sessionId)) {
throw new Error(`[bh] session ${sessionId} already exists`);
}
// Only pass `size` when given so the no-size call shape (and its
// chrome.windows.create payload) stays exactly as before.
const windowId = size
? await this.agentWindow.create(AGENT_WINDOW_HOME, size)
: await this.agentWindow.create(AGENT_WINDOW_HOME);
const windowId = await this.agentWindow.create(AGENT_WINDOW_HOME, opts);
await this.agentWindow.ensureActiveTab(windowId, AGENT_WINDOW_HOME);
const ctx: SessionContext = {
sessionId,