tabby-paneworks 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patrick Schäfer
4
+ Copyright (c) 2026 Igor Halilović
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,149 @@
1
- # Temporary Holding Version
1
+ # Paneworks
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Workspaces for [Tabby](https://tabby.sh).** A workspace is a list of terminal panes, each with its own profile, folder and startup command. All of them start when the workspace opens. Paneworks arranges them in a grid that fits your window, and a sidebar in the workspace tab lets you show, hide, focus, sort, colour and edit them. Hiding is only visual: hidden panes keep running.
4
+
5
+ Made for running several long-lived sessions side by side (coding agents, dev servers, logs, tmux sessions) and switching between them without stopping any of them.
6
+
7
+ ![View all: four panes in a grid, sidebar on the left](https://raw.githubusercontent.com/padjon/tabby-paneworks/main/docs/screenshots/view-all.png)
8
+
9
+ ## Features
10
+
11
+ - **Automatic grid.** "View all" shows every switched-on pane. You set a minimum pane size; Paneworks fits as many panes as that allows, in as many rows as give each pane the most room, and rearranges when the window changes size.
12
+ - **Focus view.** Click a pane in the sidebar to see it alone, full size. Click it again to go back.
13
+ - **Every pane runs.** All panes start with the workspace, switched off or not. Hiding a pane never stops it; it comes back exactly as it was.
14
+ - **On/off switches and drag-and-drop order**, saved in the workspace.
15
+ - **Live titles.** Each pane's label shows the title its program sets (for example a coding agent's session title), optionally prefixed with a pane name. The tab itself always shows the workspace name.
16
+ - **Label colours** per pane, so you recognise panes at a glance.
17
+ - **NEW marker** on hidden panes that printed something since you last looked.
18
+ - **Startup commands** that wait for the shell to be ready.
19
+ - **Everything in the sidebar**: add, edit, restart and remove panes; rename, configure, create, switch and delete workspaces. No settings page.
20
+
21
+ ![Focus view: one pane full size](https://raw.githubusercontent.com/padjon/tabby-paneworks/main/docs/screenshots/focus.png)
22
+
23
+ ## Install
24
+
25
+ In Tabby: **Settings → Plugins**, search **paneworks**, **Install**, restart Tabby. Updates show up in the same place.
26
+
27
+ ## Getting started
28
+
29
+ 1. Click the **Paneworks** button (grid icon) in Tabby's toolbar and choose **New workspace**. It opens with one pane and the sidebar on the left.
30
+ 2. Click **+** next to "Panes" to add panes. For each pane set a name (optional), label colour, startup command, folder and profile, then **Save**. The pane starts right away.
31
+ 3. Click **View all** to see all switched-on panes in a grid.
32
+ 4. Click the workspace name at the top of the sidebar to rename it, set the minimum pane size or let it open when Tabby starts.
33
+
34
+ Next time, open the workspace from the toolbar button. If it is already open, the button brings its tab to the front.
35
+
36
+ When a workspace opens, you briefly see all of its panes: Tabby starts a terminal only once it has been on screen. As soon as every pane runs, Paneworks switches to "View all".
37
+
38
+ ## The sidebar
39
+
40
+ | Element | What it does |
41
+ |---|---|
42
+ | Workspace name (top) | Workspace menu: rename, minimum pane size, open when Tabby starts, switch to or open another workspace, new workspace, delete this one |
43
+ | « / » | Collapse or expand the sidebar |
44
+ | **View all** | All switched-on panes in a grid; shows how many are on screen out of how many are on |
45
+ | **+** | Add a pane (opens its editor) |
46
+ | Pane title | Focus view: this pane alone. Click again to go back to "View all" |
47
+ | Switch | On: part of "View all". Off: hidden, still running, reachable through its title |
48
+ | ⋮⋮ (drag the row) | Sort the panes; the order is the grid order |
49
+ | ⋯ | Edit the pane: name, label colour, startup command, folder, profile. **Restart** applies a changed command, folder or profile; **Remove** deletes the pane |
50
+
51
+ ![Pane editor in the sidebar](https://raw.githubusercontent.com/padjon/tabby-paneworks/main/docs/screenshots/pane-editor.png)
52
+
53
+ ### What the pane rows show
54
+
55
+ | Look | Meaning |
56
+ |---|---|
57
+ | Accent bar on the left, full brightness | On screen |
58
+ | Dimmed | Running, not on screen |
59
+ | Dimmer, switch off | Switched off (running, not in "View all") |
60
+ | Highlighted row | Shown alone (focus view) |
61
+ | **NEW** label | New output since the pane left the screen |
62
+ | "no room" under the title | Switched on, but doesn't fit at the minimum pane size |
63
+ | Small square before the title | The pane's label colour |
64
+
65
+ Hover over a row for the same information as a tooltip. On screen, every pane has a frame, the focused pane's frame uses the accent colour, and the bars between panes can be dragged to resize them.
66
+
67
+ ![Workspace menu](https://raw.githubusercontent.com/padjon/tabby-paneworks/main/docs/screenshots/workspace-menu.png)
68
+
69
+ ## How the grid is chosen
70
+
71
+ With a minimum pane size of W × H, the pane area fits `floor(width / W)` columns and `floor(height / H)` rows. Paneworks shows as many switched-on panes as fit, in their sidebar order, and among the arrangements that fit picks the one with the largest panes; rows are filled evenly, fuller rows first.
72
+
73
+ Examples for 600 × 260 px in a 1900 × 1000 px area: 3 panes → 2 + 1, 4 → 2 + 2, 5 → 2 + 2 + 1, 8 → 3 + 3 + 2. In 1200 × 700 px only 2 × 2 fit, so of 8 switched-on panes the first 4 are shown and the others are marked "no room" (they keep running).
74
+
75
+ ## Pane titles
76
+
77
+ A pane's label shows the title its program sets through the terminal. With a pane name it reads `name · title`, without one just the title. Renaming a pane through Tabby's own "Rename pane" keeps your name and stops the live title for that pane.
78
+
79
+ If a pane runs **tmux**, tmux keeps titles to itself by default. Add this to `~/.tmux.conf` to pass them on:
80
+
81
+ ```
82
+ set -g set-titles on
83
+ set -g set-titles-string "#{pane_title}"
84
+ ```
85
+
86
+ ## Configuration file
87
+
88
+ Workspaces are stored in Tabby's `config.yaml` under `paneworks.workspaces`. You normally never edit this by hand, but it is plain YAML:
89
+
90
+ ```yaml
91
+ paneworks:
92
+ workspaces:
93
+ - id: 0b7c… # any unique id
94
+ name: My project
95
+ minPaneWidth: 600 # optional, px (default 600)
96
+ minPaneHeight: 260 # optional, px (default 260)
97
+ launchOnStartup: false
98
+ panes: # sidebar and grid order
99
+ - id: 5f1e… # any unique id
100
+ name: api # optional
101
+ color: '#3b82f6' # optional label colour
102
+ profileId: local:powershell
103
+ cwd: C:\code\my-project
104
+ startupCommand: npm run dev
105
+ - id: 9a2d…
106
+ profileId: local:powershell
107
+ cwd: C:\code\my-project
108
+ startupCommand: npm test -- --watch
109
+ hidden: true # switched off
110
+ ```
111
+
112
+ ## Notes and limits
113
+
114
+ - Panes live as long as the workspace tab. Closing the tab closes all of its panes, hidden ones included. After a Tabby restart, the workspace tab comes back through Tabby's tab recovery and starts its panes again.
115
+ - If a pane's program exits, the pane closes; "View all" or its title starts it again.
116
+ - Paneworks rearranges panes through Tabby's split-tab internals (the same mechanism as Tabby's own pane drag and drop). Developed and tested with Tabby 1.0.231 on Windows. A major Tabby update could need a Paneworks update.
117
+ - Paneworks keeps its data under its own config key and profile ids, so it does not interfere with other workspace plugins.
118
+
119
+ ## Develop
120
+
121
+ ```
122
+ npm install
123
+ npm run build
124
+ ```
125
+
126
+ `.npmrc` sets `legacy-peer-deps`, so npm doesn't pull Tabby's own packages. The build writes `dist/`: the published package (plugin code, its `package.json`, README, LICENSE).
127
+
128
+ To try a local build in Tabby, link it in place of the published version and restart Tabby after each `npm run build`:
129
+
130
+ ```
131
+ cd %APPDATA%\tabby\plugins
132
+ npm uninstall tabby-paneworks
133
+ npm install --legacy-peer-deps <path to this repo>\dist
134
+ ```
135
+
136
+ Back to the published version: `npm uninstall tabby-paneworks`, then install it from Tabby's plugin manager. Console messages are prefixed `[Paneworks]` (Ctrl+Shift+I in Tabby).
137
+
138
+ ## Release
139
+
140
+ ```
141
+ npm version patch # or minor / major: bumps package.json, commits, tags vX.Y.Z
142
+ git push --follow-tags
143
+ ```
144
+
145
+ The tag runs `.github/workflows/release.yml`: build, publish to npm with trusted publishing (no token), GitHub release with generated notes.
146
+
147
+ ## License
148
+
149
+ MIT, see [LICENSE](LICENSE).
@@ -0,0 +1,4 @@
1
+ export declare const CONFIG_KEY: string;
2
+ export declare const DISPLAY_NAME: string;
3
+ export declare const IS_DEV: boolean;
4
+ //# sourceMappingURL=build-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../src/build-config.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,QAAuE,CAAA;AAC9F,eAAO,MAAM,YAAY,QAA2E,CAAA;AACpG,eAAO,MAAM,MAAM,SAAyD,CAAA"}
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { WorkspaceEditorService } from './services/workspaceEditor.service';
2
+ /**
3
+ * Paneworks: no settings page. The toolbar button opens and creates workspaces;
4
+ * everything else is managed in the sidebar of a workspace tab (LayoutService).
5
+ */
6
+ export default class PaneworksModule {
7
+ }
8
+ export { WorkspaceEditorService };
9
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAI3E;;;GAGG;AAWH,MAAM,CAAC,OAAO,OAAO,eAAe;CAAG;AAEvC,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("tabby-core"),require("tabby-terminal"));else if("function"==typeof define&&define.amd)define(["@angular/common","@angular/core","rxjs","rxjs/operators","tabby-core","tabby-terminal"],t);else{var n="object"==typeof exports?t(require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("tabby-core"),require("tabby-terminal")):t(e["@angular/common"],e["@angular/core"],e.rxjs,e["rxjs/operators"],e["tabby-core"],e["tabby-terminal"]);for(var a in n)("object"==typeof exports?exports:e)[a]=n[a]}}(global,(e,t,n,a,s,i)=>(()=>{"use strict";var r={358(t){t.exports=e},860(e){e.exports=t},961(e){e.exports=n},439(e){e.exports=a},650(e){e.exports=s},349(e){e.exports=i}};const o={};function p(e){const t=o[e];if(void 0!==t)return t.exports;const n=o[e]={exports:{}};return r[e](n,n.exports,p),n.exports}p.d=(e,t)=>{for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let c={};p.r(c),p.d(c,{WorkspaceEditorService:()=>C,default:()=>N});var l=p(860),d=p(358),h=p(650);const u="paneworks",w="Paneworks";let f=class extends h.ConfigProvider{constructor(){super(...arguments),this.defaults={[u]:{workspaces:[]}}}};function m(e){return"children"in e}function b(e){return e.children.flatMap(e=>m(e)?b(e):[e.paneId])}function g(e,t,n,a,s){if(e<=0)return[];const i=Math.max(1,Math.floor(t/Math.max(1,a))),r=Math.max(1,Math.floor(n/Math.max(1,s))),o=Math.min(e,i*r);let p=null;for(let e=1;e<=Math.min(o,r);e++){const r=Math.ceil(o/e);if(r>i)continue;const c=Math.min(t/r/a,n/e/s);(!p||c>p.score+1e-9)&&(p={rows:e,score:c})}const c=p?.rows??1,l=Math.floor(o/c),d=o%c;return Array.from({length:c},(e,t)=>l+(t<d?1:0))}function k(e,t){let n=0;const a=t.map(t=>{const a=e.slice(n,n+t);return n+=t,1===a.length?{paneId:a[0]}:{orientation:"horizontal",ratios:a.map(()=>1/a.length),children:a.map(e=>({paneId:e}))}});return 1===a.length&&m(a[0])?a[0]:{orientation:"vertical",ratios:a.map(()=>1/a.length),children:a}}function y(e){return Array.isArray(e.panes)||(e.panes=[]),e}f=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.Injectable)()],f);const v="paneworks:";function x(e){if("string"!=typeof e||!e.startsWith(v))return null;const[t,n]=e.slice(10).split(":");return t&&n?{workspaceId:t,paneId:n}:null}function P(e,t){const n=(e??"").trim(),a=(t??"").trim();return n?!a||a===n||a.startsWith(`${n} · `)?n:`${n} · ${a}`:a}function T(){return{id:W(),profileId:"",cwd:"",startupCommand:""}}const S=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316"],I=["columns","terminal","code","folder","home","briefcase","cog","database","server","cloud","rocket","flask","bug","wrench","cube","layer-group","sitemap","project-diagram"];function W(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}let C=class{constructor(e,t,n){this.config=e,this.notifications=t,this.profilesService=n,this.cachedProfiles=null,this.cacheTimestamp=0,this.CACHE_TTL=3e4}async getCachedProfiles(){const e=Date.now();return(!this.cachedProfiles||e-this.cacheTimestamp>this.CACHE_TTL)&&(this.cachedProfiles=await this.profilesService.getProfiles(),this.cacheTimestamp=e),this.cachedProfiles}getWorkspaces(){const e=this.config.store?.[u]?.workspaces??[];for(const t of e)Array.isArray(t.panes)||y(t);return e}async saveWorkspaceQuietly(e){const t=this.getWorkspaces(),n=t.findIndex(t=>t.id===e.id);-1!==n&&(t[n]=e,await this.saveWorkspaces(t))}minPaneSize(e){return{width:e.minPaneWidth||600,height:e.minPaneHeight||260}}planViewAll(e,t,n){const a=e.panes.filter(e=>!e.hidden).map(e=>e.id),s=this.minPaneSize(e),i=g(a.length,t,n,s.width,s.height),r=i.reduce((e,t)=>e+t,0),o=a.slice(0,r);return{tree:o.length?k(o,i):null,shown:o}}allPanesLayout(e,t,n){const a=e.panes.map(e=>e.id);if(!a.length)return null;const s=Math.max(1,t??window.innerWidth-210),i=Math.max(1,n??window.innerHeight-80);return k(a,g(a.length,s,i,1,1))}initialLayout(e){return this.allPanesLayout(e)}async saveWorkspaces(e){if(!this.config.store?.[u])throw new Error("Config store not initialized");this.config.store[u].workspaces=e,await this.saveConfig()}async addWorkspace(e){try{const t=this.getWorkspaces();t.push(e),await this.saveWorkspaces(t),this.notifications.info(`Workspace "${e.name}" created`)}catch(t){throw this.notifications.error(`Failed to create workspace "${e.name}"`),t}}async deleteWorkspace(e){const t=this.getWorkspaces(),n=t.find(t=>t.id===e);try{const a=t.filter(t=>t.id!==e);await this.saveWorkspaces(a),n&&this.notifications.info(`Workspace "${n.name}" deleted`)}catch(t){throw this.notifications.error(`Failed to delete workspace "${n?.name||e}"`),t}}async getAvailableProfiles(){return(await this.profilesService.getProfiles()).filter(e=>!e.id?.startsWith("split-layout:"))}cleanupOrphanedProfiles(){if(!this.config.store?.profiles)return;const e=this.config.store.profiles,t=`split-layout:${u}:`,n=e.filter(e=>!e.id?.startsWith(t));n.length!==e.length&&(this.config.store.profiles=n,this.config.save(),console.log(`[${w}] Cleaned up ${e.length-n.length} orphaned profiles`))}async generateTabbyProfile(e){await this.getCachedProfiles();const t=this.initialLayout(e);if(!t)return null;const n=this.sanitizeForProfileId(e.name);return{id:`split-layout:${u}:${n}:${e.id}`,type:"split-layout",name:e.name,group:w,icon:e.icon,color:e.color,isBuiltin:!1,options:{recoveryToken:this.generateRecoveryToken(t,e)}}}async createPaneToken(e,t){return await this.getCachedProfiles(),this.generatePaneToken(t,e.name,e.id)}generateRecoveryToken(e,t){return{type:"app:split-tab",orientation:"horizontal"===e.orientation?"h":"v",ratios:[...e.ratios],paneworksWorkspaceId:t.id,tabTitle:t.name,disableDynamicTitle:!0,children:e.children.map(e=>{if(m(e))return this.generateRecoveryToken(e,t);const n=t.panes.find(t=>t.id===e.paneId);return this.generatePaneToken(n,t.name,t.id)})}}generatePaneToken(e,t,n){const a=this.getProfileById(e.profileId),s=function(e,t){return`${v}${e}:${t}`}(n,e.id),i=P(e.name,"");if(!a)return{type:"app:local-tab",profile:{type:"local",name:"Shell",group:s},savedState:!1,tabTitle:e.name||"Shell",tabCustomTitle:i,paneworksWorkspaceId:n,disableDynamicTitle:!1};if(!this.isLocalProfile(a))return{type:`app:${a.type}-tab`,profile:{...a,group:s,disableDynamicTitle:!1},savedState:!1,tabTitle:e.name||a.name,tabCustomTitle:i,paneworksWorkspaceId:n,disableDynamicTitle:!1};const r=e.cwd||a.options?.cwd||"",o=this.isWslProfile(a),p=a.options?.args||[],c={restoreFromPTYID:!1,command:a.options?.command||"",args:o&&r?[...p,"--cd",r]:p,cwd:o?"":r,env:a.options?.env||{},width:null,height:null,pauseAfterExit:!1,runAsAdministrator:!1};return{type:"app:local-tab",profile:{id:a.id,type:"local",name:a.name||"Shell",group:s,options:c,icon:a.icon||"",color:a.color||"",disableDynamicTitle:!1,weight:0,isBuiltin:!1,isTemplate:!1,terminalColorScheme:null,behaviorOnSessionEnd:"auto"},savedState:!1,tabTitle:e.name||a.name||"Shell",tabCustomTitle:i,paneworksWorkspaceId:n,disableDynamicTitle:!1,cwd:o?"":r}}sanitizeForProfileId(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"workspace"}isLocalProfile(e){return"local"===e.type||e.type?.startsWith("local:")||!1}isWslProfile(e){if(e.id?.startsWith("local:wsl"))return!0;const t=(e.options?.command||"").toLowerCase();return"wsl.exe"===t||"wsl"===t||t.endsWith("\\wsl.exe")||t.endsWith("/wsl.exe")}getProfileById(e){return(this.config.store?.profiles??[]).find(t=>t.id===e)||this.cachedProfiles?.find(t=>t.id===e)}collectStartupCommands(e){return e.panes.filter(e=>e.startupCommand).map(e=>({paneId:e.id,command:e.startupCommand}))}getWorkspace(e){return this.getWorkspaces().find(t=>t.id===e)}async saveConfig(){try{await this.config.save()}catch(e){throw console.error(`[${w}] Save error:`,e),e}}};C=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.Injectable)({providedIn:"root"}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[h.ConfigService,h.NotificationsService,h.ProfilesService])],C);var O=p(349),A=p(961),R=p(439);const j=[0,300,1e3,3e3,8e3];let $=class{constructor(e,t){this.app=e,this.workspaces=t,this.workspaceSplitFound$=new A.Subject,this.pendingCommands=new Map,this.watchedSplits=new WeakSet,this.attachedPanes=new WeakSet,this.app.tabOpened$.subscribe(e=>this.onTabOpened(e))}registerCommands(e){for(const t of e)this.pendingCommands.set(t.paneId,t)}onTabOpened(e){e instanceof h.SplitTabComponent?this.watchSplit(e):e instanceof O.BaseTerminalTabComponent&&this.processPane(e,null)}watchSplit(e){if(this.watchedSplits.has(e))return;this.watchedSplits.add(e);const t=()=>this.scanSplit(e);e.initialized$?.subscribe({complete:t}),e.tabAdded$?.subscribe(()=>t());for(const e of j)setTimeout(t,e)}scanSplit(e){for(const t of e.getAllTabs())t instanceof O.BaseTerminalTabComponent&&this.processPane(t,e)}processPane(e,t){const n=x(e.profile?.group);n&&(t&&(this.pinSplitTitle(t,n.workspaceId),this.workspaceSplitFound$.next({split:t,workspaceId:n.workspaceId})),this.attachedPanes.has(e)||(this.attachedPanes.add(e),this.attachLabelSync(e,n.workspaceId,n.paneId),this.runPendingCommand(e,n.paneId)))}pinSplitTitle(e,t){const n=this.workspaces.getWorkspace(t)?.name;e.disableDynamicTitle=!0,n&&e.title!==n&&e.setTitle(n)}attachLabelSync(e,t,n){const a=e;a.disableDynamicTitle=!1;let s=e.customTitle,i=!0;const r=()=>{if(!i)return;if(e.customTitle!==s)return void(i=!1);const r=this.workspaces.getWorkspace(t),o=r?function(e,t){return e.panes.find(e=>e.id===t)}(r,n)?.name:void 0,p=P(o,e.title);p&&p!==e.customTitle&&(s=p,"function"==typeof a.setCustomTitle?a.setCustomTitle(p):e.customTitle=p)},o=e.setTitle.bind(e);e.setTitle=e=>{o(e),r()},r()}runPendingCommand(e,t,n=!1){const a=this.pendingCommands.get(t);if(!a?.command)return;this.pendingCommands.delete(t);const s=a.command,i=()=>{console.log(`[${w}] Sending startup command:`,s),e.sendInput(s+"\r"),this.clearProfileArgs(e)},r=e.sessionChanged$;if(!e.session&&r&&!n)return this.pendingCommands.set(t,a),void r.pipe((0,A.first)(e=>!!e),(0,A.timeout)(5e3),(0,R.catchError)(()=>(0,A.of)(null))).subscribe(()=>this.runPendingCommand(e,t,!0));e.session?.output$?e.session.output$.pipe((0,A.first)(),(0,A.timeout)(2e3),(0,R.catchError)(()=>(0,A.of)(null))).subscribe(()=>setTimeout(i,100)):setTimeout(i,500)}clearProfileArgs(e){const t=e.profile;t?.options?.args&&(t.options.args=[])}};$=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.Injectable)(),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[h.AppService,C])],$);const E=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#06b6d4","#f97316"];let z=class{constructor(e,t,n,a,s,i){this.app=e,this.profilesService=t,this.runtime=n,this.workspaces=a,this.tabsService=s,this.tabRecovery=i,this.states=new WeakMap,this.active=new Set,this.resizeTimer=null,this.profiles=[],this.watchedSessions=new WeakSet,this.runtime.workspaceSplitFound$.subscribe(({split:e,workspaceId:t})=>this.attach(e,t)),window.addEventListener("resize",()=>{this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>this.refreshAllGrids(),250)})}findOpenTab(e){for(const t of this.active)if(t.workspaceId===e)return t.split;for(const t of this.app.tabs)if(t instanceof h.SplitTabComponent&&t.getAllTabs().some(t=>x(t.profile?.group)?.workspaceId===e))return t;return null}async openWorkspace(e){const t=this.findOpenTab(e);if(t)return void this.app.selectTab(t);const n=this.workspaces.getWorkspace(e);if(!n)return;const a=this.workspaces.collectStartupCommands(n);a.length&&this.runtime.registerCommands(a);const s=await this.workspaces.generateTabbyProfile(n);s&&this.profilesService.openNewTabForProfile(s)}async createWorkspace(){await this.loadProfiles();const e=new Set(this.workspaces.getWorkspaces().map(e=>e.name));let t=1;for(;e.has(`Workspace ${t}`);)t++;const n=function(e=""){return{id:W(),name:e,icon:I[Math.floor(Math.random()*I.length)],color:S[Math.floor(Math.random()*S.length)],panes:[T(),T()],launchOnStartup:!1}}(`Workspace ${t}`),a=this.profiles.find(e=>"local"===e.type||e.type?.startsWith("local:"))??this.profiles[0];n.panes=[{...T(),profileId:a?.id??""}],await this.workspaces.addWorkspace(n),await this.openWorkspace(n.id)}async loadProfiles(){this.profiles.length||(this.profiles=await this.workspaces.getAvailableProfiles())}attach(e,t){const n=this.states.get(e);if(n)return void(n.sidebar?.isConnected||this.mountSidebar(n));const a={split:e,workspaceId:t,view:{kind:"all"},appliedPlan:null,parked:new Map,sidebar:null,collapsed:this.loadCollapsed(t),busy:!1,dragging:!1,editingPaneId:null,menuOpen:!1,timer:null,unseen:new Set,starting:!0,leftAt:new Map};this.states.set(e,a),this.active.add(a),this.loadProfiles(),e.destroyed$.subscribe(()=>{for(const e of a.parked.values())e.destroy();a.parked.clear(),a.timer&&clearInterval(a.timer),a.sidebar?.remove(),this.active.delete(a)}),e.visibility$?.subscribe(e=>{e&&setTimeout(()=>this.refreshGrid(a),50)}),this.mountSidebar(a),a.timer=setInterval(()=>this.render(a),1e3),this.startAllPanes(a)}async showAll(e,t=!1){const n=this.workspaces.getWorkspace(e.workspaceId),a=this.paneArea(e);if(!n||!a)return;const s=this.workspaces.planViewAll(n,a.width,a.height),i=JSON.stringify(s.tree);i!==e.appliedPlan&&console.log(`[${w}] View all:`,{area:a,shown:s.shown.length,min:this.workspaces.minPaneSize(n)});const r="all"===e.view.kind;e.view={kind:"all"},!s.tree||!t&&r&&i===e.appliedPlan||await this.apply(e,n,s.tree)&&(e.appliedPlan=i),this.render(e,!0)}async showFocus(e,t){const n=this.workspaces.getWorkspace(e.workspaceId);if(!n)return;const a={orientation:"horizontal",ratios:[1],children:[{paneId:t}]};await this.apply(e,n,a)&&(e.view={kind:"focus",paneId:t},e.appliedPlan=null),this.render(e,!0)}async reapplyView(e){"focus"===e.view.kind?await this.showFocus(e,e.view.paneId):await this.showAll(e,!0)}refreshGrid(e){"all"!==e.view.kind||e.busy||e.starting||this.showAll(e)}async startAllPanes(e){const t=e.view;e.starting=!0;try{const t=this.workspaces.getWorkspace(e.workspaceId);if(!t)return;const n=await this.waitFor(()=>this.paneArea(e),3e3),a=t.panes.some(t=>!this.livePanes(e).has(t.id)),s=this.workspaces.allPanesLayout(t,n?.width,n?.height);a&&s&&await this.apply(e,t,s),await this.waitFor(()=>{const t=[...this.livePanes(e).values()];return!(!t.length||!t.every(e=>e.session))||null},8e3)}finally{e.starting=!1}"focus"===t.kind?await this.showFocus(e,t.paneId):await this.showAll(e,!0)}async waitFor(e,t){const n=Date.now()+t;for(;;){const t=e();if(t)return t;if(Date.now()>n)return null;await new Promise(e=>setTimeout(e,100))}}refreshAllGrids(){for(const e of this.active)this.refreshGrid(e)}paneArea(e){const t=this.splitElement(e)?.getBoundingClientRect();return t&&t.width>0&&t.height>0?{width:t.width,height:t.height}:null}async apply(e,t,n){if(e.busy)return!1;e.busy=!0;try{const a=e.split,s=new Map(t.panes.map(e=>[e.id,e])),i=this.livePanes(e),r=b(n).filter(e=>s.has(e));for(const e of r)if(!i.has(e)){const n=await this.createPane(t,s.get(e));n&&i.set(e,n)}const o=r.filter(e=>i.has(e));if(!o.length)return!1;for(const t of e.split.getAllTabs()){const n=this.paneIdOf(t);n&&o.includes(n)||(t.removeFromContainer(),a.viewRefs?.delete(t),t.parent=null,n?(e.parked.set(n,t),e.leftAt.set(n,Date.now())):t.destroy())}const p=this.buildContainer(n,i);if(!p)return!1;a.maximizedTab=null,a.root=p;for(const t of o){const n=i.get(t);e.unseen.delete(t),n.clearActivity(),a.viewRefs?.has(n)||(e.parked.delete(t),n.parent=e.split,n.emitVisibility?.(a.visibility?.value??!0),a.attachTabView(n),a.onAfterTabAdded(n))}return a.layout(),e.split.focus(i.get(o[0])),a.recoveryStateChangedHint?.next(),this.nudgeResize(),setTimeout(()=>this.applyLabelColors(e,this.workspaces.getWorkspace(e.workspaceId)),100),!0}catch(e){return console.error(`[${w}] Layout change failed:`,e),!1}finally{e.busy=!1}}buildContainer(e,t){const n=[],a=[];if(e.children.forEach((s,i)=>{const r=m(s)?this.buildContainer(s,t):t.get(s.paneId)??null;r&&(n.push(r),a.push(e.ratios[i]??1))}),!n.length)return null;const s=a.reduce((e,t)=>e+t,0)||1,i=new h.SplitContainer;return i.orientation="horizontal"===e.orientation?"h":"v",i.children=n,i.ratios=a.map(e=>e/s),i}async createPane(e,t){try{const n=await this.workspaces.createPaneToken(e,t),a=await this.tabRecovery.recoverTab(n);return a?(t.startupCommand&&this.runtime.registerCommands([{paneId:t.id,command:t.startupCommand}]),this.tabsService.create(a)):null}catch(e){return console.error(`[${w}] Could not create pane:`,t,e),null}}livePanes(e){const t=new Map;for(const n of e.split.getAllTabs()){const e=this.paneIdOf(n);e&&t.set(e,n)}for(const[n,a]of e.parked)t.set(n,a);return t}paneIdOf(e){return x(e.profile?.group)?.paneId??null}nudgeResize(){setTimeout(()=>window.dispatchEvent(new Event("resize")),50)}async toggleShown(e,t){const n=this.workspaces.getWorkspace(e.workspaceId),a=n?.panes.find(e=>e.id===t);n&&a&&(a.hidden?delete a.hidden:a.hidden=!0,await this.workspaces.saveWorkspaceQuietly(n),"all"===e.view.kind?await this.showAll(e):this.render(e,!0))}async movePane(e,t,n){const a=this.workspaces.getWorkspace(e.workspaceId);if(!a)return;const s=a.panes.findIndex(e=>e.id===t);if(-1===s||t===n)return;const[i]=a.panes.splice(s,1),r=n?a.panes.findIndex(e=>e.id===n):-1;a.panes.splice(-1===r?a.panes.length:r,0,i),await this.workspaces.saveWorkspaceQuietly(a),"all"===e.view.kind?await this.showAll(e):this.render(e,!0)}async addPane(e){const t=this.workspaces.getWorkspace(e.workspaceId);if(!t)return;await this.loadProfiles();const n=t.panes[t.panes.length-1],a={...T(),profileId:n?.profileId||this.profiles[0]?.id||"",cwd:n?.cwd||""};t.panes.push(a),await this.workspaces.saveWorkspaceQuietly(t),e.editingPaneId=a.id,e.menuOpen=!1,this.render(e,!0)}async savePane(e,t,n){const a=this.workspaces.getWorkspace(e.workspaceId),s=a?.panes.find(e=>e.id===t);if(a&&s){Object.assign(s,n);for(const e of["name","color"])s[e]||delete s[e];await this.workspaces.saveWorkspaceQuietly(a),e.editingPaneId=null,this.render(e,!0),this.livePanes(e).has(t)||await this.startAllPanes(e)}}async restartPane(e,t){const n=this.workspaces.getWorkspace(e.workspaceId),a=n?.panes.find(e=>e.id===t);if(!n||!a)return;const s=this.livePanes(e).get(t),i=await this.createPane(n,a);i&&(s&&e.parked.get(t)===s?(e.parked.set(t,i),s.destroy()):s&&s.parent===e.split?(i.parent=e.split,e.split.replaceTab(s,i),e.split.viewRefs?.delete(s),s.destroy(),e.split.layout(),e.split.focus(i),this.nudgeResize()):e.parked.set(t,i),this.render(e,!0))}async removePane(e,t){const n=this.workspaces.getWorkspace(e.workspaceId),a=n?.panes.find(e=>e.id===t);if(!n||!a)return;if(n.panes.length<=1)return void window.alert("A workspace needs at least one pane. Delete the workspace from its menu instead.");const s=a.name||a.startupCommand||"this pane";if(!window.confirm(`Remove "${s}" from ${n.name}? Its terminal is closed.`))return;n.panes=n.panes.filter(e=>e.id!==t),await this.workspaces.saveWorkspaceQuietly(n),e.editingPaneId=null;const i=this.livePanes(e).get(t);i&&i.parent===e.split&&("focus"===e.view.kind&&e.view.paneId===t&&(e.view={kind:"all"}),await this.reapplyView(e));const r=this.livePanes(e).get(t);if(r&&r.parent===e.split&&e.split.getAllTabs().length<=1){const t=n.panes[0];delete t.hidden,await this.workspaces.saveWorkspaceQuietly(n),await this.showFocus(e,t.id)}e.parked.delete(t),this.livePanes(e).get(t)?.destroy(),i?.destroy(),this.render(e,!0)}async saveWorkspaceSettings(e,t){const n=this.workspaces.getWorkspace(e.workspaceId);if(n){n.name=t.name.trim()||n.name;for(const e of["minPaneWidth","minPaneHeight"]){const a=t[e];a&&a>0?n[e]=Math.round(a):delete n[e]}t.launchOnStartup?n.launchOnStartup=!0:n.launchOnStartup=!1,await this.workspaces.saveWorkspaceQuietly(n),e.split.setTitle(n.name),e.menuOpen=!1,"all"===e.view.kind?await this.showAll(e):this.render(e,!0)}}async deleteWorkspace(e){const t=this.workspaces.getWorkspace(e.workspaceId);if(!t)return;if(!window.confirm(`Delete the workspace "${t.name}"? Its tab and all its panes are closed.`))return;await this.workspaces.deleteWorkspace(t.id);const n=this.app;"function"==typeof n.closeTab?n.closeTab(e.split,!1):e.split.destroy()}splitElement(e){const t=e.split;for(const e of[t.hostView,t.viewContainerEmbeddedRef]){const t=e?.rootNodes?.[0];if(t instanceof HTMLElement)return t}return null}mountSidebar(e){const t=this.splitElement(e),n=t?.parentElement;t&&n?(e.sidebar||(e.sidebar=document.createElement("div"),e.sidebar.className="paneworks-sidebar",this.ensureStyles()),n.insertBefore(e.sidebar,t),t.setAttribute("data-paneworks",""),this.render(e,!0),this.nudgeResize(),setTimeout(()=>this.refreshGrid(e),100)):setTimeout(()=>{!e.sidebar?.isConnected&&this.active.has(e)&&this.mountSidebar(e)},500)}applyLabelColors(e,t){const n=this.splitElement(e);if(!n||!t)return;const a=new Map(t.panes.map(e=>[e.id,e.color])),s=Array.from(n.querySelectorAll(":scope > split-tab-pane-label")),i=e.split.getAllTabs();s.forEach((e,t)=>{const n=e.querySelector(".custom-name");if(!n)return;const s=i[t]?this.paneIdOf(i[t]):null,r=s?a.get(s):void 0;r?(n.style.background=r,n.style.color=function(e){const t=e.replace("#","");if(!/^[0-9a-f]{6}$/i.test(t))return"#fff";const[n,a,s]=[0,2,4].map(e=>parseInt(t.slice(e,e+2),16)/255).map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*a+.0722*s>.4?"#000":"#fff"}(r)):(n.style.removeProperty("background"),n.style.removeProperty("color"))})}watchOutput(e){for(const[t,n]of this.livePanes(e)){const a=n.session;a?.output$&&!this.watchedSessions.has(a)&&(this.watchedSessions.add(a),a.output$.subscribe(()=>{n.parent===e.split||e.unseen.has(t)||Date.now()-(e.leftAt.get(t)??0)<2500||e.unseen.add(t)}))}}render(e,t=!1){const n=e.sidebar;if(!n||!n.isConnected||e.dragging)return;if(this.watchOutput(e),this.applyLabelColors(e,this.workspaces.getWorkspace(e.workspaceId)),!t&&(e.editingPaneId||e.menuOpen))return;const a=this.workspaces.getWorkspace(e.workspaceId),s=this.livePanes(e),i=new Set(e.split.getAllTabs().map(e=>this.paneIdOf(e))),r=JSON.stringify([e.collapsed,e.view,e.editingPaneId,e.menuOpen,a,a?.panes.map(t=>{const n=s.get(t.id);return[n?.customTitle,n?.title,e.unseen.has(t.id),i.has(t.id)]})]);if(!t&&n.__pwSignature===r)return;n.__pwSignature=r,n.classList.toggle("collapsed",e.collapsed),n.style.flex=`0 0 ${e.collapsed?22:210}px`,n.textContent="";const o=this.button("pw-icon-btn pw-toggle",e.collapsed?"»":"«",e.collapsed?"Show sidebar":"Hide sidebar",()=>{e.collapsed=!e.collapsed,this.saveCollapsed(e.workspaceId,e.collapsed),this.render(e,!0),this.nudgeResize()});if(e.collapsed||!a)return void n.append(o);const p=this.node("div","pw-header"),c=this.button("pw-ws","","Workspace menu",()=>{e.menuOpen=!e.menuOpen,e.editingPaneId=null,this.render(e,!0)});c.append(this.node("span","pw-ws-name",a.name),this.node("span","pw-caret",e.menuOpen?"▴":"▾")),p.append(c,o),n.append(p),e.menuOpen&&n.append(this.workspaceMenu(e,a));const l=a.panes.filter(e=>!e.hidden),d=l.filter(e=>i.has(e.id)).length,h=this.node("div","pw-row pw-all"+("all"===e.view.kind?" active":""));h.append(this.node("span","pw-main","View all"),this.node("span","pw-count","all"===e.view.kind?`${d} / ${l.length}`:`${l.length} on`)),h.title="Show all switched-on panes in a grid",h.onclick=()=>this.showAll(e,!0),n.append(h);const u=this.node("div","pw-section");u.append(this.node("span","","Panes"),this.button("pw-icon-btn pw-add","+","Add a pane",()=>this.addPane(e))),n.append(u);const w="focus"===e.view.kind?e.view.paneId:null,f=this.node("div","pw-list");for(const t of a.panes)f.append(this.paneRow(e,t,s.get(t.id),i.has(t.id),w)),e.editingPaneId===t.id&&f.append(this.paneEditor(e,t));const m=this.node("div","pw-drop-end");this.makeDropTarget(e,m,null),f.append(m),n.append(f)}paneRow(e,t,n,a,s){const i=(n?n.customTitle||n.title:"")||t.name||t.startupCommand||"New pane",r=[t.name,t.startupCommand].filter(Boolean).join(" · "),o=!t.hidden&&!a&&"all"===e.view.kind,p=!a&&e.unseen.has(t.id),c=["pw-row","pw-pane"];a&&c.push("onscreen"),t.id===s&&c.push("focused"),t.hidden&&c.push("off"),e.editingPaneId===t.id&&c.push("editing");const l=this.node("div",c.join(" "));l.title=[a?"On screen":n?"Running, not on screen":"Not running (shown again by View all or its title)",t.hidden?'switched off (not in "View all")':o?"switched on, but no room at the minimum pane size":""].filter(Boolean).join(" · "),l.draggable=!0,l.append(this.node("span","pw-handle","⋮⋮")),l.addEventListener("dragstart",n=>{e.dragging=!0,n.dataTransfer?.setData("text/plain",t.id),n.dataTransfer&&(n.dataTransfer.effectAllowed="move"),l.classList.add("dragging")}),l.addEventListener("dragend",()=>{e.dragging=!1,l.classList.remove("dragging"),this.render(e,!0)}),this.makeDropTarget(e,l,t.id);const d=this.node("span","pw-pane-color"+(t.color?"":" none"));t.color&&(d.style.background=t.color),d.title=t.color?`Label colour ${t.color}`:"No label colour",l.append(d);const h=this.node("span","pw-text"),u=this.node("span","pw-main");if(u.append(this.node("span","pw-name",i)),p){const e=this.node("span","pw-news","new");e.title="New output since it left the screen",u.append(e)}h.append(u),(r||o)&&h.append(this.node("span","pw-sub",[r,o?"no room":""].filter(Boolean).join(" · "))),h.onclick=()=>{t.id===s?this.showAll(e,!0):this.showFocus(e,t.id)},h.title=t.id===s?'Back to "View all"':"Show this pane alone";const w=this.node("label","pw-switch");w.title=t.hidden?'Off: not in "View all"':'On: in "View all"';const f=document.createElement("input");f.type="checkbox",f.checked=!t.hidden,f.onchange=()=>this.toggleShown(e,t.id),w.append(f,this.node("span","pw-slider")),w.addEventListener("click",e=>e.stopPropagation());const m=this.button("pw-icon-btn pw-more","⋯","Edit pane",()=>{e.editingPaneId=e.editingPaneId===t.id?null:t.id,e.menuOpen=!1,this.render(e,!0)});return l.append(h,w,m),l}paneEditor(e,t){const n=this.node("div","pw-form"),a=this.input("text",t.name??"","optional"),s=this.input("text",t.startupCommand??"","e.g. c 1"),i=this.input("text",t.cwd??"","C:\\path or /home/user"),r=document.createElement("select");r.className="pw-input";const o=document.createElement("option");o.value="",o.textContent="-- profile --",r.append(o);for(const e of this.profiles){const t=document.createElement("option");t.value=e.id,t.textContent=e.name,r.append(t)}r.value=t.profileId??"";let p=t.color??"";const c=this.node("div","pw-colors"),l=document.createElement("input");l.type="color",l.className="pw-color-custom",l.title="Custom colour";const d=()=>{c.querySelectorAll(".pw-swatch").forEach(e=>{e.classList.toggle("selected",e.dataset.color===p)}),l.classList.toggle("selected",!!p&&!E.includes(p)),p&&(l.value=p)};for(const e of["",...E]){const t=this.button("pw-swatch"+(e?"":" none"),"",e||"No colour",()=>{p=e,d()});t.dataset.color=e,e&&(t.style.background=e),c.append(t)}l.addEventListener("input",()=>{p=l.value,d()}),c.append(l),d(),n.append(this.field("Name",a),this.field("Label colour",c),this.field("Startup command",s),this.field("Folder",i),this.field("Profile",r),this.node("div","pw-hint","Command, folder and profile apply when the pane (re)starts."));const h=()=>this.savePane(e,t.id,{name:a.value.trim(),color:p,startupCommand:s.value.trim(),cwd:i.value.trim(),profileId:r.value});for(const t of[a,s,i])t.addEventListener("keydown",t=>{"Enter"===t.key&&h(),"Escape"===t.key&&(e.editingPaneId=null,this.render(e,!0))});const u=this.node("div","pw-actions");return u.append(this.button("pw-btn primary","Save","Save the pane settings",h),this.button("pw-btn","Restart","Save, then close and start the pane again",async()=>{await h(),await this.restartPane(e,t.id)}),this.button("pw-btn danger","Remove","Remove the pane from the workspace",()=>this.removePane(e,t.id))),n.append(u),setTimeout(()=>a.focus(),0),n}workspaceMenu(e,t){const n=this.node("div","pw-form pw-menu"),a=this.input("text",t.name,"Workspace name"),s=this.input("number",t.minPaneWidth?String(t.minPaneWidth):"",String(600)),i=this.input("number",t.minPaneHeight?String(t.minPaneHeight):"",String(260));s.classList.add("pw-size"),i.classList.add("pw-size");const r=this.node("div","pw-size-row");r.append(s,this.node("span","","×"),i,this.node("span","","px"));const o=document.createElement("input");o.type="checkbox",o.checked=!!t.launchOnStartup;const p=this.node("label","pw-check");p.append(o,this.node("span","","Open when Tabby starts")),n.append(this.field("Name",a),this.field("Minimum pane size",r),this.node("div","pw-hint",'"View all" fits as many switched-on panes as this size allows.'),p);const c=()=>this.saveWorkspaceSettings(e,{name:a.value,minPaneWidth:Number(s.value)||null,minPaneHeight:Number(i.value)||null,launchOnStartup:o.checked});for(const t of[a,s,i])t.addEventListener("keydown",t=>{"Enter"===t.key&&c(),"Escape"===t.key&&(e.menuOpen=!1,this.render(e,!0))});const l=this.node("div","pw-actions");l.append(this.button("pw-btn primary","Save","Save the workspace settings",c),this.button("pw-btn","Close","Close the menu",()=>{e.menuOpen=!1,this.render(e,!0)})),n.append(l),n.append(this.node("div","pw-menu-title","Workspaces"));for(const a of this.workspaces.getWorkspaces()){const s=a.id===t.id,i=!s&&!!this.findOpenTab(a.id),r=this.button("pw-menu-item"+(s?" current":""),"",s?"This workspace":i?"Switch to its tab":"Open it",()=>{s||(e.menuOpen=!1,this.render(e,!0),this.openWorkspace(a.id))});r.append(this.node("span","pw-name",a.name),this.node("span","pw-count",s?"this":i?"open":"")),n.append(r)}return n.append(this.button("pw-menu-item","+ New workspace","Create a workspace with one pane",()=>{e.menuOpen=!1,this.render(e,!0),this.createWorkspace()}),this.button("pw-menu-item danger","Delete this workspace…","Delete it and close its tab",()=>this.deleteWorkspace(e))),n}makeDropTarget(e,t,n){t.addEventListener("dragover",n=>{e.dragging&&(n.preventDefault(),n.dataTransfer&&(n.dataTransfer.dropEffect="move"),t.classList.add("drop-before"))}),t.addEventListener("dragleave",()=>t.classList.remove("drop-before")),t.addEventListener("drop",a=>{a.preventDefault(),t.classList.remove("drop-before");const s=a.dataTransfer?.getData("text/plain");e.dragging=!1,s&&this.movePane(e,s,n)})}node(e,t,n){const a=document.createElement(e);return t&&(a.className=t),void 0!==n&&(a.textContent=n),a}button(e,t,n,a){const s=document.createElement("button");return s.type="button",s.className=e,s.textContent=t,s.title=n,s.addEventListener("click",e=>{e.stopPropagation(),a()}),s}input(e,t,n){const a=document.createElement("input");return a.type=e,a.className="pw-input",a.value=t,a.placeholder=n,a.addEventListener("keydown",e=>e.stopPropagation()),a}field(e,t){const n=this.node("label","pw-field");return n.append(this.node("span","pw-label",e),t),n}ensureStyles(){if(document.getElementById("paneworks-sidebar-styles"))return;const e=document.createElement("style");e.id="paneworks-sidebar-styles",e.textContent="\n /* Pane frames in Paneworks tabs: every pane gets a frame and a small gap,\n the pane with keyboard focus an accent frame. Tabby positions the panes\n (class \"child\") absolutely; border-box keeps them inside their slot. */\n [data-paneworks] > .child {\n box-sizing: border-box;\n border: 3px solid var(--theme-bg-more, rgba(0,0,0,.35));\n border-radius: 6px;\n overflow: hidden;\n transition: border-color .12s;\n }\n [data-paneworks] > .child.focused {\n border-color: var(--theme-primary, #4c9aff);\n }\n [data-paneworks] split-tab-pane-label .custom-name {\n font-weight: 600;\n }\n /* Split handles: Tabby's handle is a 10px band centred on the border between two\n panes. A bright 4px bar in its middle (inset 3px works for both orientations)\n stands out against the panes; brighter on hover, accent while dragging. */\n [data-paneworks] > split-tab-spanner::after {\n content: '';\n position: absolute;\n inset: 3px;\n border-radius: 2px;\n background: rgba(255, 255, 255, .30);\n background: color-mix(in srgb, var(--theme-fg, #fff) 32%, transparent);\n pointer-events: none;\n transition: background .12s;\n }\n [data-paneworks] > split-tab-spanner:hover::after {\n background: rgba(255, 255, 255, .55);\n background: color-mix(in srgb, var(--theme-fg, #fff) 60%, transparent);\n }\n [data-paneworks] > split-tab-spanner.active::after {\n background: var(--theme-primary, #4c9aff);\n }\n\n .paneworks-sidebar {\n --pw-accent: var(--theme-primary, #4c9aff);\n display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;\n background: var(--theme-bg-more, rgba(0,0,0,.25));\n border-right: 1px solid var(--theme-bg-more-2, rgba(255,255,255,.08));\n color: var(--theme-fg, inherit); font-size: 12px; user-select: none;\n }\n .paneworks-sidebar.collapsed { align-items: center; }\n .paneworks-sidebar button { font: inherit; color: inherit; }\n .paneworks-sidebar .pw-icon-btn {\n background: none; border: none; opacity: .6; cursor: pointer; padding: 2px 6px; line-height: 1; font-size: 13px;\n }\n .paneworks-sidebar .pw-icon-btn:hover { opacity: 1; }\n .paneworks-sidebar.collapsed .pw-toggle { margin-top: 8px; }\n\n .paneworks-sidebar .pw-header { display: flex; align-items: center; padding: 6px 4px 4px 4px; }\n .paneworks-sidebar .pw-ws {\n flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: none; border: none;\n padding: 4px 6px; border-radius: 4px; cursor: pointer; font-weight: 600; text-align: left;\n }\n .paneworks-sidebar .pw-ws:hover { background: rgba(127,127,127,.15); }\n .paneworks-sidebar .pw-ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .paneworks-sidebar .pw-caret { opacity: .5; font-size: 10px; }\n\n .paneworks-sidebar .pw-section {\n display: flex; align-items: center; justify-content: space-between;\n padding: 10px 6px 2px 10px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .6;\n }\n .paneworks-sidebar .pw-add { font-size: 15px; opacity: .9; }\n\n .paneworks-sidebar .pw-row {\n display: flex; align-items: center; gap: 6px; padding: 5px 4px 5px 4px;\n border-left: 3px solid transparent; border-top: 2px solid transparent;\n }\n .paneworks-sidebar .pw-row:hover { background: rgba(127,127,127,.10); }\n .paneworks-sidebar .pw-all { cursor: pointer; padding-left: 10px; }\n .paneworks-sidebar .pw-all .pw-main { flex: 1; font-weight: 600; }\n .paneworks-sidebar .pw-all.active { border-left-color: var(--pw-accent); background: rgba(127,127,127,.14); }\n .paneworks-sidebar .pw-count { font-size: 10px; opacity: .55; }\n\n /* Pane states: on screen = accent bar + full brightness; running elsewhere = dimmed;\n switched off = dimmer; focus view = highlighted row. */\n .paneworks-sidebar .pw-pane .pw-text { opacity: .6; }\n .paneworks-sidebar .pw-pane.onscreen { border-left-color: var(--pw-accent); }\n .paneworks-sidebar .pw-pane.onscreen .pw-text { opacity: 1; }\n .paneworks-sidebar .pw-pane.off .pw-text { opacity: .38; }\n .paneworks-sidebar .pw-pane.focused { background: rgba(127,127,127,.20); }\n .paneworks-sidebar .pw-pane.focused .pw-name { font-weight: 600; }\n .paneworks-sidebar .pw-pane.editing { background: rgba(127,127,127,.14); }\n\n .paneworks-sidebar .pw-pane-color { flex: 0 0 8px; height: 8px; border-radius: 2px; }\n .paneworks-sidebar .pw-pane-color.none { border: 1px dashed rgba(127,127,127,.5); box-sizing: border-box; }\n .paneworks-sidebar .pw-colors { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }\n .paneworks-sidebar .pw-swatch {\n width: 16px; height: 16px; padding: 0; border-radius: 3px; cursor: pointer;\n border: 2px solid transparent; box-sizing: border-box;\n }\n .paneworks-sidebar .pw-swatch.none {\n background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(127,127,127,.5) 3px 4px);\n border-color: rgba(127,127,127,.4);\n }\n .paneworks-sidebar .pw-swatch.selected, .paneworks-sidebar .pw-color-custom.selected {\n border-color: var(--theme-fg, #fff);\n }\n .paneworks-sidebar .pw-color-custom {\n width: 22px; height: 18px; padding: 0; border: 2px solid transparent; border-radius: 3px;\n background: none; cursor: pointer;\n }\n .paneworks-sidebar .pw-handle { cursor: grab; opacity: .25; font-size: 10px; letter-spacing: -2px; }\n .paneworks-sidebar .pw-row:hover .pw-handle { opacity: .7; }\n .paneworks-sidebar .pw-row.dragging { opacity: .35; }\n .paneworks-sidebar .drop-before { border-top-color: var(--pw-accent); }\n .paneworks-sidebar .pw-drop-end { flex: 1; min-height: 24px; border-top: 2px solid transparent; }\n\n .paneworks-sidebar .pw-text { display: flex; flex-direction: column; min-width: 0; flex: 1; cursor: pointer; }\n .paneworks-sidebar .pw-main { display: flex; align-items: center; gap: 5px; min-width: 0; }\n .paneworks-sidebar .pw-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .paneworks-sidebar .pw-sub { font-size: 10px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .paneworks-sidebar .pw-news {\n flex: none; font-size: 9px; line-height: 1; padding: 2px 4px; border-radius: 3px;\n background: var(--pw-accent); color: var(--theme-bg, #000); font-weight: 600; text-transform: uppercase;\n }\n .paneworks-sidebar .pw-more { opacity: .35; font-size: 14px; }\n .paneworks-sidebar .pw-row:hover .pw-more, .paneworks-sidebar .pw-pane.editing .pw-more { opacity: .9; }\n\n .paneworks-sidebar .pw-switch { position: relative; flex: 0 0 26px; height: 14px; cursor: pointer; }\n .paneworks-sidebar .pw-switch input { opacity: 0; width: 0; height: 0; position: absolute; }\n .paneworks-sidebar .pw-slider {\n position: absolute; inset: 0; border-radius: 7px; background: rgba(127,127,127,.35); transition: background .15s;\n }\n .paneworks-sidebar .pw-slider::before {\n content: ''; position: absolute; left: 2px; top: 2px; width: 10px; height: 10px; border-radius: 50%;\n background: var(--theme-fg, #fff); transition: transform .15s;\n }\n .paneworks-sidebar .pw-switch input:checked + .pw-slider { background: var(--pw-accent); }\n .paneworks-sidebar .pw-switch input:checked + .pw-slider::before { transform: translateX(12px); }\n\n .paneworks-sidebar .pw-form {\n display: flex; flex-direction: column; gap: 6px; margin: 2px 6px 6px 7px; padding: 8px;\n border-radius: 4px; background: rgba(127,127,127,.10); user-select: text;\n }\n .paneworks-sidebar .pw-menu { margin-top: 0; }\n .paneworks-sidebar .pw-field { display: flex; flex-direction: column; gap: 2px; margin: 0; }\n .paneworks-sidebar .pw-label { font-size: 10px; opacity: .6; }\n .paneworks-sidebar .pw-input {\n width: 100%; box-sizing: border-box; padding: 3px 6px; font: inherit; color: inherit; border-radius: 3px;\n background: var(--theme-bg, rgba(0,0,0,.3)); border: 1px solid rgba(127,127,127,.35);\n }\n .paneworks-sidebar .pw-input:focus { outline: none; border-color: var(--pw-accent); }\n .paneworks-sidebar .pw-size-row { display: flex; align-items: center; gap: 4px; }\n .paneworks-sidebar .pw-size { width: 64px; }\n .paneworks-sidebar .pw-check { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }\n .paneworks-sidebar .pw-hint { font-size: 10px; opacity: .55; }\n .paneworks-sidebar .pw-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }\n .paneworks-sidebar .pw-btn {\n padding: 3px 8px; border-radius: 3px; cursor: pointer; background: rgba(127,127,127,.2);\n border: 1px solid transparent;\n }\n .paneworks-sidebar .pw-btn:hover { background: rgba(127,127,127,.3); }\n .paneworks-sidebar .pw-btn.primary { background: var(--pw-accent); color: var(--theme-bg, #000); }\n .paneworks-sidebar .pw-btn.danger:hover { background: #c0392b; color: #fff; }\n .paneworks-sidebar .pw-menu-title { margin-top: 8px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .6; }\n .paneworks-sidebar .pw-menu-item {\n display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;\n background: none; border: none; padding: 4px 6px; border-radius: 3px; cursor: pointer; text-align: left;\n }\n .paneworks-sidebar .pw-menu-item:hover { background: rgba(127,127,127,.2); }\n .paneworks-sidebar .pw-menu-item.current { cursor: default; font-weight: 600; }\n .paneworks-sidebar .pw-menu-item.danger:hover { background: #c0392b; color: #fff; }\n ",document.head.appendChild(e)}loadCollapsed(e){try{return"1"===localStorage.getItem(`paneworks-sidebar-collapsed:${e}`)}catch{return!1}}saveCollapsed(e,t){try{localStorage.setItem(`paneworks-sidebar-collapsed:${e}`,t?"1":"0")}catch{}}};z=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.Injectable)(),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[h.AppService,h.ProfilesService,$,C,h.TabsService,h.TabRecoveryService])],z);const L="__new__";let M=class extends h.ToolbarButtonProvider{constructor(e,t,n){super(),this.workspaceService=e,this.app=t,this.layout=n,this.waitForTabbyReady().then(()=>{this.workspaceService.cleanupOrphanedProfiles(),this.launchStartupWorkspaces()})}waitForTabbyReady(){return new Promise(e=>{let t=-1;const n=()=>{const a=this.app.tabs.length;a===t?e():(t=a,setTimeout(n,300))};setTimeout(n,500)})}async launchStartupWorkspaces(){for(const e of this.workspaceService.getWorkspaces().filter(e=>e.launchOnStartup))this.layout.findOpenTab(e.id)?console.log(`[${w}] Workspace "${e.name}" already open, skipping`):await this.layout.openWorkspace(e.id)}provide(){return[{icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <rect x="3" y="3" width="7" height="7"/>\n <rect x="14" y="3" width="7" height="7"/>\n <rect x="14" y="14" width="7" height="7"/>\n <rect x="3" y="14" width="7" height="7"/>\n</svg>',title:w,weight:5,click:()=>this.showWorkspaceSelector()}]}async showWorkspaceSelector(){const e=this.workspaceService.getWorkspaces().map(e=>({name:e.name,description:`${e.panes.length} panes${this.layout.findOpenTab(e.id)?" · open":""}`,icon:e.icon||"columns",color:e.color,result:e.id}));e.push({name:"New workspace",description:"Create a workspace with one pane; set it up in its sidebar",icon:"plus",color:void 0,result:L});const t=await this.app.showSelector(w,e);t===L?await this.layout.createWorkspace():t&&await this.layout.openWorkspace(t)}};M=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.Injectable)(),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[C,h.AppService,z])],M);let D=class{};D=function(e,t,n,a){var s,i=arguments.length,r=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,a);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(r=(i<3?s(r):i>3?s(t,n,r):s(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}([(0,l.NgModule)({imports:[d.CommonModule],providers:[{provide:h.ConfigProvider,useClass:f,multi:!0},{provide:h.ToolbarButtonProvider,useClass:M,multi:!0},C,$,z]})],D);const N=D;return c})());
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ /*!**********************************!*\
2
+ !*** ./src/index.ts + 7 modules ***!
3
+ \**********************************/
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,mBAAoBA,QAAQ,iBAAkBA,QAAQ,QAASA,QAAQ,kBAAmBA,QAAQ,cAAeA,QAAQ,wBACtJ,GAAqB,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,kBAAmB,gBAAiB,OAAQ,iBAAkB,aAAc,kBAAmBJ,OACnG,CACJ,IAAIM,EAAuB,iBAAZL,QAAuBD,EAAQG,QAAQ,mBAAoBA,QAAQ,iBAAkBA,QAAQ,QAASA,QAAQ,kBAAmBA,QAAQ,cAAeA,QAAQ,mBAAqBH,EAAQD,EAAK,mBAAoBA,EAAK,iBAAkBA,EAAW,KAAGA,EAAK,kBAAmBA,EAAK,cAAeA,EAAK,mBAC3T,IAAI,IAAIQ,KAAKD,GAAuB,iBAAZL,QAAuBA,QAAUF,GAAMQ,GAAKD,EAAEC,EACvE,CACA,CAT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AAAoK,WACGE,KAJPmP,GCDE,IAAMkB,EAAN,QAAMA,E,mUAAe,GAVnC,IAAAC,UAAS,CACRC,QAAS,CAAC,EAAAC,cACVC,UAAW,CACT,CAAEZ,QAAS,EAAA3e,eAAgBwf,SAAUzf,EAA+B0f,OAAO,GAC3E,CAAEd,QAAS,EAAAT,sBAAuBsB,SAAUvB,EAA0BwB,OAAO,GAC7Ejb,EACAuG,EACA+D,MAGiBqQ,G","sources":["webpack://tabby-paneworks/webpack/universalModuleDefinition","webpack://tabby-paneworks/external umd \"@angular/common\"","webpack://tabby-paneworks/external umd \"@angular/core\"","webpack://tabby-paneworks/external umd \"rxjs\"","webpack://tabby-paneworks/external umd \"rxjs/operators\"","webpack://tabby-paneworks/external umd \"tabby-core\"","webpack://tabby-paneworks/external umd \"tabby-terminal\"","webpack://tabby-paneworks/webpack/bootstrap","webpack://tabby-paneworks/webpack/runtime/define property getters","webpack://tabby-paneworks/webpack/runtime/hasOwnProperty shorthand","webpack://tabby-paneworks/webpack/runtime/make namespace object","webpack://tabby-paneworks/./src/build-config.ts","webpack://tabby-paneworks/./src/providers/config.provider.ts","webpack://tabby-paneworks/./src/models/workspace.model.ts","webpack://tabby-paneworks/./src/services/workspaceEditor.service.ts","webpack://tabby-paneworks/./src/services/paneRuntime.service.ts","webpack://tabby-paneworks/./src/services/layout.service.ts","webpack://tabby-paneworks/./src/providers/toolbar.provider.ts","webpack://tabby-paneworks/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@angular/common\"), require(\"@angular/core\"), require(\"rxjs\"), require(\"rxjs/operators\"), require(\"tabby-core\"), require(\"tabby-terminal\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@angular/common\", \"@angular/core\", \"rxjs\", \"rxjs/operators\", \"tabby-core\", \"tabby-terminal\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"@angular/common\"), require(\"@angular/core\"), require(\"rxjs\"), require(\"rxjs/operators\"), require(\"tabby-core\"), require(\"tabby-terminal\")) : factory(root[\"@angular/common\"], root[\"@angular/core\"], root[\"rxjs\"], root[\"rxjs/operators\"], root[\"tabby-core\"], root[\"tabby-terminal\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(global, (__WEBPACK_EXTERNAL_MODULE__358__, __WEBPACK_EXTERNAL_MODULE__860__, __WEBPACK_EXTERNAL_MODULE__961__, __WEBPACK_EXTERNAL_MODULE__439__, __WEBPACK_EXTERNAL_MODULE__650__, __WEBPACK_EXTERNAL_MODULE__349__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__358__;","module.exports = __WEBPACK_EXTERNAL_MODULE__860__;","module.exports = __WEBPACK_EXTERNAL_MODULE__961__;","module.exports = __WEBPACK_EXTERNAL_MODULE__439__;","module.exports = __WEBPACK_EXTERNAL_MODULE__650__;","module.exports = __WEBPACK_EXTERNAL_MODULE__349__;","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter/value functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// Build-time constants injected by webpack DefinePlugin\r\ndeclare const __CONFIG_KEY__: string\r\ndeclare const __DISPLAY_NAME__: string\r\ndeclare const __IS_DEV__: boolean\r\n\r\nexport const CONFIG_KEY = typeof __CONFIG_KEY__ !== 'undefined' ? __CONFIG_KEY__ : 'paneworks'\r\nexport const DISPLAY_NAME = typeof __DISPLAY_NAME__ !== 'undefined' ? __DISPLAY_NAME__ : 'Paneworks'\r\nexport const IS_DEV = typeof __IS_DEV__ !== 'undefined' ? __IS_DEV__ : false\r\n","import { Injectable } from '@angular/core'\r\nimport { ConfigProvider } from 'tabby-core'\r\nimport { CONFIG_KEY } from '../build-config'\r\n\r\n@Injectable()\r\nexport class WorkspaceEditorConfigProvider extends ConfigProvider {\r\n defaults = {\r\n [CONFIG_KEY]: {\r\n workspaces: [],\r\n },\r\n }\r\n}\r\n","// Tabby profile interfaces\nexport interface TabbyProfileOptions {\n command?: string\n args?: string[]\n cwd?: string\n env?: Record<string, string>\n restoreFromPTYID?: boolean\n width?: number | null\n height?: number | null\n pauseAfterExit?: boolean\n runAsAdministrator?: boolean\n}\n\nexport interface TabbyProfile {\n id: string\n type: string\n name: string\n group?: string\n icon?: string\n color?: string\n options?: TabbyProfileOptions\n isBuiltin?: boolean\n isTemplate?: boolean\n weight?: number\n disableDynamicTitle?: boolean\n terminalColorScheme?: string | null\n behaviorOnSessionEnd?: string\n}\n\nexport interface TabbyRecoveryToken {\n type: string\n orientation?: 'h' | 'v'\n ratios?: number[]\n children?: TabbyRecoveryToken[]\n profile?: Partial<TabbyProfile>\n savedState?: boolean\n tabTitle?: string\n tabCustomTitle?: string\n disableDynamicTitle?: boolean\n cwd?: string\n // Allow custom properties (matches Tabby's RecoveryToken interface)\n [key: string]: any\n}\n\nexport interface TabbySplitLayoutProfile {\n id: string\n type: 'split-layout'\n name: string\n group: string\n icon?: string\n color?: string\n isBuiltin: boolean\n options: {\n recoveryToken: TabbyRecoveryToken\n }\n}\n\n// Workspace interfaces\nexport interface WorkspacePane {\n id: string\n name?: string\n profileId: string\n cwd?: string\n startupCommand?: string\n /** Switched off in the sidebar: not part of \"View all\" (still reachable by focus view). */\n hidden?: boolean\n /** Background of the pane label (CSS colour, e.g. #3b82f6); none = Tabby's default. */\n color?: string\n}\n\n/** Black or white, whichever reads better on the given #rrggbb background. */\nexport function readableTextColor(background: string): string {\n const hex = background.replace('#', '')\n if (!/^[0-9a-f]{6}$/i.test(hex)) return '#fff'\n const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)\n .map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4))\n const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b\n return luminance > 0.4 ? '#000' : '#fff'\n}\n\nexport interface Workspace {\n id: string\n name: string\n icon?: string\n color?: string\n /** All panes, in sidebar and grid order. */\n panes: WorkspacePane[]\n /** Smallest pane size in px; decides how many panes fit and in how many rows. */\n minPaneWidth?: number\n minPaneHeight?: number\n launchOnStartup?: boolean\n}\n\nexport const DEFAULT_MIN_PANE_WIDTH = 600\nexport const DEFAULT_MIN_PANE_HEIGHT = 260\n\n/** Tree used internally to build Tabby's split layout. */\nexport interface LayoutPaneRef {\n paneId: string\n}\n\nexport interface LayoutSplit {\n orientation: 'horizontal' | 'vertical'\n ratios: number[]\n children: (LayoutPaneRef | LayoutSplit)[]\n}\n\nexport function isLayoutSplit(node: LayoutPaneRef | LayoutSplit): node is LayoutSplit {\n return 'children' in node\n}\n\n/** Pane ids of a layout tree in reading order. */\nexport function layoutPaneIds(split: LayoutSplit): string[] {\n return split.children.flatMap((c) => isLayoutSplit(c) ? layoutPaneIds(c) : [c.paneId])\n}\n\n/**\n * Grid plan: how many panes go in each row.\n * Fits as many of `count` panes as the minimum size allows in width x height,\n * and among the arrangements that fit picks the one with the largest panes\n * (relative to the minimum size); rows are filled evenly, fuller rows first.\n * Examples (min 600x260, area 1900x1000, capacity 3x3): 3 panes -> [2, 1];\n * 4 -> [2, 2]; 5 -> [2, 2, 1]; 8 -> [3, 3, 2]. In 1200x700 (capacity 2x2)\n * 8 panes -> [2, 2]: only the first 4 are shown.\n */\nexport function planGrid(count: number, width: number, height: number, minWidth: number, minHeight: number): number[] {\n if (count <= 0) return []\n const maxCols = Math.max(1, Math.floor(width / Math.max(1, minWidth)))\n const maxRows = Math.max(1, Math.floor(height / Math.max(1, minHeight)))\n const shown = Math.min(count, maxCols * maxRows)\n let best: { rows: number, score: number } | null = null\n for (let rows = 1; rows <= Math.min(shown, maxRows); rows++) {\n const perRow = Math.ceil(shown / rows)\n if (perRow > maxCols) continue\n const score = Math.min(width / perRow / minWidth, height / rows / minHeight)\n if (!best || score > best.score + 1e-9) best = { rows, score }\n }\n const rows = best?.rows ?? 1\n const base = Math.floor(shown / rows)\n const extra = shown % rows\n return Array.from({ length: rows }, (_, i) => base + (i < extra ? 1 : 0))\n}\n\n/** Layout tree for panes arranged by a grid plan (rows stacked, panes side by side). */\nexport function gridTree(paneIds: string[], rows: number[]): LayoutSplit {\n let offset = 0\n const rowNodes = rows.map((n): LayoutPaneRef | LayoutSplit => {\n const ids = paneIds.slice(offset, offset + n)\n offset += n\n return ids.length === 1\n ? { paneId: ids[0] }\n : { orientation: 'horizontal', ratios: ids.map(() => 1 / ids.length), children: ids.map((paneId) => ({ paneId })) }\n })\n if (rowNodes.length === 1 && isLayoutSplit(rowNodes[0])) return rowNodes[0]\n return { orientation: 'vertical', ratios: rowNodes.map(() => 1 / rowNodes.length), children: rowNodes }\n}\n\n/** Makes sure a stored workspace has a pane list (e.g. one edited by hand in config.yaml). */\nexport function normalizeWorkspace(workspace: Workspace): Workspace {\n if (!Array.isArray(workspace.panes)) {\n workspace.panes = []\n }\n return workspace\n}\n\n/**\n * Hidden marker that identifies a workspace pane at runtime.\n * Stored in the pane's profile `group` field: Tabby keeps that field on the tab\n * (including after app restart recovery) and never shows it on a running tab.\n * An unknown group id makes Tabby skip group defaults, nothing else.\n */\nexport const PANE_MARKER_PREFIX = 'paneworks:'\n\nexport function makePaneMarker(workspaceId: string, paneId: string): string {\n return `${PANE_MARKER_PREFIX}${workspaceId}:${paneId}`\n}\n\nexport function parsePaneMarker(group: unknown): { workspaceId: string, paneId: string } | null {\n if (typeof group !== 'string' || !group.startsWith(PANE_MARKER_PREFIX)) {\n return null\n }\n const [workspaceId, paneId] = group.slice(PANE_MARKER_PREFIX.length).split(':')\n return workspaceId && paneId ? { workspaceId, paneId } : null\n}\n\n/**\n * Text of a pane label: the program's title, prefixed by the pane name when one is set.\n * Examples: ('C1', 'Claude Code') -> 'C1 · Claude Code'; ('', 'Claude Code') -> 'Claude Code'.\n */\nexport function formatPaneLabel(paneName: string | undefined, programTitle: string | undefined): string {\n const name = (paneName ?? '').trim()\n const title = (programTitle ?? '').trim()\n if (!name) return title\n if (!title || title === name || title.startsWith(`${name} · `)) return name\n return `${name} · ${title}`\n}\n\n/** Finds a pane of a workspace by id. */\nexport function findPane(workspace: Workspace, paneId: string): WorkspacePane | undefined {\n return workspace.panes.find((p) => p.id === paneId)\n}\n\n/**\n * Creates a new pane with default configuration.\n * @returns A new WorkspacePane with generated UUID and empty settings\n */\nexport function createDefaultPane(): WorkspacePane {\n return {\n id: generateUUID(),\n profileId: '',\n cwd: '',\n startupCommand: '',\n }\n}\n\n// Color palette for workspaces\nconst WORKSPACE_COLORS = [\n '#3b82f6', // blue\n '#10b981', // emerald\n '#f59e0b', // amber\n '#ef4444', // red\n '#8b5cf6', // violet\n '#ec4899', // pink\n '#06b6d4', // cyan\n '#f97316', // orange\n]\n\n// Icon list for workspaces\nconst WORKSPACE_ICONS = [\n 'columns', 'terminal', 'code', 'folder', 'home', 'briefcase',\n 'cog', 'database', 'server', 'cloud', 'rocket', 'flask',\n 'bug', 'wrench', 'cube', 'layer-group', 'sitemap', 'project-diagram'\n]\n\n/** Returns a random color from the workspace color palette. */\nexport function getRandomColor(): string {\n return WORKSPACE_COLORS[Math.floor(Math.random() * WORKSPACE_COLORS.length)]\n}\n\n/** Returns a random icon from the workspace icon set. */\nexport function getRandomIcon(): string {\n return WORKSPACE_ICONS[Math.floor(Math.random() * WORKSPACE_ICONS.length)]\n}\n\n/**\n * Creates a new workspace with default configuration.\n * @param name - Display name for the workspace (optional)\n * @returns A new Workspace with generated UUID, random icon/color and two panes\n */\nexport function createDefaultWorkspace(name: string = ''): Workspace {\n return {\n id: generateUUID(),\n name,\n icon: getRandomIcon(),\n color: getRandomColor(),\n panes: [createDefaultPane(), createDefaultPane()],\n launchOnStartup: false,\n }\n}\n\n/** Generates a random UUID v4 string. */\nexport function generateUUID(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0\n const v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n}\n\n/**\n * Creates a deep clone of an object, preserving type information.\n * More efficient than JSON.parse(JSON.stringify()) for simple objects.\n * @param obj - The object to clone\n * @returns A deep copy of the object\n */\nexport function deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== 'object') {\n return obj\n }\n if (Array.isArray(obj)) {\n return obj.map(item => deepClone(item)) as T\n }\n const cloned = {} as T\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n cloned[key] = deepClone(obj[key])\n }\n }\n return cloned\n}\n","import { Injectable } from '@angular/core'\nimport { ConfigService, NotificationsService, ProfilesService } from 'tabby-core'\nimport {\n Workspace,\n WorkspacePane,\n LayoutSplit,\n isLayoutSplit,\n generateUUID,\n TabbyProfile,\n TabbyRecoveryToken,\n TabbySplitLayoutProfile,\n makePaneMarker,\n formatPaneLabel,\n normalizeWorkspace,\n planGrid,\n gridTree,\n DEFAULT_MIN_PANE_WIDTH,\n DEFAULT_MIN_PANE_HEIGHT,\n} from '../models/workspace.model'\n\n/** Width of the Paneworks sidebar in a workspace tab (px). */\nexport const SIDEBAR_WIDTH = 210\n/** Tab bar and window chrome, used to estimate the pane area before the tab exists (px). */\nconst CHROME_HEIGHT = 80\nimport { CONFIG_KEY, DISPLAY_NAME } from '../build-config'\nimport { PendingCommand } from './paneRuntime.service'\n\n@Injectable({ providedIn: 'root' })\nexport class WorkspaceEditorService {\n private cachedProfiles: TabbyProfile[] | null = null\n private cacheTimestamp: number = 0\n private readonly CACHE_TTL = 30000 // 30 seconds\n\n constructor(\n private config: ConfigService,\n private notifications: NotificationsService,\n private profilesService: ProfilesService\n ) {}\n\n private async getCachedProfiles(): Promise<TabbyProfile[]> {\n const now = Date.now()\n if (!this.cachedProfiles || now - this.cacheTimestamp > this.CACHE_TTL) {\n this.cachedProfiles = (await this.profilesService.getProfiles()) as TabbyProfile[]\n this.cacheTimestamp = now\n }\n return this.cachedProfiles\n }\n\n /** Returns all saved workspaces from config (old tree-shaped ones converted to a pane list). */\n getWorkspaces(): Workspace[] {\n const workspaces: Workspace[] = this.config.store?.[CONFIG_KEY]?.workspaces ?? []\n for (const workspace of workspaces) {\n if (!Array.isArray(workspace.panes)) normalizeWorkspace(workspace)\n }\n return workspaces\n }\n\n /**\n * Saves one workspace's changed fields (pane order, switches) without a notification.\n * Used by the sidebar.\n */\n async saveWorkspaceQuietly(workspace: Workspace): Promise<void> {\n const workspaces = this.getWorkspaces()\n const index = workspaces.findIndex((w) => w.id === workspace.id)\n if (index === -1) return\n workspaces[index] = workspace\n await this.saveWorkspaces(workspaces)\n }\n\n /** Minimum pane size of a workspace, with defaults. */\n minPaneSize(workspace: Workspace): { width: number, height: number } {\n return {\n width: workspace.minPaneWidth || DEFAULT_MIN_PANE_WIDTH,\n height: workspace.minPaneHeight || DEFAULT_MIN_PANE_HEIGHT,\n }\n }\n\n /**\n * \"View all\" grid of a workspace for a pane area: the switched-on panes in order,\n * as many as fit. Returns the tree and the ids of the panes that fit.\n */\n planViewAll(workspace: Workspace, width: number, height: number): { tree: LayoutSplit | null, shown: string[] } {\n const visible = workspace.panes.filter((p) => !p.hidden).map((p) => p.id)\n const min = this.minPaneSize(workspace)\n const rows = planGrid(visible.length, width, height, min.width, min.height)\n const count = rows.reduce((a, b) => a + b, 0)\n const shown = visible.slice(0, count)\n return { tree: shown.length ? gridTree(shown, rows) : null, shown }\n }\n\n /**\n * Grid with every pane of a workspace, switched off ones included, ignoring the\n * minimum size. A workspace opens with it: Tabby starts a terminal's shell only once\n * the terminal has been on screen, and every pane must run. The sidebar then switches\n * to \"View all\" (see LayoutService.startAllPanes).\n */\n allPanesLayout(workspace: Workspace, width?: number, height?: number): LayoutSplit | null {\n const ids = workspace.panes.map((p) => p.id)\n if (!ids.length) return null\n const w = Math.max(1, width ?? window.innerWidth - SIDEBAR_WIDTH)\n const h = Math.max(1, height ?? window.innerHeight - CHROME_HEIGHT)\n return gridTree(ids, planGrid(ids.length, w, h, 1, 1))\n }\n\n private initialLayout(workspace: Workspace): LayoutSplit | null {\n return this.allPanesLayout(workspace)\n }\n\n /**\n * Saves the workspace list to config.\n * @throws Error if config store is not initialized\n */\n async saveWorkspaces(workspaces: Workspace[]): Promise<void> {\n if (!this.config.store?.[CONFIG_KEY]) {\n throw new Error('Config store not initialized')\n }\n this.config.store[CONFIG_KEY].workspaces = workspaces\n await this.saveConfig()\n }\n\n /** Adds a new workspace and shows notification. */\n async addWorkspace(workspace: Workspace): Promise<void> {\n try {\n const workspaces = this.getWorkspaces()\n workspaces.push(workspace)\n await this.saveWorkspaces(workspaces)\n this.notifications.info(`Workspace \"${workspace.name}\" created`)\n } catch (error) {\n this.notifications.error(`Failed to create workspace \"${workspace.name}\"`)\n throw error\n }\n }\n\n /** Deletes a workspace by ID and shows notification. */\n async deleteWorkspace(workspaceId: string): Promise<void> {\n const workspaces = this.getWorkspaces()\n const workspace = workspaces.find((w) => w.id === workspaceId)\n try {\n const filtered = workspaces.filter((w) => w.id !== workspaceId)\n await this.saveWorkspaces(filtered)\n if (workspace) {\n this.notifications.info(`Workspace \"${workspace.name}\" deleted`)\n }\n } catch (error) {\n this.notifications.error(`Failed to delete workspace \"${workspace?.name || workspaceId}\"`)\n throw error\n }\n }\n\n /** Returns all profiles available for use in workspaces (local, SSH, serial, etc.). */\n async getAvailableProfiles(): Promise<TabbyProfile[]> {\n const allProfiles = await this.profilesService.getProfiles()\n return allProfiles.filter(\n (p) => !p.id?.startsWith('split-layout:')\n ) as TabbyProfile[]\n }\n\n /**\n * Cleanup orphaned profiles from previous plugin versions.\n * Call this once on plugin init.\n */\n cleanupOrphanedProfiles(): void {\n if (!this.config.store?.profiles) {\n return\n }\n const profiles: TabbyProfile[] = this.config.store.profiles\n const prefix = `split-layout:${CONFIG_KEY}:`\n const filtered = profiles.filter((p) => !p.id?.startsWith(prefix))\n if (filtered.length !== profiles.length) {\n this.config.store.profiles = filtered\n this.config.save()\n console.log(`[${DISPLAY_NAME}] Cleaned up ${profiles.length - filtered.length} orphaned profiles`)\n }\n }\n\n /**\n * Generates a Tabby split-layout profile from a workspace for opening:\n * the \"View all\" grid of its switched-on panes; the others start when shown.\n */\n async generateTabbyProfile(workspace: Workspace): Promise<TabbySplitLayoutProfile | null> {\n await this.getCachedProfiles()\n const tree = this.initialLayout(workspace)\n if (!tree) return null\n const safeName = this.sanitizeForProfileId(workspace.name)\n return {\n id: `split-layout:${CONFIG_KEY}:${safeName}:${workspace.id}`,\n type: 'split-layout',\n name: workspace.name,\n group: DISPLAY_NAME,\n icon: workspace.icon,\n color: workspace.color,\n isBuiltin: false,\n options: {\n recoveryToken: this.generateRecoveryToken(tree, workspace),\n },\n }\n }\n\n /** Token for one pane of a workspace, used to create panes on demand (layouts, focus view). */\n async createPaneToken(workspace: Workspace, pane: WorkspacePane): Promise<TabbyRecoveryToken> {\n await this.getCachedProfiles()\n return this.generatePaneToken(pane, workspace.name, workspace.id)\n }\n\n private generateRecoveryToken(split: LayoutSplit, workspace: Workspace): TabbyRecoveryToken {\n return {\n type: 'app:split-tab',\n orientation: split.orientation === 'horizontal' ? 'h' : 'v',\n ratios: [...split.ratios],\n paneworksWorkspaceId: workspace.id,\n // The outer tab always shows the workspace name, never the pane titles\n tabTitle: workspace.name,\n disableDynamicTitle: true,\n children: split.children.map((child) => {\n if (isLayoutSplit(child)) {\n return this.generateRecoveryToken(child, workspace)\n }\n const pane = workspace.panes.find((p) => p.id === child.paneId)!\n return this.generatePaneToken(pane, workspace.name, workspace.id)\n }),\n }\n }\n\n private generatePaneToken(pane: WorkspacePane, workspaceName: string, workspaceId: string): TabbyRecoveryToken {\n const baseProfile = this.getProfileById(pane.profileId)\n\n // Marker: lets PaneRuntimeService find this pane (startup command, live label)\n // without putting anything visible on it. Initial label: the pane name.\n const marker = makePaneMarker(workspaceId, pane.id)\n const initialLabel = formatPaneLabel(pane.name, '')\n\n if (!baseProfile) {\n return {\n type: 'app:local-tab',\n profile: {\n type: 'local',\n name: 'Shell',\n group: marker,\n },\n savedState: false,\n tabTitle: pane.name || 'Shell',\n tabCustomTitle: initialLabel,\n paneworksWorkspaceId: workspaceId,\n disableDynamicTitle: false,\n }\n }\n\n // Non-local profiles (SSH, serial, telnet): pass profile through, Tabby handles the rest\n if (!this.isLocalProfile(baseProfile)) {\n return {\n type: `app:${baseProfile.type}-tab`,\n profile: {\n ...baseProfile,\n group: marker,\n disableDynamicTitle: false,\n },\n savedState: false,\n tabTitle: pane.name || baseProfile.name,\n tabCustomTitle: initialLabel,\n paneworksWorkspaceId: workspaceId,\n disableDynamicTitle: false,\n }\n }\n\n // Local profiles: build options with CWD/WSL handling\n const rawCwd = pane.cwd || baseProfile.options?.cwd || ''\n const isWsl = this.isWslProfile(baseProfile)\n const baseArgs = baseProfile.options?.args || []\n\n const options = {\n restoreFromPTYID: false,\n command: baseProfile.options?.command || '',\n // WSL: inject --cd to set Linux CWD directly (bypasses fs.existsSync validation)\n args: isWsl && rawCwd ? [...baseArgs, '--cd', rawCwd] : baseArgs,\n // WSL: don't set cwd (Unix paths fail fs.existsSync on Windows)\n cwd: isWsl ? '' : rawCwd,\n env: baseProfile.options?.env || {},\n width: null,\n height: null,\n pauseAfterExit: false,\n runAsAdministrator: false,\n }\n\n // Note: startupCommand is handled via sendInput() in StartupCommandService\n // to avoid re-execution when Tabby splits the pane\n\n const profile = {\n id: baseProfile.id,\n type: 'local',\n name: baseProfile.name || 'Shell',\n group: marker,\n options,\n icon: baseProfile.icon || '',\n color: baseProfile.color || '',\n disableDynamicTitle: false,\n weight: 0,\n isBuiltin: false,\n isTemplate: false,\n terminalColorScheme: null,\n behaviorOnSessionEnd: 'auto',\n }\n\n // tabTitle: follows the program's title (dynamic titles stay on)\n // tabCustomTitle: the pane label; PaneRuntimeService keeps it in sync with the program title\n // paneworksWorkspaceId: for duplicate detection after Tabby recovery\n return {\n type: 'app:local-tab',\n profile,\n savedState: false,\n tabTitle: pane.name || baseProfile.name || 'Shell',\n tabCustomTitle: initialLabel,\n paneworksWorkspaceId: workspaceId,\n disableDynamicTitle: false,\n cwd: isWsl ? '' : rawCwd,\n }\n }\n\n private sanitizeForProfileId(name: string): string {\n return name\n .toLowerCase()\n .replace(/[^a-z0-9-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n || 'workspace'\n }\n\n /** Checks if a profile is a local shell (local, local:wsl, local:powershell, etc.). */\n private isLocalProfile(profile: TabbyProfile): boolean {\n return profile.type === 'local' || profile.type?.startsWith('local:') || false\n }\n\n /** Detects WSL profiles by ID prefix (built-in) or command path (user-defined). */\n private isWslProfile(profile: TabbyProfile): boolean {\n // Built-in WSL profiles: id starts with 'local:wsl'\n if (profile.id?.startsWith('local:wsl')) {\n return true\n }\n // User-defined WSL profiles: type 'local' with command pointing to wsl.exe\n const command = (profile.options?.command || '').toLowerCase()\n return command === 'wsl.exe' || command === 'wsl' || command.endsWith('\\\\wsl.exe') || command.endsWith('/wsl.exe')\n }\n\n private getProfileById(profileId: string): TabbyProfile | undefined {\n // First: check user profiles in config\n const userProfiles: TabbyProfile[] = this.config.store?.profiles ?? []\n const found = userProfiles.find((p) => p.id === profileId)\n if (found) return found\n\n // Fallback: check cached profiles (includes built-ins)\n return this.cachedProfiles?.find((p) => p.id === profileId)\n }\n\n /** Startup commands of all panes (a workspace opens with all of them). */\n collectStartupCommands(workspace: Workspace): PendingCommand[] {\n return workspace.panes\n .filter((p) => p.startupCommand)\n .map((p) => ({ paneId: p.id, command: p.startupCommand }))\n }\n\n /** Returns the workspace with the given id, if it still exists. */\n getWorkspace(workspaceId: string): Workspace | undefined {\n return this.getWorkspaces().find((w) => w.id === workspaceId)\n }\n\n private async saveConfig(): Promise<void> {\n try {\n await this.config.save()\n } catch (error) {\n console.error(`[${DISPLAY_NAME}] Save error:`, error)\n throw error\n }\n }\n}\n","import { Injectable } from '@angular/core'\nimport { AppService, BaseTabComponent, SplitTabComponent } from 'tabby-core'\nimport { BaseTerminalTabComponent } from 'tabby-terminal'\nimport { first, timeout, of, Subject } from 'rxjs'\nimport { catchError } from 'rxjs/operators'\nimport { DISPLAY_NAME } from '../build-config'\nimport { findPane, formatPaneLabel, parsePaneMarker } from '../models/workspace.model'\nimport { WorkspaceEditorService } from './workspaceEditor.service'\n\nexport interface PendingCommand {\n paneId: string\n command?: string\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype TerminalTab = BaseTerminalTabComponent<any>\n\n/**\n * A split tab is scanned when it reports initialized, whenever a pane is added,\n * and again after these delays, so panes that come up slowly are never missed.\n * Each pane is handled once (attachedPanes), so extra scans are free.\n */\nconst RESCAN_DELAYS_MS = [0, 300, 1000, 3000, 8000]\n\n/**\n * Runtime behaviour of workspace panes, found by the hidden marker in their profile group:\n * - sends the pane's startup command once, after the shell's first output;\n * - keeps the outer tab titled with the workspace name;\n * - keeps the pane label (Tabby shows a pane's custom title inside the split)\n * in sync with the title the program sets, prefixed by the pane name.\n * A manual \"Rename pane\" stops the sync for that pane.\n *\n * Module-level singleton for the app lifetime; subscriptions intentionally run forever.\n */\n@Injectable()\nexport class PaneRuntimeService {\n /** Emitted whenever a split tab containing Paneworks panes is scanned (may repeat). */\n readonly workspaceSplitFound$ = new Subject<{ split: SplitTabComponent, workspaceId: string }>()\n\n private pendingCommands = new Map<string, PendingCommand>()\n private watchedSplits = new WeakSet<SplitTabComponent>()\n private attachedPanes = new WeakSet<BaseTabComponent>()\n\n constructor(\n private app: AppService,\n private workspaces: WorkspaceEditorService\n ) {\n this.app.tabOpened$.subscribe((tab) => this.onTabOpened(tab))\n }\n\n registerCommands(commands: PendingCommand[]): void {\n for (const cmd of commands) {\n this.pendingCommands.set(cmd.paneId, cmd)\n }\n }\n\n private onTabOpened(tab: BaseTabComponent): void {\n if (tab instanceof SplitTabComponent) {\n this.watchSplit(tab)\n } else if (tab instanceof BaseTerminalTabComponent) {\n this.processPane(tab, null)\n }\n }\n\n private watchSplit(split: SplitTabComponent): void {\n if (this.watchedSplits.has(split)) return\n this.watchedSplits.add(split)\n\n const scan = () => this.scanSplit(split)\n // initialized$ completes once the layout exists (also immediately if it already did)\n split.initialized$?.subscribe({ complete: scan })\n split.tabAdded$?.subscribe(() => scan())\n for (const delay of RESCAN_DELAYS_MS) {\n setTimeout(scan, delay)\n }\n }\n\n private scanSplit(split: SplitTabComponent): void {\n for (const tab of split.getAllTabs()) {\n if (tab instanceof BaseTerminalTabComponent) {\n this.processPane(tab, split)\n }\n }\n }\n\n private processPane(tab: TerminalTab, split: SplitTabComponent | null): void {\n const marker = parsePaneMarker(tab.profile?.group)\n if (!marker) return\n\n if (split) {\n this.pinSplitTitle(split, marker.workspaceId)\n this.workspaceSplitFound$.next({ split, workspaceId: marker.workspaceId })\n }\n\n if (this.attachedPanes.has(tab)) return\n this.attachedPanes.add(tab)\n\n this.attachLabelSync(tab, marker.workspaceId, marker.paneId)\n this.runPendingCommand(tab, marker.paneId)\n }\n\n /** The outer tab shows the workspace name and ignores pane titles. */\n private pinSplitTitle(split: SplitTabComponent, workspaceId: string): void {\n const name = this.workspaces.getWorkspace(workspaceId)?.name\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(split as any).disableDynamicTitle = true\n if (name && split.title !== name) {\n split.setTitle(name)\n }\n }\n\n private attachLabelSync(tab: TerminalTab, workspaceId: string, paneId: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tabAny = tab as any\n tabAny.disableDynamicTitle = false\n\n let lastLabel: string = tab.customTitle\n let active = true\n\n const update = () => {\n if (!active) return\n if (tab.customTitle !== lastLabel) {\n // The user renamed the pane: their name wins from now on\n active = false\n return\n }\n const workspace = this.workspaces.getWorkspace(workspaceId)\n const paneName = workspace ? findPane(workspace, paneId)?.name : undefined\n const label = formatPaneLabel(paneName, tab.title)\n if (!label || label === tab.customTitle) return\n lastLabel = label\n if (typeof tabAny.setCustomTitle === 'function') {\n tabAny.setCustomTitle(label)\n } else {\n tab.customTitle = label\n }\n }\n\n // The terminal calls this.setTitle(title) for every title the program sends.\n // titleChange$ can't be used: it emits the display title, which is the\n // (unchanged) custom title, and is filtered by distinctUntilChanged.\n const originalSetTitle = tab.setTitle.bind(tab)\n tab.setTitle = (title: string) => {\n originalSetTitle(title)\n update()\n }\n update()\n }\n\n private runPendingCommand(tab: TerminalTab, paneId: string, waitedForSession = false): void {\n const pending = this.pendingCommands.get(paneId)\n if (!pending?.command) return\n this.pendingCommands.delete(paneId)\n const command = pending.command\n\n const send = () => {\n console.log(`[${DISPLAY_NAME}] Sending startup command:`, command)\n tab.sendInput(command + '\\r')\n this.clearProfileArgs(tab)\n }\n\n // No session yet: wait for it (with a fallback), then continue as below\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sessionChanged$ = (tab as any).sessionChanged$\n if (!tab.session && sessionChanged$ && !waitedForSession) {\n this.pendingCommands.set(paneId, pending)\n sessionChanged$.pipe(\n first((s: unknown) => !!s),\n timeout(5000),\n catchError(() => of(null))\n ).subscribe(() => this.runPendingCommand(tab, paneId, true))\n return\n }\n\n // Wait for the shell's first output (its prompt), then send\n if (tab.session?.output$) {\n tab.session.output$.pipe(\n first(),\n timeout(2000),\n catchError(() => of(null))\n ).subscribe(() => setTimeout(send, 100))\n } else {\n setTimeout(send, 500)\n }\n }\n\n /** Prevents native splits of this pane from re-running the startup command. */\n private clearProfileArgs(tab: TerminalTab): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const profile = (tab as any).profile\n if (profile?.options?.args) {\n profile.options.args = []\n }\n }\n}\n","import { Injectable } from '@angular/core'\nimport {\n AppService,\n BaseTabComponent,\n ProfilesService,\n SplitContainer,\n SplitTabComponent,\n TabRecoveryService,\n TabsService,\n} from 'tabby-core'\nimport { DISPLAY_NAME } from '../build-config'\nimport {\n DEFAULT_MIN_PANE_HEIGHT,\n DEFAULT_MIN_PANE_WIDTH,\n LayoutSplit,\n TabbyProfile,\n Workspace,\n WorkspacePane,\n createDefaultPane,\n createDefaultWorkspace,\n isLayoutSplit,\n layoutPaneIds,\n parsePaneMarker,\n readableTextColor,\n} from '../models/workspace.model'\nimport { PaneRuntimeService } from './paneRuntime.service'\nimport { SIDEBAR_WIDTH, WorkspaceEditorService } from './workspaceEditor.service'\n\n/** Quick choices for pane label colours. */\nconst PANE_COLORS = ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#f97316']\n\nconst SIDEBAR_COLLAPSED_WIDTH = 22\nconst REFRESH_MS = 1000\nconst RESIZE_DEBOUNCE_MS = 250\n\n/** What a workspace tab shows: all switched-on panes in a grid, or one pane. */\ntype View = { kind: 'all' } | { kind: 'focus', paneId: string }\n\ninterface WorkspaceTabState {\n split: SplitTabComponent\n workspaceId: string\n view: View\n /** Signature of the grid last applied for \"View all\"; skips needless rebuilds. */\n appliedPlan: string | null\n /** Panes taken out of the split; alive, not shown. */\n parked: Map<string, BaseTabComponent>\n sidebar: HTMLElement | null\n collapsed: boolean\n busy: boolean\n dragging: boolean\n /** Open editors pause the periodic redraw (it would reset what is being typed). */\n editingPaneId: string | null\n menuOpen: boolean\n timer: ReturnType<typeof setInterval> | null\n /** \"NEW\": panes with output since they left the screen (after the grace period). */\n unseen: Set<string>\n /** When each pane last left the screen. */\n leftAt: Map<string, number>\n /** Starting all panes after the tab opened; the grid waits until that is done. */\n starting: boolean\n}\n\n/** How long opening waits for every pane's shell before switching to \"View all\". */\nconst START_TIMEOUT_MS = 8000\n\n/**\n * Output in the first moments after a pane leaves the screen is ignored for \"NEW\":\n * a layout change resizes terminals, and shells / tmux redraw on resize.\n */\nconst NEW_OUTPUT_GRACE_MS = 2500\n\n// Tabby internals used here (stable across 1.0.x, not in the public typings):\n// split.viewRefs, split.attachTabView(), split.onAfterTabAdded(), split.replaceTab(),\n// split.maximizedTab, split.visibility$, tab.hostView (the top-level tab's DOM).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Any = any\n\n/**\n * Everything inside a Paneworks workspace tab: the sidebar (workspace menu, panes,\n * switches, sorting, editing), the \"View all\" grid and the focus view; plus opening,\n * focusing and creating workspaces.\n * Showing and hiding moves live panes in and out of the split (the way Tabby's own\n * drag and drop does), so hidden panes keep running; panes never shown before are\n * created on demand with their startup command. Closing the tab closes all panes.\n */\n@Injectable()\nexport class LayoutService {\n private states = new WeakMap<SplitTabComponent, WorkspaceTabState>()\n private active = new Set<WorkspaceTabState>()\n private resizeTimer: ReturnType<typeof setTimeout> | null = null\n private profiles: TabbyProfile[] = []\n private watchedSessions = new WeakSet<object>()\n\n constructor(\n private app: AppService,\n private profilesService: ProfilesService,\n private runtime: PaneRuntimeService,\n private workspaces: WorkspaceEditorService,\n private tabsService: TabsService,\n private tabRecovery: TabRecoveryService\n ) {\n this.runtime.workspaceSplitFound$.subscribe(({ split, workspaceId }) => this.attach(split, workspaceId))\n window.addEventListener('resize', () => {\n if (this.resizeTimer) clearTimeout(this.resizeTimer)\n this.resizeTimer = setTimeout(() => this.refreshAllGrids(), RESIZE_DEBOUNCE_MS)\n })\n }\n\n // ---------- workspaces ----------\n\n /** The open tab of a workspace, if any. */\n findOpenTab(workspaceId: string): SplitTabComponent | null {\n for (const state of this.active) {\n if (state.workspaceId === workspaceId) return state.split\n }\n for (const tab of this.app.tabs) {\n if (tab instanceof SplitTabComponent &&\n tab.getAllTabs().some((t) => parsePaneMarker((t as Any).profile?.group)?.workspaceId === workspaceId)) {\n return tab\n }\n }\n return null\n }\n\n /** Opens a workspace, or brings its tab to the front when it is already open. */\n async openWorkspace(workspaceId: string): Promise<void> {\n const open = this.findOpenTab(workspaceId)\n if (open) {\n this.app.selectTab(open)\n return\n }\n const workspace = this.workspaces.getWorkspace(workspaceId)\n if (!workspace) return\n const commands = this.workspaces.collectStartupCommands(workspace)\n if (commands.length) this.runtime.registerCommands(commands)\n // Opens with all panes on screen; the sidebar then switches to \"View all\"\n const profile = await this.workspaces.generateTabbyProfile(workspace)\n if (profile) this.profilesService.openNewTabForProfile(profile as Any)\n }\n\n /** New workspace with one pane (profile of the first local shell); opened right away. */\n async createWorkspace(): Promise<void> {\n await this.loadProfiles()\n const existing = new Set(this.workspaces.getWorkspaces().map((w) => w.name))\n let n = 1\n while (existing.has(`Workspace ${n}`)) n++\n const workspace = createDefaultWorkspace(`Workspace ${n}`)\n const local = this.profiles.find((p) => p.type === 'local' || p.type?.startsWith('local:')) ?? this.profiles[0]\n workspace.panes = [{ ...createDefaultPane(), profileId: local?.id ?? '' }]\n await this.workspaces.addWorkspace(workspace)\n await this.openWorkspace(workspace.id)\n }\n\n private async loadProfiles(): Promise<void> {\n if (!this.profiles.length) {\n this.profiles = await this.workspaces.getAvailableProfiles()\n }\n }\n\n // ---------- attaching to a workspace tab ----------\n\n private attach(split: SplitTabComponent, workspaceId: string): void {\n const existing = this.states.get(split)\n if (existing) {\n if (!existing.sidebar?.isConnected) this.mountSidebar(existing)\n return\n }\n const state: WorkspaceTabState = {\n split,\n workspaceId,\n view: { kind: 'all' },\n appliedPlan: null,\n parked: new Map(),\n sidebar: null,\n collapsed: this.loadCollapsed(workspaceId),\n busy: false,\n dragging: false,\n editingPaneId: null,\n menuOpen: false,\n timer: null,\n unseen: new Set(),\n starting: true,\n leftAt: new Map(),\n }\n this.states.set(split, state)\n this.active.add(state)\n this.loadProfiles()\n\n split.destroyed$.subscribe(() => {\n // Parked panes are outside the split: close them with it\n for (const tab of state.parked.values()) tab.destroy()\n state.parked.clear()\n if (state.timer) clearInterval(state.timer)\n state.sidebar?.remove()\n this.active.delete(state)\n })\n // A tab in the background has no size; fit its grid when it comes to the front\n ;(split as Any).visibility$?.subscribe((visible: boolean) => {\n if (visible) setTimeout(() => this.refreshGrid(state), 50)\n })\n\n this.mountSidebar(state)\n state.timer = setInterval(() => this.render(state), REFRESH_MS)\n this.startAllPanes(state)\n }\n\n // ---------- views ----------\n\n private async showAll(state: WorkspaceTabState, force = false): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const area = this.paneArea(state)\n if (!workspace || !area) return\n const plan = this.workspaces.planViewAll(workspace, area.width, area.height)\n const signature = JSON.stringify(plan.tree)\n if (signature !== state.appliedPlan) {\n console.log(`[${DISPLAY_NAME}] View all:`, { area, shown: plan.shown.length, min: this.workspaces.minPaneSize(workspace) })\n }\n const wasAll = state.view.kind === 'all'\n state.view = { kind: 'all' }\n if (plan.tree && (force || !wasAll || signature !== state.appliedPlan)) {\n if (await this.apply(state, workspace, plan.tree)) {\n state.appliedPlan = signature\n }\n }\n this.render(state, true)\n }\n\n private async showFocus(state: WorkspaceTabState, paneId: string): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n const tree: LayoutSplit = { orientation: 'horizontal', ratios: [1], children: [{ paneId }] }\n if (await this.apply(state, workspace, tree)) {\n state.view = { kind: 'focus', paneId }\n state.appliedPlan = null\n }\n this.render(state, true)\n }\n\n /** Shows the current view again (after panes changed). */\n private async reapplyView(state: WorkspaceTabState): Promise<void> {\n if (state.view.kind === 'focus') await this.showFocus(state, state.view.paneId)\n else await this.showAll(state, true)\n }\n\n /** Re-fits \"View all\" to the current size; no-op when the grid stays the same. */\n private refreshGrid(state: WorkspaceTabState): void {\n if (state.view.kind === 'all' && !state.busy && !state.starting) this.showAll(state)\n }\n\n /**\n * Every pane of a workspace runs, switched off or not: hiding is only visual.\n * Tabby starts a terminal's shell only once the terminal has been on screen, so the\n * workspace first shows all its panes (a fresh open already does; after a Tabby\n * restart only the panes that were on screen come back), waits until every shell\n * runs, then switches to \"View all\", which hides the switched-off ones again.\n */\n private async startAllPanes(state: WorkspaceTabState): Promise<void> {\n const before = state.view\n state.starting = true\n try {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n const area = await this.waitFor(() => this.paneArea(state), 3000)\n const missing = workspace.panes.some((p) => !this.livePanes(state).has(p.id))\n const tree = this.workspaces.allPanesLayout(workspace, area?.width, area?.height)\n if (missing && tree) {\n await this.apply(state, workspace, tree)\n }\n await this.waitFor(() => {\n const tabs = [...this.livePanes(state).values()]\n return tabs.length && tabs.every((t) => (t as Any).session) ? true : null\n }, START_TIMEOUT_MS)\n } finally {\n state.starting = false\n }\n // Back to the view from before (a fresh tab starts in \"View all\")\n if (before.kind === 'focus') await this.showFocus(state, before.paneId)\n else await this.showAll(state, true)\n }\n\n /** Polls until `check` returns a value (not null/false) or the timeout passes. */\n private async waitFor<T>(check: () => T | null | false, timeoutMs: number): Promise<T | null> {\n const end = Date.now() + timeoutMs\n for (;;) {\n const value = check()\n if (value) return value\n if (Date.now() > end) return null\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n }\n\n private refreshAllGrids(): void {\n for (const state of this.active) this.refreshGrid(state)\n }\n\n /** Size of the area the panes get (the split element). Null while the tab is in the background. */\n private paneArea(state: WorkspaceTabState): { width: number, height: number } | null {\n const rect = this.splitElement(state)?.getBoundingClientRect()\n return rect && rect.width > 0 && rect.height > 0 ? { width: rect.width, height: rect.height } : null\n }\n\n /** Rebuilds the split to show exactly the panes of `tree`. Returns false if nothing could be shown. */\n private async apply(state: WorkspaceTabState, workspace: Workspace, tree: LayoutSplit): Promise<boolean> {\n if (state.busy) return false\n state.busy = true\n try {\n const split = state.split as Any\n const panes = new Map(workspace.panes.map((p) => [p.id, p]))\n const live = this.livePanes(state)\n\n // Panes of the new view: live ones, or created now\n const wanted = layoutPaneIds(tree).filter((id) => panes.has(id))\n for (const id of wanted) {\n if (!live.has(id)) {\n const tab = await this.createPane(workspace, panes.get(id)!)\n if (tab) live.set(id, tab)\n }\n }\n const shown = wanted.filter((id) => live.has(id))\n if (!shown.length) return false\n\n // Park the panes that leave the split (detach their view, keep them alive)\n for (const tab of state.split.getAllTabs()) {\n const id = this.paneIdOf(tab)\n if (!id || !shown.includes(id)) {\n tab.removeFromContainer()\n split.viewRefs?.delete(tab)\n tab.parent = null\n if (id) {\n state.parked.set(id, tab)\n state.leftAt.set(id, Date.now())\n } else {\n tab.destroy() // not a workspace pane (e.g. a manual split): close it\n }\n }\n }\n\n const root = this.buildContainer(tree, live)\n if (!root) return false\n split.maximizedTab = null\n split.root = root\n\n // Attach the panes that enter the split; on screen = seen\n for (const id of shown) {\n const tab = live.get(id)!\n state.unseen.delete(id)\n tab.clearActivity()\n if (!split.viewRefs?.has(tab)) {\n state.parked.delete(id)\n tab.parent = state.split\n ;(tab as Any).emitVisibility?.(split.visibility?.value ?? true)\n split.attachTabView(tab)\n split.onAfterTabAdded(tab)\n }\n }\n\n split.layout()\n state.split.focus(live.get(shown[0])!)\n split.recoveryStateChangedHint?.next()\n this.nudgeResize()\n // Labels of newly attached panes appear after Angular's next pass\n setTimeout(() => this.applyLabelColors(state, this.workspaces.getWorkspace(state.workspaceId)), 100)\n return true\n } catch (error) {\n console.error(`[${DISPLAY_NAME}] Layout change failed:`, error)\n return false\n } finally {\n state.busy = false\n }\n }\n\n private buildContainer(node: LayoutSplit, live: Map<string, BaseTabComponent>): SplitContainer | null {\n const children: (SplitContainer | BaseTabComponent)[] = []\n const ratios: number[] = []\n node.children.forEach((child, i) => {\n const built = isLayoutSplit(child) ? this.buildContainer(child, live) : live.get(child.paneId) ?? null\n if (built) {\n children.push(built)\n ratios.push(node.ratios[i] ?? 1)\n }\n })\n if (!children.length) return null\n const sum = ratios.reduce((a, b) => a + b, 0) || 1\n const container = new SplitContainer()\n container.orientation = node.orientation === 'horizontal' ? 'h' : 'v'\n container.children = children\n container.ratios = ratios.map((r) => r / sum)\n return container\n }\n\n private async createPane(workspace: Workspace, pane: WorkspacePane): Promise<BaseTabComponent | null> {\n try {\n const token = await this.workspaces.createPaneToken(workspace, pane)\n const params = await this.tabRecovery.recoverTab(token as Any)\n if (!params) return null\n if (pane.startupCommand) {\n this.runtime.registerCommands([{ paneId: pane.id, command: pane.startupCommand }])\n }\n return this.tabsService.create(params)\n } catch (error) {\n console.error(`[${DISPLAY_NAME}] Could not create pane:`, pane, error)\n return null\n }\n }\n\n private livePanes(state: WorkspaceTabState): Map<string, BaseTabComponent> {\n const live = new Map<string, BaseTabComponent>()\n for (const tab of state.split.getAllTabs()) {\n const id = this.paneIdOf(tab)\n if (id) live.set(id, tab)\n }\n for (const [id, tab] of state.parked) live.set(id, tab)\n return live\n }\n\n private paneIdOf(tab: BaseTabComponent): string | null {\n return parsePaneMarker((tab as Any).profile?.group)?.paneId ?? null\n }\n\n /** Terminals refit on window resize; the split area changed. */\n private nudgeResize(): void {\n setTimeout(() => window.dispatchEvent(new Event('resize')), 50)\n }\n\n // ---------- pane changes from the sidebar ----------\n\n private async toggleShown(state: WorkspaceTabState, paneId: string): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const pane = workspace?.panes.find((p) => p.id === paneId)\n if (!workspace || !pane) return\n if (pane.hidden) delete pane.hidden\n else pane.hidden = true\n await this.workspaces.saveWorkspaceQuietly(workspace)\n if (state.view.kind === 'all') await this.showAll(state)\n else this.render(state, true)\n }\n\n private async movePane(state: WorkspaceTabState, paneId: string, beforePaneId: string | null): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n const from = workspace.panes.findIndex((p) => p.id === paneId)\n if (from === -1 || paneId === beforePaneId) return\n const [pane] = workspace.panes.splice(from, 1)\n const to = beforePaneId ? workspace.panes.findIndex((p) => p.id === beforePaneId) : -1\n workspace.panes.splice(to === -1 ? workspace.panes.length : to, 0, pane)\n await this.workspaces.saveWorkspaceQuietly(workspace)\n if (state.view.kind === 'all') await this.showAll(state)\n else this.render(state, true)\n }\n\n private async addPane(state: WorkspaceTabState): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n await this.loadProfiles()\n const last = workspace.panes[workspace.panes.length - 1]\n const pane: WorkspacePane = {\n ...createDefaultPane(),\n profileId: last?.profileId || this.profiles[0]?.id || '',\n cwd: last?.cwd || '',\n }\n workspace.panes.push(pane)\n await this.workspaces.saveWorkspaceQuietly(workspace)\n state.editingPaneId = pane.id\n state.menuOpen = false\n this.render(state, true)\n }\n\n private async savePane(state: WorkspaceTabState, paneId: string, fields: Partial<WorkspacePane>): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const pane = workspace?.panes.find((p) => p.id === paneId)\n if (!workspace || !pane) return\n Object.assign(pane, fields)\n // Optional fields are stored only when set (the config file never gets empty keys)\n for (const key of ['name', 'color'] as const) {\n if (!pane[key]) delete pane[key]\n }\n await this.workspaces.saveWorkspaceQuietly(workspace)\n state.editingPaneId = null\n this.render(state, true)\n // Every pane runs: a new pane starts as soon as it is saved\n if (!this.livePanes(state).has(paneId)) await this.startAllPanes(state)\n }\n\n /**\n * Closes the pane's terminal and starts it again with its current settings\n * (command, folder, profile). On screen it is swapped in place, so the tab stays open.\n */\n private async restartPane(state: WorkspaceTabState, paneId: string): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const pane = workspace?.panes.find((p) => p.id === paneId)\n if (!workspace || !pane) return\n const old = this.livePanes(state).get(paneId)\n const fresh = await this.createPane(workspace, pane)\n if (!fresh) return\n if (old && state.parked.get(paneId) === old) {\n state.parked.set(paneId, fresh)\n old.destroy()\n } else if (old && old.parent === state.split) {\n fresh.parent = state.split\n ;(state.split as Any).replaceTab(old, fresh)\n ;(state.split as Any).viewRefs?.delete(old)\n old.destroy()\n ;(state.split as Any).layout()\n state.split.focus(fresh)\n this.nudgeResize()\n } else {\n state.parked.set(paneId, fresh)\n }\n this.render(state, true)\n }\n\n private async removePane(state: WorkspaceTabState, paneId: string): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const pane = workspace?.panes.find((p) => p.id === paneId)\n if (!workspace || !pane) return\n if (workspace.panes.length <= 1) {\n window.alert('A workspace needs at least one pane. Delete the workspace from its menu instead.')\n return\n }\n const label = pane.name || pane.startupCommand || 'this pane'\n if (!window.confirm(`Remove \"${label}\" from ${workspace.name}? Its terminal is closed.`)) return\n\n workspace.panes = workspace.panes.filter((p) => p.id !== paneId)\n await this.workspaces.saveWorkspaceQuietly(workspace)\n state.editingPaneId = null\n\n const tab = this.livePanes(state).get(paneId)\n const onScreen = !!tab && tab.parent === state.split\n if (onScreen) {\n // Show the rest first, so the split never runs empty (an empty split closes the tab)\n if (state.view.kind === 'focus' && state.view.paneId === paneId) state.view = { kind: 'all' }\n await this.reapplyView(state)\n }\n const still = this.livePanes(state).get(paneId)\n if (still && still.parent === state.split && state.split.getAllTabs().length <= 1) {\n // Nothing else can be shown: switch another pane on and show it\n const other = workspace.panes[0]\n delete other.hidden\n await this.workspaces.saveWorkspaceQuietly(workspace)\n await this.showFocus(state, other.id)\n }\n state.parked.delete(paneId)\n this.livePanes(state).get(paneId)?.destroy()\n tab?.destroy()\n this.render(state, true)\n }\n\n // ---------- workspace changes from the sidebar ----------\n\n private async saveWorkspaceSettings(\n state: WorkspaceTabState,\n fields: { name: string, minPaneWidth: number | null, minPaneHeight: number | null, launchOnStartup: boolean }\n ): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n workspace.name = fields.name.trim() || workspace.name\n for (const key of ['minPaneWidth', 'minPaneHeight'] as const) {\n const value = fields[key]\n if (value && value > 0) workspace[key] = Math.round(value)\n else delete workspace[key]\n }\n if (fields.launchOnStartup) workspace.launchOnStartup = true\n else workspace.launchOnStartup = false\n await this.workspaces.saveWorkspaceQuietly(workspace)\n state.split.setTitle(workspace.name)\n state.menuOpen = false\n if (state.view.kind === 'all') await this.showAll(state)\n else this.render(state, true)\n }\n\n private async deleteWorkspace(state: WorkspaceTabState): Promise<void> {\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n if (!workspace) return\n if (!window.confirm(`Delete the workspace \"${workspace.name}\"? Its tab and all its panes are closed.`)) return\n await this.workspaces.deleteWorkspace(workspace.id)\n const app = this.app as Any\n if (typeof app.closeTab === 'function') app.closeTab(state.split, false)\n else state.split.destroy()\n }\n\n // ---------- sidebar ----------\n\n /**\n * DOM element of the workspace tab. Tabby's tab-body inserts a top-level tab's\n * `hostView` directly (viewContainerEmbeddedRef is only set for panes inside a split).\n */\n private splitElement(state: WorkspaceTabState): HTMLElement | null {\n const split = state.split as Any\n for (const ref of [split.hostView, split.viewContainerEmbeddedRef]) {\n const el = ref?.rootNodes?.[0]\n if (el instanceof HTMLElement) return el\n }\n return null\n }\n\n private mountSidebar(state: WorkspaceTabState): void {\n const splitEl = this.splitElement(state)\n const host = splitEl?.parentElement\n if (!splitEl || !host) {\n // Not in the DOM yet: retry shortly (also retried by every scan of the split)\n setTimeout(() => {\n if (!state.sidebar?.isConnected && this.active.has(state)) this.mountSidebar(state)\n }, 500)\n return\n }\n if (!state.sidebar) {\n state.sidebar = document.createElement('div')\n state.sidebar.className = 'paneworks-sidebar'\n this.ensureStyles()\n }\n host.insertBefore(state.sidebar, splitEl)\n // Scope for the pane frames (see ensureStyles)\n splitEl.setAttribute('data-paneworks', '')\n this.render(state, true)\n this.nudgeResize()\n // The pane area is known now: fit the grid to it\n setTimeout(() => this.refreshGrid(state), 100)\n }\n\n /**\n * Pane label colours. Tabby renders one <split-tab-pane-label> per pane, in the\n * order of split.getAllTabs(), and recreates them when panes change; so this runs\n * on every sidebar tick and after every layout change.\n */\n private applyLabelColors(state: WorkspaceTabState, workspace: Workspace | undefined): void {\n const splitEl = this.splitElement(state)\n if (!splitEl || !workspace) return\n const colors = new Map(workspace.panes.map((p) => [p.id, p.color]))\n const labels = Array.from(splitEl.querySelectorAll(':scope > split-tab-pane-label'))\n const tabs = state.split.getAllTabs()\n labels.forEach((label, i) => {\n const name = label.querySelector('.custom-name') as HTMLElement | null\n if (!name) return\n const id = tabs[i] ? this.paneIdOf(tabs[i]) : null\n const color = id ? colors.get(id) : undefined\n if (color) {\n name.style.background = color\n name.style.color = readableTextColor(color)\n } else {\n name.style.removeProperty('background')\n name.style.removeProperty('color')\n }\n })\n }\n\n /**\n * Subscribes once to each pane's terminal output for \"NEW\": output while the pane\n * is off screen, after the grace period, marks it until the pane is shown again.\n */\n private watchOutput(state: WorkspaceTabState): void {\n for (const [id, tab] of this.livePanes(state)) {\n const session = (tab as Any).session\n if (!session?.output$ || this.watchedSessions.has(session)) continue\n this.watchedSessions.add(session)\n session.output$.subscribe(() => {\n if (tab.parent === state.split || state.unseen.has(id)) return // on screen, or already marked\n if (Date.now() - (state.leftAt.get(id) ?? 0) < NEW_OUTPUT_GRACE_MS) return\n state.unseen.add(id)\n })\n }\n }\n\n private render(state: WorkspaceTabState, force = false): void {\n const el = state.sidebar\n if (!el || !el.isConnected || state.dragging) return\n this.watchOutput(state)\n this.applyLabelColors(state, this.workspaces.getWorkspace(state.workspaceId))\n if (!force && (state.editingPaneId || state.menuOpen)) return\n const workspace = this.workspaces.getWorkspace(state.workspaceId)\n const live = this.livePanes(state)\n const onScreen = new Set(state.split.getAllTabs().map((t) => this.paneIdOf(t)))\n\n // Redraw only on change: a redraw between mousedown and mouseup would swallow the click\n const signature = JSON.stringify([\n state.collapsed, state.view, state.editingPaneId, state.menuOpen, workspace,\n workspace?.panes.map((p) => {\n const tab = live.get(p.id)\n return [tab?.customTitle, tab?.title, state.unseen.has(p.id), onScreen.has(p.id)]\n }),\n ])\n if (!force && (el as Any).__pwSignature === signature) return\n ;(el as Any).__pwSignature = signature\n\n el.classList.toggle('collapsed', state.collapsed)\n el.style.flex = `0 0 ${state.collapsed ? SIDEBAR_COLLAPSED_WIDTH : SIDEBAR_WIDTH}px`\n el.textContent = ''\n\n const toggle = this.button('pw-icon-btn pw-toggle', state.collapsed ? '»' : '«',\n state.collapsed ? 'Show sidebar' : 'Hide sidebar', () => {\n state.collapsed = !state.collapsed\n this.saveCollapsed(state.workspaceId, state.collapsed)\n this.render(state, true)\n this.nudgeResize()\n })\n if (state.collapsed || !workspace) {\n el.append(toggle)\n return\n }\n\n // Header: workspace name opens the workspace menu\n const header = this.node('div', 'pw-header')\n const wsButton = this.button('pw-ws', '', 'Workspace menu', () => {\n state.menuOpen = !state.menuOpen\n state.editingPaneId = null\n this.render(state, true)\n })\n wsButton.append(this.node('span', 'pw-ws-name', workspace.name), this.node('span', 'pw-caret', state.menuOpen ? '▴' : '▾'))\n header.append(wsButton, toggle)\n el.append(header)\n if (state.menuOpen) el.append(this.workspaceMenu(state, workspace))\n\n // View all\n const enabled = workspace.panes.filter((p) => !p.hidden)\n const shownCount = enabled.filter((p) => onScreen.has(p.id)).length\n const allRow = this.node('div', 'pw-row pw-all' + (state.view.kind === 'all' ? ' active' : ''))\n allRow.append(\n this.node('span', 'pw-main', 'View all'),\n this.node('span', 'pw-count', state.view.kind === 'all' ? `${shownCount} / ${enabled.length}` : `${enabled.length} on`)\n )\n allRow.title = 'Show all switched-on panes in a grid'\n allRow.onclick = () => this.showAll(state, true)\n el.append(allRow)\n\n // Panes\n const section = this.node('div', 'pw-section')\n section.append(\n this.node('span', '', 'Panes'),\n this.button('pw-icon-btn pw-add', '+', 'Add a pane', () => this.addPane(state))\n )\n el.append(section)\n\n const focused = state.view.kind === 'focus' ? state.view.paneId : null\n const list = this.node('div', 'pw-list')\n for (const pane of workspace.panes) {\n list.append(this.paneRow(state, pane, live.get(pane.id), onScreen.has(pane.id), focused))\n if (state.editingPaneId === pane.id) list.append(this.paneEditor(state, pane))\n }\n const endZone = this.node('div', 'pw-drop-end')\n this.makeDropTarget(state, endZone, null)\n list.append(endZone)\n el.append(list)\n }\n\n private paneRow(\n state: WorkspaceTabState,\n pane: WorkspacePane,\n tab: BaseTabComponent | undefined,\n onScreen: boolean,\n focused: string | null\n ): HTMLElement {\n const title = (tab ? (tab.customTitle || tab.title) : '') || pane.name || pane.startupCommand || 'New pane'\n const sub = [pane.name, pane.startupCommand].filter(Boolean).join(' · ')\n const noRoom = !pane.hidden && !onScreen && state.view.kind === 'all'\n const hasNews = !onScreen && state.unseen.has(pane.id)\n\n const classes = ['pw-row', 'pw-pane']\n if (onScreen) classes.push('onscreen')\n if (pane.id === focused) classes.push('focused')\n if (pane.hidden) classes.push('off')\n if (state.editingPaneId === pane.id) classes.push('editing')\n const row = this.node('div', classes.join(' '))\n row.title = [\n onScreen ? 'On screen' : tab ? 'Running, not on screen' : 'Not running (shown again by View all or its title)',\n pane.hidden ? 'switched off (not in \"View all\")' : noRoom ? 'switched on, but no room at the minimum pane size' : '',\n ].filter(Boolean).join(' · ')\n\n // Sorting: drag the row (the handle shows where to grab)\n row.draggable = true\n row.append(this.node('span', 'pw-handle', '⋮⋮'))\n row.addEventListener('dragstart', (e) => {\n state.dragging = true\n e.dataTransfer?.setData('text/plain', pane.id)\n if (e.dataTransfer) e.dataTransfer.effectAllowed = 'move'\n row.classList.add('dragging')\n })\n row.addEventListener('dragend', () => {\n state.dragging = false\n row.classList.remove('dragging')\n this.render(state, true)\n })\n this.makeDropTarget(state, row, pane.id)\n\n const swatch = this.node('span', 'pw-pane-color' + (pane.color ? '' : ' none'))\n if (pane.color) swatch.style.background = pane.color\n swatch.title = pane.color ? `Label colour ${pane.color}` : 'No label colour'\n row.append(swatch)\n\n const text = this.node('span', 'pw-text')\n const main = this.node('span', 'pw-main')\n main.append(this.node('span', 'pw-name', title))\n if (hasNews) {\n const news = this.node('span', 'pw-news', 'new')\n news.title = 'New output since it left the screen'\n main.append(news)\n }\n text.append(main)\n if (sub || noRoom) text.append(this.node('span', 'pw-sub', [sub, noRoom ? 'no room' : ''].filter(Boolean).join(' · ')))\n text.onclick = () => {\n if (pane.id === focused) this.showAll(state, true)\n else this.showFocus(state, pane.id)\n }\n text.title = pane.id === focused ? 'Back to \"View all\"' : 'Show this pane alone'\n\n const sw = this.node('label', 'pw-switch')\n sw.title = pane.hidden ? 'Off: not in \"View all\"' : 'On: in \"View all\"'\n const input = document.createElement('input')\n input.type = 'checkbox'\n input.checked = !pane.hidden\n input.onchange = () => this.toggleShown(state, pane.id)\n sw.append(input, this.node('span', 'pw-slider'))\n sw.addEventListener('click', (e) => e.stopPropagation())\n\n const more = this.button('pw-icon-btn pw-more', '⋯', 'Edit pane', () => {\n state.editingPaneId = state.editingPaneId === pane.id ? null : pane.id\n state.menuOpen = false\n this.render(state, true)\n })\n\n row.append(text, sw, more)\n return row\n }\n\n private paneEditor(state: WorkspaceTabState, pane: WorkspacePane): HTMLElement {\n const box = this.node('div', 'pw-form')\n const name = this.input('text', pane.name ?? '', 'optional')\n const command = this.input('text', pane.startupCommand ?? '', 'e.g. c 1')\n const cwd = this.input('text', pane.cwd ?? '', 'C:\\\\path or /home/user')\n const profile = document.createElement('select')\n profile.className = 'pw-input'\n const empty = document.createElement('option')\n empty.value = ''\n empty.textContent = '-- profile --'\n profile.append(empty)\n for (const p of this.profiles) {\n const option = document.createElement('option')\n option.value = p.id\n option.textContent = p.name\n profile.append(option)\n }\n profile.value = pane.profileId ?? ''\n\n // Label colour: presets, a custom picker, or none\n let chosen = pane.color ?? ''\n const colors = this.node('div', 'pw-colors')\n const custom = document.createElement('input')\n custom.type = 'color'\n custom.className = 'pw-color-custom'\n custom.title = 'Custom colour'\n const paint = () => {\n colors.querySelectorAll('.pw-swatch').forEach((s) => {\n s.classList.toggle('selected', (s as HTMLElement).dataset.color === chosen)\n })\n custom.classList.toggle('selected', !!chosen && !PANE_COLORS.includes(chosen))\n if (chosen) custom.value = chosen\n }\n for (const color of ['', ...PANE_COLORS]) {\n const swatch = this.button('pw-swatch' + (color ? '' : ' none'), '', color ? color : 'No colour', () => {\n chosen = color\n paint()\n })\n swatch.dataset.color = color\n if (color) swatch.style.background = color\n colors.append(swatch)\n }\n custom.addEventListener('input', () => {\n chosen = custom.value\n paint()\n })\n colors.append(custom)\n paint()\n\n box.append(\n this.field('Name', name),\n this.field('Label colour', colors),\n this.field('Startup command', command),\n this.field('Folder', cwd),\n this.field('Profile', profile),\n this.node('div', 'pw-hint', 'Command, folder and profile apply when the pane (re)starts.'),\n )\n const save = () => this.savePane(state, pane.id, {\n name: name.value.trim(),\n color: chosen,\n startupCommand: command.value.trim(),\n cwd: cwd.value.trim(),\n profileId: profile.value,\n })\n for (const field of [name, command, cwd]) {\n field.addEventListener('keydown', (e) => {\n if (e.key === 'Enter') save()\n if (e.key === 'Escape') { state.editingPaneId = null; this.render(state, true) }\n })\n }\n const actions = this.node('div', 'pw-actions')\n actions.append(\n this.button('pw-btn primary', 'Save', 'Save the pane settings', save),\n this.button('pw-btn', 'Restart', 'Save, then close and start the pane again', async () => {\n await save()\n await this.restartPane(state, pane.id)\n }),\n this.button('pw-btn danger', 'Remove', 'Remove the pane from the workspace', () => this.removePane(state, pane.id)),\n )\n box.append(actions)\n setTimeout(() => name.focus(), 0)\n return box\n }\n\n private workspaceMenu(state: WorkspaceTabState, workspace: Workspace): HTMLElement {\n const box = this.node('div', 'pw-form pw-menu')\n const name = this.input('text', workspace.name, 'Workspace name')\n const minW = this.input('number', workspace.minPaneWidth ? String(workspace.minPaneWidth) : '', String(DEFAULT_MIN_PANE_WIDTH))\n const minH = this.input('number', workspace.minPaneHeight ? String(workspace.minPaneHeight) : '', String(DEFAULT_MIN_PANE_HEIGHT))\n minW.classList.add('pw-size')\n minH.classList.add('pw-size')\n const size = this.node('div', 'pw-size-row')\n size.append(minW, this.node('span', '', '×'), minH, this.node('span', '', 'px'))\n const startup = document.createElement('input')\n startup.type = 'checkbox'\n startup.checked = !!workspace.launchOnStartup\n const startupLabel = this.node('label', 'pw-check')\n startupLabel.append(startup, this.node('span', '', 'Open when Tabby starts'))\n\n box.append(\n this.field('Name', name),\n this.field('Minimum pane size', size),\n this.node('div', 'pw-hint', '\"View all\" fits as many switched-on panes as this size allows.'),\n startupLabel,\n )\n const save = () => this.saveWorkspaceSettings(state, {\n name: name.value,\n minPaneWidth: Number(minW.value) || null,\n minPaneHeight: Number(minH.value) || null,\n launchOnStartup: startup.checked,\n })\n for (const field of [name, minW, minH]) {\n field.addEventListener('keydown', (e) => {\n if (e.key === 'Enter') save()\n if (e.key === 'Escape') { state.menuOpen = false; this.render(state, true) }\n })\n }\n const actions = this.node('div', 'pw-actions')\n actions.append(\n this.button('pw-btn primary', 'Save', 'Save the workspace settings', save),\n this.button('pw-btn', 'Close', 'Close the menu', () => { state.menuOpen = false; this.render(state, true) }),\n )\n box.append(actions)\n\n // Other workspaces\n box.append(this.node('div', 'pw-menu-title', 'Workspaces'))\n for (const other of this.workspaces.getWorkspaces()) {\n const isThis = other.id === workspace.id\n const open = !isThis && !!this.findOpenTab(other.id)\n const item = this.button('pw-menu-item' + (isThis ? ' current' : ''), '',\n isThis ? 'This workspace' : open ? 'Switch to its tab' : 'Open it', () => {\n if (isThis) return\n state.menuOpen = false\n this.render(state, true)\n this.openWorkspace(other.id)\n })\n item.append(this.node('span', 'pw-name', other.name), this.node('span', 'pw-count', isThis ? 'this' : open ? 'open' : ''))\n box.append(item)\n }\n box.append(\n this.button('pw-menu-item', '+ New workspace', 'Create a workspace with one pane', () => {\n state.menuOpen = false\n this.render(state, true)\n this.createWorkspace()\n }),\n this.button('pw-menu-item danger', 'Delete this workspace…', 'Delete it and close its tab', () => this.deleteWorkspace(state)),\n )\n return box\n }\n\n private makeDropTarget(state: WorkspaceTabState, el: HTMLElement, beforePaneId: string | null): void {\n el.addEventListener('dragover', (e) => {\n if (!state.dragging) return\n e.preventDefault()\n if (e.dataTransfer) e.dataTransfer.dropEffect = 'move'\n el.classList.add('drop-before')\n })\n el.addEventListener('dragleave', () => el.classList.remove('drop-before'))\n el.addEventListener('drop', (e) => {\n e.preventDefault()\n el.classList.remove('drop-before')\n const paneId = e.dataTransfer?.getData('text/plain')\n state.dragging = false\n if (paneId) this.movePane(state, paneId, beforePaneId)\n })\n }\n\n // ---------- DOM helpers ----------\n\n private node(tag: string, className: string, text?: string): HTMLElement {\n const el = document.createElement(tag)\n if (className) el.className = className\n if (text !== undefined) el.textContent = text\n return el\n }\n\n private button(className: string, text: string, title: string, onClick: () => void): HTMLButtonElement {\n const el = document.createElement('button')\n el.type = 'button'\n el.className = className\n el.textContent = text\n el.title = title\n el.addEventListener('click', (e) => {\n e.stopPropagation()\n onClick()\n })\n return el\n }\n\n private input(type: string, value: string, placeholder: string): HTMLInputElement {\n const el = document.createElement('input')\n el.type = type\n el.className = 'pw-input'\n el.value = value\n el.placeholder = placeholder\n // Keep Tabby's hotkeys out of the sidebar's text fields\n el.addEventListener('keydown', (e) => e.stopPropagation())\n return el\n }\n\n private field(label: string, control: HTMLElement): HTMLElement {\n const el = this.node('label', 'pw-field')\n el.append(this.node('span', 'pw-label', label), control)\n return el\n }\n\n private ensureStyles(): void {\n if (document.getElementById('paneworks-sidebar-styles')) return\n const style = document.createElement('style')\n style.id = 'paneworks-sidebar-styles'\n style.textContent = `\n /* Pane frames in Paneworks tabs: every pane gets a frame and a small gap,\n the pane with keyboard focus an accent frame. Tabby positions the panes\n (class \"child\") absolutely; border-box keeps them inside their slot. */\n [data-paneworks] > .child {\n box-sizing: border-box;\n border: 3px solid var(--theme-bg-more, rgba(0,0,0,.35));\n border-radius: 6px;\n overflow: hidden;\n transition: border-color .12s;\n }\n [data-paneworks] > .child.focused {\n border-color: var(--theme-primary, #4c9aff);\n }\n [data-paneworks] split-tab-pane-label .custom-name {\n font-weight: 600;\n }\n /* Split handles: Tabby's handle is a 10px band centred on the border between two\n panes. A bright 4px bar in its middle (inset 3px works for both orientations)\n stands out against the panes; brighter on hover, accent while dragging. */\n [data-paneworks] > split-tab-spanner::after {\n content: '';\n position: absolute;\n inset: 3px;\n border-radius: 2px;\n background: rgba(255, 255, 255, .30);\n background: color-mix(in srgb, var(--theme-fg, #fff) 32%, transparent);\n pointer-events: none;\n transition: background .12s;\n }\n [data-paneworks] > split-tab-spanner:hover::after {\n background: rgba(255, 255, 255, .55);\n background: color-mix(in srgb, var(--theme-fg, #fff) 60%, transparent);\n }\n [data-paneworks] > split-tab-spanner.active::after {\n background: var(--theme-primary, #4c9aff);\n }\n\n .paneworks-sidebar {\n --pw-accent: var(--theme-primary, #4c9aff);\n display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;\n background: var(--theme-bg-more, rgba(0,0,0,.25));\n border-right: 1px solid var(--theme-bg-more-2, rgba(255,255,255,.08));\n color: var(--theme-fg, inherit); font-size: 12px; user-select: none;\n }\n .paneworks-sidebar.collapsed { align-items: center; }\n .paneworks-sidebar button { font: inherit; color: inherit; }\n .paneworks-sidebar .pw-icon-btn {\n background: none; border: none; opacity: .6; cursor: pointer; padding: 2px 6px; line-height: 1; font-size: 13px;\n }\n .paneworks-sidebar .pw-icon-btn:hover { opacity: 1; }\n .paneworks-sidebar.collapsed .pw-toggle { margin-top: 8px; }\n\n .paneworks-sidebar .pw-header { display: flex; align-items: center; padding: 6px 4px 4px 4px; }\n .paneworks-sidebar .pw-ws {\n flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: none; border: none;\n padding: 4px 6px; border-radius: 4px; cursor: pointer; font-weight: 600; text-align: left;\n }\n .paneworks-sidebar .pw-ws:hover { background: rgba(127,127,127,.15); }\n .paneworks-sidebar .pw-ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .paneworks-sidebar .pw-caret { opacity: .5; font-size: 10px; }\n\n .paneworks-sidebar .pw-section {\n display: flex; align-items: center; justify-content: space-between;\n padding: 10px 6px 2px 10px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .6;\n }\n .paneworks-sidebar .pw-add { font-size: 15px; opacity: .9; }\n\n .paneworks-sidebar .pw-row {\n display: flex; align-items: center; gap: 6px; padding: 5px 4px 5px 4px;\n border-left: 3px solid transparent; border-top: 2px solid transparent;\n }\n .paneworks-sidebar .pw-row:hover { background: rgba(127,127,127,.10); }\n .paneworks-sidebar .pw-all { cursor: pointer; padding-left: 10px; }\n .paneworks-sidebar .pw-all .pw-main { flex: 1; font-weight: 600; }\n .paneworks-sidebar .pw-all.active { border-left-color: var(--pw-accent); background: rgba(127,127,127,.14); }\n .paneworks-sidebar .pw-count { font-size: 10px; opacity: .55; }\n\n /* Pane states: on screen = accent bar + full brightness; running elsewhere = dimmed;\n switched off = dimmer; focus view = highlighted row. */\n .paneworks-sidebar .pw-pane .pw-text { opacity: .6; }\n .paneworks-sidebar .pw-pane.onscreen { border-left-color: var(--pw-accent); }\n .paneworks-sidebar .pw-pane.onscreen .pw-text { opacity: 1; }\n .paneworks-sidebar .pw-pane.off .pw-text { opacity: .38; }\n .paneworks-sidebar .pw-pane.focused { background: rgba(127,127,127,.20); }\n .paneworks-sidebar .pw-pane.focused .pw-name { font-weight: 600; }\n .paneworks-sidebar .pw-pane.editing { background: rgba(127,127,127,.14); }\n\n .paneworks-sidebar .pw-pane-color { flex: 0 0 8px; height: 8px; border-radius: 2px; }\n .paneworks-sidebar .pw-pane-color.none { border: 1px dashed rgba(127,127,127,.5); box-sizing: border-box; }\n .paneworks-sidebar .pw-colors { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }\n .paneworks-sidebar .pw-swatch {\n width: 16px; height: 16px; padding: 0; border-radius: 3px; cursor: pointer;\n border: 2px solid transparent; box-sizing: border-box;\n }\n .paneworks-sidebar .pw-swatch.none {\n background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(127,127,127,.5) 3px 4px);\n border-color: rgba(127,127,127,.4);\n }\n .paneworks-sidebar .pw-swatch.selected, .paneworks-sidebar .pw-color-custom.selected {\n border-color: var(--theme-fg, #fff);\n }\n .paneworks-sidebar .pw-color-custom {\n width: 22px; height: 18px; padding: 0; border: 2px solid transparent; border-radius: 3px;\n background: none; cursor: pointer;\n }\n .paneworks-sidebar .pw-handle { cursor: grab; opacity: .25; font-size: 10px; letter-spacing: -2px; }\n .paneworks-sidebar .pw-row:hover .pw-handle { opacity: .7; }\n .paneworks-sidebar .pw-row.dragging { opacity: .35; }\n .paneworks-sidebar .drop-before { border-top-color: var(--pw-accent); }\n .paneworks-sidebar .pw-drop-end { flex: 1; min-height: 24px; border-top: 2px solid transparent; }\n\n .paneworks-sidebar .pw-text { display: flex; flex-direction: column; min-width: 0; flex: 1; cursor: pointer; }\n .paneworks-sidebar .pw-main { display: flex; align-items: center; gap: 5px; min-width: 0; }\n .paneworks-sidebar .pw-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .paneworks-sidebar .pw-sub { font-size: 10px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .paneworks-sidebar .pw-news {\n flex: none; font-size: 9px; line-height: 1; padding: 2px 4px; border-radius: 3px;\n background: var(--pw-accent); color: var(--theme-bg, #000); font-weight: 600; text-transform: uppercase;\n }\n .paneworks-sidebar .pw-more { opacity: .35; font-size: 14px; }\n .paneworks-sidebar .pw-row:hover .pw-more, .paneworks-sidebar .pw-pane.editing .pw-more { opacity: .9; }\n\n .paneworks-sidebar .pw-switch { position: relative; flex: 0 0 26px; height: 14px; cursor: pointer; }\n .paneworks-sidebar .pw-switch input { opacity: 0; width: 0; height: 0; position: absolute; }\n .paneworks-sidebar .pw-slider {\n position: absolute; inset: 0; border-radius: 7px; background: rgba(127,127,127,.35); transition: background .15s;\n }\n .paneworks-sidebar .pw-slider::before {\n content: ''; position: absolute; left: 2px; top: 2px; width: 10px; height: 10px; border-radius: 50%;\n background: var(--theme-fg, #fff); transition: transform .15s;\n }\n .paneworks-sidebar .pw-switch input:checked + .pw-slider { background: var(--pw-accent); }\n .paneworks-sidebar .pw-switch input:checked + .pw-slider::before { transform: translateX(12px); }\n\n .paneworks-sidebar .pw-form {\n display: flex; flex-direction: column; gap: 6px; margin: 2px 6px 6px 7px; padding: 8px;\n border-radius: 4px; background: rgba(127,127,127,.10); user-select: text;\n }\n .paneworks-sidebar .pw-menu { margin-top: 0; }\n .paneworks-sidebar .pw-field { display: flex; flex-direction: column; gap: 2px; margin: 0; }\n .paneworks-sidebar .pw-label { font-size: 10px; opacity: .6; }\n .paneworks-sidebar .pw-input {\n width: 100%; box-sizing: border-box; padding: 3px 6px; font: inherit; color: inherit; border-radius: 3px;\n background: var(--theme-bg, rgba(0,0,0,.3)); border: 1px solid rgba(127,127,127,.35);\n }\n .paneworks-sidebar .pw-input:focus { outline: none; border-color: var(--pw-accent); }\n .paneworks-sidebar .pw-size-row { display: flex; align-items: center; gap: 4px; }\n .paneworks-sidebar .pw-size { width: 64px; }\n .paneworks-sidebar .pw-check { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }\n .paneworks-sidebar .pw-hint { font-size: 10px; opacity: .55; }\n .paneworks-sidebar .pw-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }\n .paneworks-sidebar .pw-btn {\n padding: 3px 8px; border-radius: 3px; cursor: pointer; background: rgba(127,127,127,.2);\n border: 1px solid transparent;\n }\n .paneworks-sidebar .pw-btn:hover { background: rgba(127,127,127,.3); }\n .paneworks-sidebar .pw-btn.primary { background: var(--pw-accent); color: var(--theme-bg, #000); }\n .paneworks-sidebar .pw-btn.danger:hover { background: #c0392b; color: #fff; }\n .paneworks-sidebar .pw-menu-title { margin-top: 8px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .6; }\n .paneworks-sidebar .pw-menu-item {\n display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;\n background: none; border: none; padding: 4px 6px; border-radius: 3px; cursor: pointer; text-align: left;\n }\n .paneworks-sidebar .pw-menu-item:hover { background: rgba(127,127,127,.2); }\n .paneworks-sidebar .pw-menu-item.current { cursor: default; font-weight: 600; }\n .paneworks-sidebar .pw-menu-item.danger:hover { background: #c0392b; color: #fff; }\n `\n document.head.appendChild(style)\n }\n\n private loadCollapsed(workspaceId: string): boolean {\n try {\n return localStorage.getItem(`paneworks-sidebar-collapsed:${workspaceId}`) === '1'\n } catch {\n return false\n }\n }\n\n private saveCollapsed(workspaceId: string, collapsed: boolean): void {\n try {\n localStorage.setItem(`paneworks-sidebar-collapsed:${workspaceId}`, collapsed ? '1' : '0')\n } catch {\n // per-viewer convenience only\n }\n }\n}\n","import { Injectable } from '@angular/core'\nimport { ToolbarButtonProvider, ToolbarButton, AppService } from 'tabby-core'\nimport { WorkspaceEditorService } from '../services/workspaceEditor.service'\nimport { LayoutService } from '../services/layout.service'\nimport { DISPLAY_NAME, IS_DEV } from '../build-config'\n\nconst ICON_GRID = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"3\" width=\"7\" height=\"7\"/>\n <rect x=\"14\" y=\"3\" width=\"7\" height=\"7\"/>\n <rect x=\"14\" y=\"14\" width=\"7\" height=\"7\"/>\n <rect x=\"3\" y=\"14\" width=\"7\" height=\"7\"/>\n</svg>`\n\nconst ICON_BOLT = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <polygon points=\"13 2 3 14 12 14 11 22 21 10 12 10 13 2\"/>\n</svg>`\n\nconst NEW_WORKSPACE = '__new__'\n\n/**\n * The toolbar button: the entry point outside a workspace tab. Lists the workspaces\n * (open one, or bring it to the front if already open) and creates new ones.\n * Everything else is managed in the workspace tab's sidebar.\n */\n@Injectable()\nexport class WorkspaceToolbarProvider extends ToolbarButtonProvider {\n constructor(\n private workspaceService: WorkspaceEditorService,\n private app: AppService,\n private layout: LayoutService\n ) {\n super()\n // Wait for Tabby to finish recovering tabs before launching startup workspaces\n this.waitForTabbyReady().then(() => {\n this.workspaceService.cleanupOrphanedProfiles()\n this.launchStartupWorkspaces()\n })\n }\n\n private waitForTabbyReady(): Promise<void> {\n return new Promise(resolve => {\n let lastTabCount = -1\n const checkStable = () => {\n const currentCount = this.app.tabs.length\n if (currentCount === lastTabCount) {\n resolve()\n } else {\n lastTabCount = currentCount\n setTimeout(checkStable, 300)\n }\n }\n setTimeout(checkStable, 500)\n })\n }\n\n private async launchStartupWorkspaces(): Promise<void> {\n for (const workspace of this.workspaceService.getWorkspaces().filter((w) => w.launchOnStartup)) {\n if (this.layout.findOpenTab(workspace.id)) {\n console.log(`[${DISPLAY_NAME}] Workspace \"${workspace.name}\" already open, skipping`)\n continue\n }\n await this.layout.openWorkspace(workspace.id)\n }\n }\n\n provide(): ToolbarButton[] {\n return [\n {\n icon: IS_DEV ? ICON_BOLT : ICON_GRID,\n title: DISPLAY_NAME,\n weight: 5,\n click: () => this.showWorkspaceSelector(),\n },\n ]\n }\n\n private async showWorkspaceSelector(): Promise<void> {\n const options = this.workspaceService.getWorkspaces().map((ws) => ({\n name: ws.name,\n description: `${ws.panes.length} panes${this.layout.findOpenTab(ws.id) ? ' · open' : ''}`,\n icon: ws.icon || 'columns',\n color: ws.color,\n result: ws.id,\n }))\n options.push({\n name: 'New workspace',\n description: 'Create a workspace with one pane; set it up in its sidebar',\n icon: 'plus',\n color: undefined,\n result: NEW_WORKSPACE,\n })\n\n const selected = await this.app.showSelector(DISPLAY_NAME, options)\n if (selected === NEW_WORKSPACE) {\n await this.layout.createWorkspace()\n } else if (selected) {\n await this.layout.openWorkspace(selected)\n }\n }\n}\n","import { NgModule } from '@angular/core'\nimport { CommonModule } from '@angular/common'\nimport { ConfigProvider, ToolbarButtonProvider } from 'tabby-core'\n\nimport { WorkspaceEditorConfigProvider } from './providers/config.provider'\nimport { WorkspaceToolbarProvider } from './providers/toolbar.provider'\nimport { WorkspaceEditorService } from './services/workspaceEditor.service'\nimport { PaneRuntimeService } from './services/paneRuntime.service'\nimport { LayoutService } from './services/layout.service'\n\n/**\n * Paneworks: no settings page. The toolbar button opens and creates workspaces;\n * everything else is managed in the sidebar of a workspace tab (LayoutService).\n */\n@NgModule({\n imports: [CommonModule],\n providers: [\n { provide: ConfigProvider, useClass: WorkspaceEditorConfigProvider, multi: true },\n { provide: ToolbarButtonProvider, useClass: WorkspaceToolbarProvider, multi: true },\n WorkspaceEditorService,\n PaneRuntimeService,\n LayoutService,\n ],\n})\nexport default class PaneworksModule {}\n\nexport { WorkspaceEditorService }\n"],"names":["root","factory","exports","module","require","define","amd","a","i","global","__WEBPACK_EXTERNAL_MODULE__358__","__WEBPACK_EXTERNAL_MODULE__860__","__WEBPACK_EXTERNAL_MODULE__961__","__WEBPACK_EXTERNAL_MODULE__439__","__WEBPACK_EXTERNAL_MODULE__650__","__WEBPACK_EXTERNAL_MODULE__349__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","CONFIG_KEY","DISPLAY_NAME","WorkspaceEditorConfigProvider","ConfigProvider","defaults","workspaces","isLayoutSplit","node","layoutPaneIds","split","children","flatMap","c","paneId","planGrid","count","width","height","minWidth","minHeight","maxCols","Math","max","floor","maxRows","shown","min","best","rows","perRow","ceil","score","base","extra","Array","from","length","_","gridTree","paneIds","offset","rowNodes","map","n","ids","slice","orientation","ratios","normalizeWorkspace","workspace","isArray","panes","Injectable","PANE_MARKER_PREFIX","parsePaneMarker","group","startsWith","workspaceId","formatPaneLabel","paneName","programTitle","name","trim","title","createDefaultPane","id","generateUUID","profileId","cwd","startupCommand","WORKSPACE_COLORS","WORKSPACE_ICONS","replace","random","toString","WorkspaceEditorService","constructor","config","notifications","profilesService","cachedProfiles","cacheTimestamp","CACHE_TTL","getCachedProfiles","now","Date","this","getProfiles","getWorkspaces","store","saveWorkspaceQuietly","index","findIndex","w","saveWorkspaces","minPaneSize","minPaneWidth","minPaneHeight","planViewAll","visible","filter","p","hidden","reduce","b","tree","allPanesLayout","window","innerWidth","h","innerHeight","initialLayout","Error","saveConfig","addWorkspace","push","info","error","deleteWorkspace","find","filtered","getAvailableProfiles","cleanupOrphanedProfiles","profiles","prefix","save","console","log","generateTabbyProfile","safeName","sanitizeForProfileId","type","icon","color","isBuiltin","options","recoveryToken","generateRecoveryToken","createPaneToken","pane","generatePaneToken","paneworksWorkspaceId","tabTitle","disableDynamicTitle","child","workspaceName","baseProfile","getProfileById","marker","makePaneMarker","initialLabel","profile","savedState","tabCustomTitle","isLocalProfile","rawCwd","isWsl","isWslProfile","baseArgs","args","restoreFromPTYID","command","env","pauseAfterExit","runAsAdministrator","weight","isTemplate","terminalColorScheme","behaviorOnSessionEnd","toLowerCase","endsWith","collectStartupCommands","getWorkspace","providedIn","ConfigService","NotificationsService","ProfilesService","RESCAN_DELAYS_MS","PaneRuntimeService","app","workspaceSplitFound$","Subject","pendingCommands","Map","watchedSplits","WeakSet","attachedPanes","tabOpened$","subscribe","tab","onTabOpened","registerCommands","commands","cmd","set","SplitTabComponent","watchSplit","BaseTerminalTabComponent","processPane","has","add","scan","scanSplit","initialized$","complete","tabAdded$","delay","setTimeout","getAllTabs","pinSplitTitle","next","attachLabelSync","runPendingCommand","setTitle","tabAny","lastLabel","customTitle","active","update","findPane","label","setCustomTitle","originalSetTitle","bind","waitedForSession","pending","delete","send","sendInput","clearProfileArgs","sessionChanged$","session","pipe","first","s","timeout","catchError","of","output$","AppService","PANE_COLORS","LayoutService","runtime","tabsService","tabRecovery","states","WeakMap","Set","resizeTimer","watchedSessions","attach","addEventListener","clearTimeout","refreshAllGrids","findOpenTab","state","tabs","some","t","openWorkspace","open","selectTab","openNewTabForProfile","createWorkspace","loadProfiles","existing","launchOnStartup","createDefaultWorkspace","local","sidebar","isConnected","mountSidebar","view","kind","appliedPlan","parked","collapsed","loadCollapsed","busy","dragging","editingPaneId","menuOpen","timer","unseen","starting","leftAt","destroyed$","values","destroy","clear","clearInterval","remove","visibility$","refreshGrid","setInterval","render","startAllPanes","showAll","force","area","paneArea","plan","signature","JSON","stringify","wasAll","apply","showFocus","reapplyView","before","waitFor","missing","livePanes","every","check","timeoutMs","end","Promise","resolve","rect","splitElement","getBoundingClientRect","live","wanted","createPane","paneIdOf","includes","removeFromContainer","viewRefs","parent","buildContainer","maximizedTab","clearActivity","emitVisibility","visibility","attachTabView","onAfterTabAdded","layout","focus","recoveryStateChangedHint","nudgeResize","applyLabelColors","forEach","built","sum","container","SplitContainer","token","params","recoverTab","create","dispatchEvent","Event","toggleShown","movePane","beforePaneId","splice","to","addPane","last","savePane","fields","assign","restartPane","old","fresh","replaceTab","removePane","alert","confirm","still","other","saveWorkspaceSettings","round","closeTab","ref","hostView","viewContainerEmbeddedRef","el","rootNodes","HTMLElement","splitEl","host","parentElement","document","createElement","className","ensureStyles","insertBefore","setAttribute","colors","labels","querySelectorAll","querySelector","style","background","hex","test","g","parseInt","pow","readableTextColor","removeProperty","watchOutput","onScreen","__pwSignature","classList","toggle","flex","textContent","button","saveCollapsed","append","header","wsButton","workspaceMenu","enabled","shownCount","allRow","onclick","section","focused","list","paneRow","paneEditor","endZone","makeDropTarget","sub","Boolean","join","noRoom","hasNews","classes","row","draggable","e","dataTransfer","setData","effectAllowed","swatch","text","main","news","sw","input","checked","onchange","stopPropagation","more","box","empty","option","chosen","custom","paint","dataset","field","actions","async","minW","String","minH","size","startup","startupLabel","Number","isThis","item","preventDefault","dropEffect","getData","tag","onClick","placeholder","control","getElementById","head","appendChild","localStorage","getItem","setItem","TabsService","TabRecoveryService","NEW_WORKSPACE","WorkspaceToolbarProvider","ToolbarButtonProvider","workspaceService","super","waitForTabbyReady","then","launchStartupWorkspaces","lastTabCount","checkStable","currentCount","provide","click","showWorkspaceSelector","ws","description","result","selected","showSelector","PaneworksModule","NgModule","imports","CommonModule","providers","useClass","multi"],"sourceRoot":""}
@@ -0,0 +1,148 @@
1
+ export interface TabbyProfileOptions {
2
+ command?: string;
3
+ args?: string[];
4
+ cwd?: string;
5
+ env?: Record<string, string>;
6
+ restoreFromPTYID?: boolean;
7
+ width?: number | null;
8
+ height?: number | null;
9
+ pauseAfterExit?: boolean;
10
+ runAsAdministrator?: boolean;
11
+ }
12
+ export interface TabbyProfile {
13
+ id: string;
14
+ type: string;
15
+ name: string;
16
+ group?: string;
17
+ icon?: string;
18
+ color?: string;
19
+ options?: TabbyProfileOptions;
20
+ isBuiltin?: boolean;
21
+ isTemplate?: boolean;
22
+ weight?: number;
23
+ disableDynamicTitle?: boolean;
24
+ terminalColorScheme?: string | null;
25
+ behaviorOnSessionEnd?: string;
26
+ }
27
+ export interface TabbyRecoveryToken {
28
+ type: string;
29
+ orientation?: 'h' | 'v';
30
+ ratios?: number[];
31
+ children?: TabbyRecoveryToken[];
32
+ profile?: Partial<TabbyProfile>;
33
+ savedState?: boolean;
34
+ tabTitle?: string;
35
+ tabCustomTitle?: string;
36
+ disableDynamicTitle?: boolean;
37
+ cwd?: string;
38
+ [key: string]: any;
39
+ }
40
+ export interface TabbySplitLayoutProfile {
41
+ id: string;
42
+ type: 'split-layout';
43
+ name: string;
44
+ group: string;
45
+ icon?: string;
46
+ color?: string;
47
+ isBuiltin: boolean;
48
+ options: {
49
+ recoveryToken: TabbyRecoveryToken;
50
+ };
51
+ }
52
+ export interface WorkspacePane {
53
+ id: string;
54
+ name?: string;
55
+ profileId: string;
56
+ cwd?: string;
57
+ startupCommand?: string;
58
+ /** Switched off in the sidebar: not part of "View all" (still reachable by focus view). */
59
+ hidden?: boolean;
60
+ /** Background of the pane label (CSS colour, e.g. #3b82f6); none = Tabby's default. */
61
+ color?: string;
62
+ }
63
+ /** Black or white, whichever reads better on the given #rrggbb background. */
64
+ export declare function readableTextColor(background: string): string;
65
+ export interface Workspace {
66
+ id: string;
67
+ name: string;
68
+ icon?: string;
69
+ color?: string;
70
+ /** All panes, in sidebar and grid order. */
71
+ panes: WorkspacePane[];
72
+ /** Smallest pane size in px; decides how many panes fit and in how many rows. */
73
+ minPaneWidth?: number;
74
+ minPaneHeight?: number;
75
+ launchOnStartup?: boolean;
76
+ }
77
+ export declare const DEFAULT_MIN_PANE_WIDTH = 600;
78
+ export declare const DEFAULT_MIN_PANE_HEIGHT = 260;
79
+ /** Tree used internally to build Tabby's split layout. */
80
+ export interface LayoutPaneRef {
81
+ paneId: string;
82
+ }
83
+ export interface LayoutSplit {
84
+ orientation: 'horizontal' | 'vertical';
85
+ ratios: number[];
86
+ children: (LayoutPaneRef | LayoutSplit)[];
87
+ }
88
+ export declare function isLayoutSplit(node: LayoutPaneRef | LayoutSplit): node is LayoutSplit;
89
+ /** Pane ids of a layout tree in reading order. */
90
+ export declare function layoutPaneIds(split: LayoutSplit): string[];
91
+ /**
92
+ * Grid plan: how many panes go in each row.
93
+ * Fits as many of `count` panes as the minimum size allows in width x height,
94
+ * and among the arrangements that fit picks the one with the largest panes
95
+ * (relative to the minimum size); rows are filled evenly, fuller rows first.
96
+ * Examples (min 600x260, area 1900x1000, capacity 3x3): 3 panes -> [2, 1];
97
+ * 4 -> [2, 2]; 5 -> [2, 2, 1]; 8 -> [3, 3, 2]. In 1200x700 (capacity 2x2)
98
+ * 8 panes -> [2, 2]: only the first 4 are shown.
99
+ */
100
+ export declare function planGrid(count: number, width: number, height: number, minWidth: number, minHeight: number): number[];
101
+ /** Layout tree for panes arranged by a grid plan (rows stacked, panes side by side). */
102
+ export declare function gridTree(paneIds: string[], rows: number[]): LayoutSplit;
103
+ /** Makes sure a stored workspace has a pane list (e.g. one edited by hand in config.yaml). */
104
+ export declare function normalizeWorkspace(workspace: Workspace): Workspace;
105
+ /**
106
+ * Hidden marker that identifies a workspace pane at runtime.
107
+ * Stored in the pane's profile `group` field: Tabby keeps that field on the tab
108
+ * (including after app restart recovery) and never shows it on a running tab.
109
+ * An unknown group id makes Tabby skip group defaults, nothing else.
110
+ */
111
+ export declare const PANE_MARKER_PREFIX = "paneworks:";
112
+ export declare function makePaneMarker(workspaceId: string, paneId: string): string;
113
+ export declare function parsePaneMarker(group: unknown): {
114
+ workspaceId: string;
115
+ paneId: string;
116
+ } | null;
117
+ /**
118
+ * Text of a pane label: the program's title, prefixed by the pane name when one is set.
119
+ * Examples: ('C1', 'Claude Code') -> 'C1 · Claude Code'; ('', 'Claude Code') -> 'Claude Code'.
120
+ */
121
+ export declare function formatPaneLabel(paneName: string | undefined, programTitle: string | undefined): string;
122
+ /** Finds a pane of a workspace by id. */
123
+ export declare function findPane(workspace: Workspace, paneId: string): WorkspacePane | undefined;
124
+ /**
125
+ * Creates a new pane with default configuration.
126
+ * @returns A new WorkspacePane with generated UUID and empty settings
127
+ */
128
+ export declare function createDefaultPane(): WorkspacePane;
129
+ /** Returns a random color from the workspace color palette. */
130
+ export declare function getRandomColor(): string;
131
+ /** Returns a random icon from the workspace icon set. */
132
+ export declare function getRandomIcon(): string;
133
+ /**
134
+ * Creates a new workspace with default configuration.
135
+ * @param name - Display name for the workspace (optional)
136
+ * @returns A new Workspace with generated UUID, random icon/color and two panes
137
+ */
138
+ export declare function createDefaultWorkspace(name?: string): Workspace;
139
+ /** Generates a random UUID v4 string. */
140
+ export declare function generateUUID(): string;
141
+ /**
142
+ * Creates a deep clone of an object, preserving type information.
143
+ * More efficient than JSON.parse(JSON.stringify()) for simple objects.
144
+ * @param obj - The object to clone
145
+ * @returns A deep copy of the object
146
+ */
147
+ export declare function deepClone<T>(obj: T): T;
148
+ //# sourceMappingURL=workspace.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.model.d.ts","sourceRoot":"","sources":["../../src/models/workspace.model.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EA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AAqBD,+DAA+D;AAC/D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,yDAAyD;AACzD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,MAAW,GAAG,SAAS,CASnE;AAED,yCAAyC;AACzC,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CActC"}
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "tabby-paneworks",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Workspaces for Tabby: terminal panes with startup commands, arranged automatically by a minimum pane size and managed from a sidebar (focus view, on/off switches, drag-and-drop order, label colours). Panes show their program title; the tab shows the workspace name.",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "tabby",
8
+ "tabby-plugin",
9
+ "workspace",
10
+ "workspaces",
11
+ "panes",
12
+ "split",
13
+ "layout",
14
+ "grid",
15
+ "sidebar",
16
+ "startup-command",
17
+ "terminal"
18
+ ],
19
+ "peerDependencies": {
20
+ "@angular/common": "^15.0.0",
21
+ "@angular/core": "^15.0.0",
22
+ "@angular/forms": "^15.0.0",
23
+ "tabby-core": "*",
24
+ "tabby-local": "*",
25
+ "tabby-settings": "*",
26
+ "tabby-terminal": "*"
27
+ },
28
+ "author": "Patrick Schäfer",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/padjon/tabby-paneworks.git"
33
+ },
34
+ "homepage": "https://github.com/padjon/tabby-paneworks#readme",
35
+ "bugs": {
36
+ "url": "https://github.com/padjon/tabby-paneworks/issues"
37
+ },
38
+ "tabbyPlugin": {
39
+ "name": "paneworks",
40
+ "displayName": "Paneworks",
41
+ "description": "Workspaces for Tabby: terminal panes with startup commands, arranged automatically by a minimum pane size and managed from a sidebar (focus view, on/off switches, drag-and-drop order, label colours). Panes show their program title; the tab shows the workspace name."
42
+ }
6
43
  }
@@ -0,0 +1,9 @@
1
+ import { ConfigProvider } from 'tabby-core';
2
+ export declare class WorkspaceEditorConfigProvider extends ConfigProvider {
3
+ defaults: {
4
+ [x: string]: {
5
+ workspaces: never[];
6
+ };
7
+ };
8
+ }
9
+ //# sourceMappingURL=config.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.provider.d.ts","sourceRoot":"","sources":["../../src/providers/config.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C,qBACa,6BAA8B,SAAQ,cAAc;IAC/D,QAAQ;;;;MAIP;CACF"}
@@ -0,0 +1,19 @@
1
+ import { ToolbarButtonProvider, ToolbarButton, AppService } from 'tabby-core';
2
+ import { WorkspaceEditorService } from '../services/workspaceEditor.service';
3
+ import { LayoutService } from '../services/layout.service';
4
+ /**
5
+ * The toolbar button: the entry point outside a workspace tab. Lists the workspaces
6
+ * (open one, or bring it to the front if already open) and creates new ones.
7
+ * Everything else is managed in the workspace tab's sidebar.
8
+ */
9
+ export declare class WorkspaceToolbarProvider extends ToolbarButtonProvider {
10
+ private workspaceService;
11
+ private app;
12
+ private layout;
13
+ constructor(workspaceService: WorkspaceEditorService, app: AppService, layout: LayoutService);
14
+ private waitForTabbyReady;
15
+ private launchStartupWorkspaces;
16
+ provide(): ToolbarButton[];
17
+ private showWorkspaceSelector;
18
+ }
19
+ //# sourceMappingURL=toolbar.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar.provider.d.ts","sourceRoot":"","sources":["../../src/providers/toolbar.provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAgB1D;;;;GAIG;AACH,qBACa,wBAAyB,SAAQ,qBAAqB;IAE/D,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,MAAM;gBAFN,gBAAgB,EAAE,sBAAsB,EACxC,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,aAAa;IAU/B,OAAO,CAAC,iBAAiB;YAgBX,uBAAuB;IAUrC,OAAO,IAAI,aAAa,EAAE;YAWZ,qBAAqB;CAuBpC"}
@@ -0,0 +1,102 @@
1
+ import { AppService, ProfilesService, SplitTabComponent, TabRecoveryService, TabsService } from 'tabby-core';
2
+ import { PaneRuntimeService } from './paneRuntime.service';
3
+ import { WorkspaceEditorService } from './workspaceEditor.service';
4
+ /**
5
+ * Everything inside a Paneworks workspace tab: the sidebar (workspace menu, panes,
6
+ * switches, sorting, editing), the "View all" grid and the focus view; plus opening,
7
+ * focusing and creating workspaces.
8
+ * Showing and hiding moves live panes in and out of the split (the way Tabby's own
9
+ * drag and drop does), so hidden panes keep running; panes never shown before are
10
+ * created on demand with their startup command. Closing the tab closes all panes.
11
+ */
12
+ export declare class LayoutService {
13
+ private app;
14
+ private profilesService;
15
+ private runtime;
16
+ private workspaces;
17
+ private tabsService;
18
+ private tabRecovery;
19
+ private states;
20
+ private active;
21
+ private resizeTimer;
22
+ private profiles;
23
+ private watchedSessions;
24
+ constructor(app: AppService, profilesService: ProfilesService, runtime: PaneRuntimeService, workspaces: WorkspaceEditorService, tabsService: TabsService, tabRecovery: TabRecoveryService);
25
+ /** The open tab of a workspace, if any. */
26
+ findOpenTab(workspaceId: string): SplitTabComponent | null;
27
+ /** Opens a workspace, or brings its tab to the front when it is already open. */
28
+ openWorkspace(workspaceId: string): Promise<void>;
29
+ /** New workspace with one pane (profile of the first local shell); opened right away. */
30
+ createWorkspace(): Promise<void>;
31
+ private loadProfiles;
32
+ private attach;
33
+ private showAll;
34
+ private showFocus;
35
+ /** Shows the current view again (after panes changed). */
36
+ private reapplyView;
37
+ /** Re-fits "View all" to the current size; no-op when the grid stays the same. */
38
+ private refreshGrid;
39
+ /**
40
+ * Every pane of a workspace runs, switched off or not: hiding is only visual.
41
+ * Tabby starts a terminal's shell only once the terminal has been on screen, so the
42
+ * workspace first shows all its panes (a fresh open already does; after a Tabby
43
+ * restart only the panes that were on screen come back), waits until every shell
44
+ * runs, then switches to "View all", which hides the switched-off ones again.
45
+ */
46
+ private startAllPanes;
47
+ /** Polls until `check` returns a value (not null/false) or the timeout passes. */
48
+ private waitFor;
49
+ private refreshAllGrids;
50
+ /** Size of the area the panes get (the split element). Null while the tab is in the background. */
51
+ private paneArea;
52
+ /** Rebuilds the split to show exactly the panes of `tree`. Returns false if nothing could be shown. */
53
+ private apply;
54
+ private buildContainer;
55
+ private createPane;
56
+ private livePanes;
57
+ private paneIdOf;
58
+ /** Terminals refit on window resize; the split area changed. */
59
+ private nudgeResize;
60
+ private toggleShown;
61
+ private movePane;
62
+ private addPane;
63
+ private savePane;
64
+ /**
65
+ * Closes the pane's terminal and starts it again with its current settings
66
+ * (command, folder, profile). On screen it is swapped in place, so the tab stays open.
67
+ */
68
+ private restartPane;
69
+ private removePane;
70
+ private saveWorkspaceSettings;
71
+ private deleteWorkspace;
72
+ /**
73
+ * DOM element of the workspace tab. Tabby's tab-body inserts a top-level tab's
74
+ * `hostView` directly (viewContainerEmbeddedRef is only set for panes inside a split).
75
+ */
76
+ private splitElement;
77
+ private mountSidebar;
78
+ /**
79
+ * Pane label colours. Tabby renders one <split-tab-pane-label> per pane, in the
80
+ * order of split.getAllTabs(), and recreates them when panes change; so this runs
81
+ * on every sidebar tick and after every layout change.
82
+ */
83
+ private applyLabelColors;
84
+ /**
85
+ * Subscribes once to each pane's terminal output for "NEW": output while the pane
86
+ * is off screen, after the grace period, marks it until the pane is shown again.
87
+ */
88
+ private watchOutput;
89
+ private render;
90
+ private paneRow;
91
+ private paneEditor;
92
+ private workspaceMenu;
93
+ private makeDropTarget;
94
+ private node;
95
+ private button;
96
+ private input;
97
+ private field;
98
+ private ensureStyles;
99
+ private loadCollapsed;
100
+ private saveCollapsed;
101
+ }
102
+ //# sourceMappingURL=layout.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.service.d.ts","sourceRoot":"","sources":["../../src/services/layout.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAEV,eAAe,EAEf,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACZ,MAAM,YAAY,CAAA;AAgBnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAiB,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAmDjF;;;;;;;GAOG;AACH,qBACa,aAAa;IAQtB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IAZrB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,WAAW,CAA6C;IAChE,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,eAAe,CAAwB;gBAGrC,GAAG,EAAE,UAAU,EACf,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,kBAAkB,EAC3B,UAAU,EAAE,sBAAsB,EAClC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,kBAAkB;IAWzC,2CAA2C;IAC3C,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAa1D,iFAAiF;IAC3E,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAevD,yFAAyF;IACnF,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;YAYxB,YAAY;IAQ1B,OAAO,CAAC,MAAM;YA+CA,OAAO;YAmBP,SAAS;IAWvB,0DAA0D;YAC5C,WAAW;IAKzB,kFAAkF;IAClF,OAAO,CAAC,WAAW;IAInB;;;;;;OAMG;YACW,aAAa;IAwB3B,kFAAkF;YACpE,OAAO;IAUrB,OAAO,CAAC,eAAe;IAIvB,mGAAmG;IACnG,OAAO,CAAC,QAAQ;IAKhB,uGAAuG;YACzF,KAAK;IAqEnB,OAAO,CAAC,cAAc;YAmBR,UAAU;IAexB,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,QAAQ;IAIhB,gEAAgE;IAChE,OAAO,CAAC,WAAW;YAML,WAAW;YAWX,QAAQ;YAaR,OAAO;YAiBP,QAAQ;IAgBtB;;;OAGG;YACW,WAAW;YAwBX,UAAU;YAsCV,qBAAqB;YAqBrB,eAAe;IAY7B;;;OAGG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,YAAY;IAwBpB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,MAAM;IAiFd,OAAO,CAAC,OAAO;IA+Ef,OAAO,CAAC,UAAU;IAoFlB,OAAO,CAAC,aAAa;IAkErB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,KAAK;IAWb,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,YAAY;IA+KpB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,aAAa;CAOtB"}
@@ -0,0 +1,42 @@
1
+ import { AppService, SplitTabComponent } from 'tabby-core';
2
+ import { Subject } from 'rxjs';
3
+ import { WorkspaceEditorService } from './workspaceEditor.service';
4
+ export interface PendingCommand {
5
+ paneId: string;
6
+ command?: string;
7
+ }
8
+ /**
9
+ * Runtime behaviour of workspace panes, found by the hidden marker in their profile group:
10
+ * - sends the pane's startup command once, after the shell's first output;
11
+ * - keeps the outer tab titled with the workspace name;
12
+ * - keeps the pane label (Tabby shows a pane's custom title inside the split)
13
+ * in sync with the title the program sets, prefixed by the pane name.
14
+ * A manual "Rename pane" stops the sync for that pane.
15
+ *
16
+ * Module-level singleton for the app lifetime; subscriptions intentionally run forever.
17
+ */
18
+ export declare class PaneRuntimeService {
19
+ private app;
20
+ private workspaces;
21
+ /** Emitted whenever a split tab containing Paneworks panes is scanned (may repeat). */
22
+ readonly workspaceSplitFound$: Subject<{
23
+ split: SplitTabComponent;
24
+ workspaceId: string;
25
+ }>;
26
+ private pendingCommands;
27
+ private watchedSplits;
28
+ private attachedPanes;
29
+ constructor(app: AppService, workspaces: WorkspaceEditorService);
30
+ registerCommands(commands: PendingCommand[]): void;
31
+ private onTabOpened;
32
+ private watchSplit;
33
+ private scanSplit;
34
+ private processPane;
35
+ /** The outer tab shows the workspace name and ignores pane titles. */
36
+ private pinSplitTitle;
37
+ private attachLabelSync;
38
+ private runPendingCommand;
39
+ /** Prevents native splits of this pane from re-running the startup command. */
40
+ private clearProfileArgs;
41
+ }
42
+ //# sourceMappingURL=paneRuntime.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paneRuntime.service.d.ts","sourceRoot":"","sources":["../../src/services/paneRuntime.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAoB,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE5E,OAAO,EAAsB,OAAO,EAAE,MAAM,MAAM,CAAA;AAIlD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAYD;;;;;;;;;GASG;AACH,qBACa,kBAAkB;IAS3B,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,UAAU;IATpB,uFAAuF;IACvF,QAAQ,CAAC,oBAAoB;eAAwB,iBAAiB;qBAAe,MAAM;OAAK;IAEhG,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,aAAa,CAAkC;gBAG7C,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,sBAAsB;IAK5C,gBAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI;IAMlD,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,WAAW;IAgBnB,sEAAsE;IACtE,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,iBAAiB;IAqCzB,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;CAOzB"}
@@ -0,0 +1,80 @@
1
+ import { ConfigService, NotificationsService, ProfilesService } from 'tabby-core';
2
+ import { Workspace, WorkspacePane, LayoutSplit, TabbyProfile, TabbyRecoveryToken, TabbySplitLayoutProfile } from '../models/workspace.model';
3
+ /** Width of the Paneworks sidebar in a workspace tab (px). */
4
+ export declare const SIDEBAR_WIDTH = 210;
5
+ import { PendingCommand } from './paneRuntime.service';
6
+ export declare class WorkspaceEditorService {
7
+ private config;
8
+ private notifications;
9
+ private profilesService;
10
+ private cachedProfiles;
11
+ private cacheTimestamp;
12
+ private readonly CACHE_TTL;
13
+ constructor(config: ConfigService, notifications: NotificationsService, profilesService: ProfilesService);
14
+ private getCachedProfiles;
15
+ /** Returns all saved workspaces from config (old tree-shaped ones converted to a pane list). */
16
+ getWorkspaces(): Workspace[];
17
+ /**
18
+ * Saves one workspace's changed fields (pane order, switches) without a notification.
19
+ * Used by the sidebar.
20
+ */
21
+ saveWorkspaceQuietly(workspace: Workspace): Promise<void>;
22
+ /** Minimum pane size of a workspace, with defaults. */
23
+ minPaneSize(workspace: Workspace): {
24
+ width: number;
25
+ height: number;
26
+ };
27
+ /**
28
+ * "View all" grid of a workspace for a pane area: the switched-on panes in order,
29
+ * as many as fit. Returns the tree and the ids of the panes that fit.
30
+ */
31
+ planViewAll(workspace: Workspace, width: number, height: number): {
32
+ tree: LayoutSplit | null;
33
+ shown: string[];
34
+ };
35
+ /**
36
+ * Grid with every pane of a workspace, switched off ones included, ignoring the
37
+ * minimum size. A workspace opens with it: Tabby starts a terminal's shell only once
38
+ * the terminal has been on screen, and every pane must run. The sidebar then switches
39
+ * to "View all" (see LayoutService.startAllPanes).
40
+ */
41
+ allPanesLayout(workspace: Workspace, width?: number, height?: number): LayoutSplit | null;
42
+ private initialLayout;
43
+ /**
44
+ * Saves the workspace list to config.
45
+ * @throws Error if config store is not initialized
46
+ */
47
+ saveWorkspaces(workspaces: Workspace[]): Promise<void>;
48
+ /** Adds a new workspace and shows notification. */
49
+ addWorkspace(workspace: Workspace): Promise<void>;
50
+ /** Deletes a workspace by ID and shows notification. */
51
+ deleteWorkspace(workspaceId: string): Promise<void>;
52
+ /** Returns all profiles available for use in workspaces (local, SSH, serial, etc.). */
53
+ getAvailableProfiles(): Promise<TabbyProfile[]>;
54
+ /**
55
+ * Cleanup orphaned profiles from previous plugin versions.
56
+ * Call this once on plugin init.
57
+ */
58
+ cleanupOrphanedProfiles(): void;
59
+ /**
60
+ * Generates a Tabby split-layout profile from a workspace for opening:
61
+ * the "View all" grid of its switched-on panes; the others start when shown.
62
+ */
63
+ generateTabbyProfile(workspace: Workspace): Promise<TabbySplitLayoutProfile | null>;
64
+ /** Token for one pane of a workspace, used to create panes on demand (layouts, focus view). */
65
+ createPaneToken(workspace: Workspace, pane: WorkspacePane): Promise<TabbyRecoveryToken>;
66
+ private generateRecoveryToken;
67
+ private generatePaneToken;
68
+ private sanitizeForProfileId;
69
+ /** Checks if a profile is a local shell (local, local:wsl, local:powershell, etc.). */
70
+ private isLocalProfile;
71
+ /** Detects WSL profiles by ID prefix (built-in) or command path (user-defined). */
72
+ private isWslProfile;
73
+ private getProfileById;
74
+ /** Startup commands of all panes (a workspace opens with all of them). */
75
+ collectStartupCommands(workspace: Workspace): PendingCommand[];
76
+ /** Returns the workspace with the given id, if it still exists. */
77
+ getWorkspace(workspaceId: string): Workspace | undefined;
78
+ private saveConfig;
79
+ }
80
+ //# sourceMappingURL=workspaceEditor.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaceEditor.service.d.ts","sourceRoot":"","sources":["../../src/services/workspaceEditor.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACjF,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EAGX,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EAQxB,MAAM,2BAA2B,CAAA;AAElC,8DAA8D;AAC9D,eAAO,MAAM,aAAa,MAAM,CAAA;AAIhC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,qBACa,sBAAsB;IAM/B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,eAAe;IAPzB,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;gBAGxB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,oBAAoB,EACnC,eAAe,EAAE,eAAe;YAG5B,iBAAiB;IAS/B,gGAAgG;IAChG,aAAa,IAAI,SAAS,EAAE;IAQ5B;;;OAGG;IACG,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D,uDAAuD;IACvD,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOpE;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE;IAS/G;;;;;OAKG;IACH,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