From 64b564b52ba7d22ba8129821ab4b30542d971ff5 Mon Sep 17 00:00:00 2001 From: Stanton Burchett Date: Thu, 30 Jul 2026 14:50:01 -0600 Subject: Focus the emitting tab when a notification is clicked Resolve the OSC 9 onclick TODO: clicking a notification now brings the window to the front and selects the exact tab/pane that emitted the sequence. The title is read live from the tab each time instead of being captured once when the session is attached. Adds tabby-core as a dependency for AppService/HostWindowService. --- src/osc-notify-decorator.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/osc-notify-decorator.ts') diff --git a/src/osc-notify-decorator.ts b/src/osc-notify-decorator.ts index 7d32f1c..abfb796 100644 --- a/src/osc-notify-decorator.ts +++ b/src/osc-notify-decorator.ts @@ -1,25 +1,41 @@ import OscNotifyMiddleware from "./osc-notify-middleware"; import { Injectable } from "@angular/core"; import { TerminalDecorator, BaseSession, BaseTerminalTabComponent } from "tabby-terminal"; +import { AppService, HostWindowService } from "tabby-core"; @Injectable() export default class OscNotifyDecorator extends TerminalDecorator { + constructor( + private app: AppService, + private hostWindow: HostWindowService, + ) { + super(); + } + attach(tab: BaseTerminalTabComponent): void { // Subscribe to attach to future sessions in this tab tab.sessionChanged$.subscribe((session) => { if (session) { - this.attachToSession(session, (tab).title); + this.attachToSession(session, tab); } }); // Attach the current session for this tab if (tab.session) { - this.attachToSession(tab.session, (tab).title); + this.attachToSession(tab.session, tab); } } - private attachToSession(session: BaseSession, tabTitle: string) { - const middleware = new OscNotifyMiddleware(tabTitle); + private attachToSession(session: BaseSession, tab: BaseTerminalTabComponent) { + const middleware = new OscNotifyMiddleware( + () => (tab).title, + () => { + this.hostWindow.bringToFront(); + const parent = this.app.getParentTab(tab); + this.app.selectTab(parent ?? tab); + parent?.focus(tab); + }, + ); session.middleware.push(middleware); } -- cgit v1.3.1