diff --git a/server/src/desktop/mac.ts b/server/src/desktop/mac.ts index 3ebe67c..d3c552a 100644 --- a/server/src/desktop/mac.ts +++ b/server/src/desktop/mac.ts @@ -261,6 +261,11 @@ windows: async focusChannel(channel: string): Promise { try { + // Drop the marker KanbanCode drains on activation to auto-select this + // channel, written BEFORE we bring the app forward so it's on disk when + // applicationDidBecomeActive fires. A plain file (no deep link) keeps the + // quit-dialog fix intact; a write failure just means no auto-select. + this.writeFocusMarker(channel); const region = regionForSlot("top-left", await this.screen()); // Bring the ALREADY-RUNNING KanbanCode forward via accessibility, NOT the // kanbancode:// deep link. The deep link can relaunch a stale registered @@ -285,6 +290,20 @@ windows: } } + /** + * Write the channel slug to the marker KanbanCode reads (and drains) in + * applicationDidBecomeActive to auto-select that channel. Best-effort. + */ + private writeFocusMarker(channel: string): void { + try { + const marker = path.join(os.homedir(), ".kanban-code", "focus-channel"); + fs.mkdirSync(path.dirname(marker), { recursive: true }); + fs.writeFileSync(marker, channel); + } catch { + // best effort — no marker just means no auto-select, never a broken focus + } + } + async closeWindow(key: string): Promise { // A browser window we own: kill its app-instance pid. const browser = this.browserWindows.get(key);