import OscNotifyMiddleware from "./osc-notify-middleware"; import { Injectable } from "@angular/core"; import { TerminalDecorator, BaseSession, BaseTerminalTabComponent } from "tabby-terminal"; @Injectable() export default class OscNotifyDecorator extends TerminalDecorator { attach(tab: BaseTerminalTabComponent): void { // Subscribe to attach to future sessions in this tab tab.sessionChanged$.subscribe((session) => { if (session) { this.attachToSession(session, (tab).title); } }); // Attach the current session for this tab if (tab.session) { this.attachToSession(tab.session, (tab).title); } } private attachToSession(session: BaseSession, tabTitle: string) { const middleware = new OscNotifyMiddleware(tabTitle); session.middleware.push(middleware); } }