summaryrefslogtreecommitdiff
path: root/src/osc-notify-middleware.ts
diff options
context:
space:
mode:
authorStanton Burchett <sburchett@medallia.com>2026-07-30 14:50:01 -0600
committerStanton Burchett <sburchett@medallia.com>2026-07-30 14:50:01 -0600
commit64b564b52ba7d22ba8129821ab4b30542d971ff5 (patch)
tree615cf77f12ac2281d671d4fcf0ed6925c353c7d7 /src/osc-notify-middleware.ts
parentb08d308aba5fed8a20b83b63b71911732b1e53a4 (diff)
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.
Diffstat (limited to 'src/osc-notify-middleware.ts')
-rw-r--r--src/osc-notify-middleware.ts16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/osc-notify-middleware.ts b/src/osc-notify-middleware.ts
index 15548f4..ad2946c 100644
--- a/src/osc-notify-middleware.ts
+++ b/src/osc-notify-middleware.ts
@@ -5,12 +5,14 @@ const oscPrefix = Buffer.from("\x1b]");
const oscSuffix = Buffer.from("\x07");
export default class OscNotifyMiddleware extends SessionMiddleware {
- tabTitle: string;
+ getTitle: () => string;
+ onClick: () => void;
- constructor(tabTitle: string) {
+ constructor(getTitle: () => string, onClick: () => void) {
super();
- this.tabTitle = tabTitle;
+ this.getTitle = getTitle;
+ this.onClick = onClick;
}
get cwdReported$(): Observable<string> {
@@ -22,6 +24,7 @@ export default class OscNotifyMiddleware extends SessionMiddleware {
private cwdReported = new Subject<string>();
private copyRequested = new Subject<string>();
+ private notifications: Notification[] = [];
feedFromSession(data: Buffer): void {
let startIndex = 0;
@@ -36,10 +39,11 @@ export default class OscNotifyMiddleware extends SessionMiddleware {
const oscCode = parseInt(oscCodeString);
if (oscCode === 9) {
- // TODO: onclick switch to tab
- new Notification(this.tabTitle, {
+ const notification = new Notification(this.getTitle() || "Terminal", {
body: oscParams[0]
});
+ notification.onclick = () => this.onClick();
+ this.notifications.push(notification);
} else {
continue;
}
@@ -49,6 +53,8 @@ export default class OscNotifyMiddleware extends SessionMiddleware {
}
close(): void {
+ this.notifications.forEach((notification) => notification.close());
+ this.notifications = [];
this.cwdReported.complete();
this.copyRequested.complete();
super.close();