@causyne/agent 1.20.124 → 1.20.128
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/bin/causyne.js +1 -1
- package/docs/THIRD_PARTY_NOTICES.md +36 -2
- package/package.json +6 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +142 -53
- package/src/agentLoop.ts +151 -50
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +61 -3
- package/src/browser/causyneBrowser.ts +65 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +365 -45
- package/src/commands.ts +403 -45
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/memory/episodicStore.js +40 -0
- package/src/memory/episodicStore.ts +46 -0
- package/src/memory.js +67 -0
- package/src/memory.ts +65 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/personalization.js +365 -0
- package/src/personalization.ts +471 -0
- package/src/projectInstructions.js +30 -10
- package/src/projectInstructions.ts +31 -12
- package/src/providers/acp.js +3 -2
- package/src/providers/acp.ts +3 -2
- package/src/providers/antigravity.js +64 -9
- package/src/providers/antigravity.ts +75 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/memoryWrite.js +15 -1
- package/src/tools/memoryWrite.ts +16 -1
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/osSandbox.js +1 -1
- package/src/tools/osSandbox.ts +1 -1
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1108 -0
- package/src/tools/ptyTerminal.ts +1245 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +905 -0
- package/src/web/client/browserPanel.ts +872 -0
- package/src/web/client/chatStream.js +321 -0
- package/src/web/client/chatStream.ts +297 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +271 -0
- package/src/web/client/dom.ts +272 -0
- package/src/web/client/filesAndCanvas.js +233 -0
- package/src/web/client/filesAndCanvas.ts +240 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +316 -0
- package/src/web/client/main.ts +391 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +824 -0
- package/src/web/client/settingsModal.ts +959 -0
- package/src/web/client/state.js +280 -0
- package/src/web/client/state.ts +259 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +89 -0
- package/src/web/client/studioLayout.ts +103 -0
- package/src/web/client/studioShell.js +660 -0
- package/src/web/client/studioShell.ts +672 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +606 -0
- package/src/web/client/terminalPanel.ts +632 -0
- package/src/web/client/terminalTheme.js +249 -0
- package/src/web/client/terminalTheme.ts +258 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +322 -0
- package/src/web/client/validators.js +147 -0
- package/src/web/client/validators.ts +140 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +409 -0
- package/src/web/server/routesBrowser.ts +435 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesSettings.js +344 -0
- package/src/web/server/routesSettings.ts +397 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +104 -0
- package/src/web/server/staticAssets.ts +116 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +78 -2448
- package/src/web/skybridgeServer.ts +120 -2600
- package/src/web/skybridgeUi.js +20 -450
- package/src/web/skybridgeUi.ts +24 -455
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +935 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +951 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +388 -0
- package/src/web/ui/modalsTemplate.ts +388 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +256 -0
- package/src/web/ui/studioTemplate.ts +256 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { dom } from './dom.js';
|
|
2
|
+
import { DEFAULT_STUDIO_W, applyStudioWidth, state, syncExpandedStudioWidth } from './state.js';
|
|
3
|
+
import { clampSplitRatio, halvesFitWidth, isValidStudioTab, loadPersistedStudioLayout, normalizeOpenTabs, persistStudioLayout, pickDistinctSecondaryTab } from './studioLayout.js';
|
|
4
|
+
const DEFAULT_TAB_LABELS = {
|
|
5
|
+
start: 'Start',
|
|
6
|
+
files: 'Files',
|
|
7
|
+
canvas: 'Editor',
|
|
8
|
+
terminal: 'Terminal',
|
|
9
|
+
browser: 'Browser',
|
|
10
|
+
diff: 'Changes',
|
|
11
|
+
cli: 'Commands'
|
|
12
|
+
};
|
|
13
|
+
const dynamicTabTitles = new Map();
|
|
14
|
+
let lastActiveStudioTab = null;
|
|
15
|
+
let tabHandlers = {
|
|
16
|
+
onFilesTab: () => { },
|
|
17
|
+
onDiffTab: () => { },
|
|
18
|
+
onCliTab: () => { },
|
|
19
|
+
onTerminalActivate: () => { },
|
|
20
|
+
onTerminalDeactivate: () => { },
|
|
21
|
+
onTerminalClose: () => { },
|
|
22
|
+
onBrowserActivate: () => { },
|
|
23
|
+
onBrowserDeactivate: () => { },
|
|
24
|
+
onBrowserClose: () => { },
|
|
25
|
+
onLayoutResized: () => { }
|
|
26
|
+
};
|
|
27
|
+
export function configureStudioTabHandlers(handlers) {
|
|
28
|
+
tabHandlers = handlers;
|
|
29
|
+
}
|
|
30
|
+
export function closeAllPopovers() {
|
|
31
|
+
dom.modelPopover.classList.remove('open');
|
|
32
|
+
dom.plusPopover.classList.remove('open');
|
|
33
|
+
dom.permPopover.classList.remove('open');
|
|
34
|
+
dom.permTriggerBtn.classList.remove('open');
|
|
35
|
+
dom.mentionPopover.classList.remove('open');
|
|
36
|
+
dom.browserMorePopover.classList.remove('open');
|
|
37
|
+
dom.modelTriggerBtn.setAttribute('aria-expanded', 'false');
|
|
38
|
+
dom.plusBtn.setAttribute('aria-expanded', 'false');
|
|
39
|
+
dom.permTriggerBtn.setAttribute('aria-expanded', 'false');
|
|
40
|
+
dom.browserMoreBtn.setAttribute('aria-expanded', 'false');
|
|
41
|
+
}
|
|
42
|
+
export function positionPopover(pop, anchor, preferUp) {
|
|
43
|
+
const rect = anchor.getBoundingClientRect();
|
|
44
|
+
pop.classList.add('open');
|
|
45
|
+
const pw = pop.offsetWidth || 300;
|
|
46
|
+
const ph = pop.offsetHeight || 220;
|
|
47
|
+
let left = rect.left;
|
|
48
|
+
if (left + pw > window.innerWidth - 10)
|
|
49
|
+
left = rect.right - pw;
|
|
50
|
+
left = Math.max(10, Math.min(window.innerWidth - pw - 10, left));
|
|
51
|
+
let top = preferUp ? (rect.top - ph - 8) : (rect.bottom + 8);
|
|
52
|
+
if (top < 10)
|
|
53
|
+
top = rect.bottom + 8;
|
|
54
|
+
if (top + ph > window.innerHeight - 10)
|
|
55
|
+
top = Math.max(10, window.innerHeight - ph - 10);
|
|
56
|
+
pop.style.left = `${left}px`;
|
|
57
|
+
pop.style.top = `${top}px`;
|
|
58
|
+
}
|
|
59
|
+
export function isStudioTabVisible(tab) {
|
|
60
|
+
return state.studioTab === tab || (state.studioSplit && state.studioSecondaryTab === tab);
|
|
61
|
+
}
|
|
62
|
+
function createSvgElement(tag, attrs) {
|
|
63
|
+
const el = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
|
64
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
65
|
+
el.setAttribute(k, v);
|
|
66
|
+
}
|
|
67
|
+
return el;
|
|
68
|
+
}
|
|
69
|
+
function createTabIconSvg(tab) {
|
|
70
|
+
const svg = createSvgElement('svg', {
|
|
71
|
+
class: 'studio-tab-icon',
|
|
72
|
+
viewBox: '0 0 24 24',
|
|
73
|
+
'aria-hidden': 'true'
|
|
74
|
+
});
|
|
75
|
+
if (tab === 'start') {
|
|
76
|
+
svg.appendChild(createSvgElement('circle', { cx: '12', cy: '12', r: '9' }));
|
|
77
|
+
svg.appendChild(createSvgElement('polygon', { points: '16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76' }));
|
|
78
|
+
}
|
|
79
|
+
else if (tab === 'files') {
|
|
80
|
+
svg.appendChild(createSvgElement('path', { d: 'M3 7a2 2 0 0 1 2-2h5l2 2h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z' }));
|
|
81
|
+
}
|
|
82
|
+
else if (tab === 'canvas') {
|
|
83
|
+
svg.appendChild(createSvgElement('path', { d: 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z' }));
|
|
84
|
+
svg.appendChild(createSvgElement('polyline', { points: '14 2 14 8 20 8' }));
|
|
85
|
+
}
|
|
86
|
+
else if (tab === 'terminal') {
|
|
87
|
+
svg.appendChild(createSvgElement('polyline', { points: '4 17 10 11 4 5' }));
|
|
88
|
+
svg.appendChild(createSvgElement('line', { x1: '12', y1: '19', x2: '20', y2: '19' }));
|
|
89
|
+
}
|
|
90
|
+
else if (tab === 'browser') {
|
|
91
|
+
svg.appendChild(createSvgElement('circle', { cx: '12', cy: '12', r: '9' }));
|
|
92
|
+
svg.appendChild(createSvgElement('line', { x1: '3', y1: '12', x2: '21', y2: '12' }));
|
|
93
|
+
svg.appendChild(createSvgElement('path', { d: 'M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18' }));
|
|
94
|
+
}
|
|
95
|
+
else if (tab === 'diff') {
|
|
96
|
+
svg.appendChild(createSvgElement('circle', { cx: '18', cy: '18', r: '3' }));
|
|
97
|
+
svg.appendChild(createSvgElement('circle', { cx: '6', cy: '6', r: '3' }));
|
|
98
|
+
svg.appendChild(createSvgElement('path', { d: 'M6 9v6a3 3 0 0 0 3 3h6' }));
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
svg.appendChild(createSvgElement('polyline', { points: '9 18 15 12 9 6' }));
|
|
102
|
+
}
|
|
103
|
+
return svg;
|
|
104
|
+
}
|
|
105
|
+
function createCloseIconSvg() {
|
|
106
|
+
const svg = createSvgElement('svg', {
|
|
107
|
+
viewBox: '0 0 24 24',
|
|
108
|
+
'aria-hidden': 'true'
|
|
109
|
+
});
|
|
110
|
+
svg.appendChild(createSvgElement('line', { x1: '18', y1: '6', x2: '6', y2: '18' }));
|
|
111
|
+
svg.appendChild(createSvgElement('line', { x1: '6', y1: '6', x2: '18', y2: '18' }));
|
|
112
|
+
return svg;
|
|
113
|
+
}
|
|
114
|
+
function tabDisplayTitle(tab) {
|
|
115
|
+
const dynamic = dynamicTabTitles.get(tab);
|
|
116
|
+
if (dynamic && dynamic.trim())
|
|
117
|
+
return dynamic.trim();
|
|
118
|
+
return DEFAULT_TAB_LABELS[tab] || tab;
|
|
119
|
+
}
|
|
120
|
+
function persistCurrentLayout() {
|
|
121
|
+
persistStudioLayout({
|
|
122
|
+
openTabs: state.studioOpenTabs,
|
|
123
|
+
primaryTab: state.studioTab,
|
|
124
|
+
splitActive: state.studioSplit,
|
|
125
|
+
secondaryTab: state.studioSecondaryTab,
|
|
126
|
+
splitRatio: state.studioSplitRatio
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function applySplitRatioVar() {
|
|
130
|
+
const ratio = clampSplitRatio(state.studioSplitRatio);
|
|
131
|
+
state.studioSplitRatio = ratio;
|
|
132
|
+
const leftPct = `${(ratio * 100).toFixed(2)}%`;
|
|
133
|
+
const rightPct = `${((1 - ratio) * 100).toFixed(2)}%`;
|
|
134
|
+
if (dom.studioPanesGrid) {
|
|
135
|
+
dom.studioPanesGrid.style.setProperty('--studio-split-left', leftPct);
|
|
136
|
+
dom.studioPanesGrid.style.setProperty('--studio-split-right', rightPct);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export function setStudioTabDynamicTitle(tab, title) {
|
|
140
|
+
if (!isValidStudioTab(tab))
|
|
141
|
+
return;
|
|
142
|
+
const clean = typeof title === 'string' ? title.trim().slice(0, 40) : '';
|
|
143
|
+
const prev = dynamicTabTitles.get(tab) || '';
|
|
144
|
+
if (clean === prev)
|
|
145
|
+
return;
|
|
146
|
+
if (clean)
|
|
147
|
+
dynamicTabTitles.set(tab, clean);
|
|
148
|
+
else
|
|
149
|
+
dynamicTabTitles.delete(tab);
|
|
150
|
+
const labelEl = dom.studioTabs?.querySelector(`.studio-tab[data-tab="${tab}"] .studio-tab-label`);
|
|
151
|
+
if (labelEl) {
|
|
152
|
+
const nextText = tabDisplayTitle(tab);
|
|
153
|
+
labelEl.textContent = nextText;
|
|
154
|
+
const chipEl = labelEl.closest('.studio-tab');
|
|
155
|
+
if (chipEl)
|
|
156
|
+
chipEl.title = nextText;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function scrollActiveTabIntoView() {
|
|
160
|
+
const strip = dom.studioTabs;
|
|
161
|
+
if (!strip)
|
|
162
|
+
return;
|
|
163
|
+
const activeChip = strip.querySelector('.studio-tab.active');
|
|
164
|
+
if (!activeChip)
|
|
165
|
+
return;
|
|
166
|
+
const stripRect = strip.getBoundingClientRect();
|
|
167
|
+
if (stripRect.width <= 0)
|
|
168
|
+
return;
|
|
169
|
+
const chipRect = activeChip.getBoundingClientRect();
|
|
170
|
+
if (chipRect.left < stripRect.left) {
|
|
171
|
+
strip.scrollLeft = Math.max(0, strip.scrollLeft - (stripRect.left - chipRect.left) - 6);
|
|
172
|
+
}
|
|
173
|
+
else if (chipRect.right > stripRect.right) {
|
|
174
|
+
strip.scrollLeft = strip.scrollLeft + (chipRect.right - stripRect.right) + 6;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export function renderStudioTabs() {
|
|
178
|
+
const strip = dom.studioTabs;
|
|
179
|
+
if (!strip)
|
|
180
|
+
return;
|
|
181
|
+
const effectiveSplit = state.studioSplit && state.studioSecondaryTab !== state.studioTab;
|
|
182
|
+
const openTabs = normalizeOpenTabs(state.studioOpenTabs, state.studioTab, effectiveSplit, state.studioSecondaryTab);
|
|
183
|
+
state.studioOpenTabs = openTabs;
|
|
184
|
+
const isQuietLoneStart = openTabs.length === 1 && openTabs[0] === 'start' && !effectiveSplit;
|
|
185
|
+
strip.textContent = '';
|
|
186
|
+
openTabs.forEach((tab, index) => {
|
|
187
|
+
if (index > 0) {
|
|
188
|
+
const slot = document.createElement('span');
|
|
189
|
+
slot.className = 'studio-tab-slot';
|
|
190
|
+
slot.setAttribute('aria-hidden', 'true');
|
|
191
|
+
strip.appendChild(slot);
|
|
192
|
+
}
|
|
193
|
+
const isPrimary = tab === state.studioTab;
|
|
194
|
+
const isSecondary = effectiveSplit && tab === state.studioSecondaryTab;
|
|
195
|
+
const closable = !isQuietLoneStart;
|
|
196
|
+
const labelText = tabDisplayTitle(tab);
|
|
197
|
+
const chip = document.createElement('div');
|
|
198
|
+
chip.className = 'studio-tab';
|
|
199
|
+
if (isPrimary)
|
|
200
|
+
chip.classList.add('active');
|
|
201
|
+
if (isSecondary)
|
|
202
|
+
chip.classList.add('split-secondary');
|
|
203
|
+
if (isQuietLoneStart)
|
|
204
|
+
chip.classList.add('quiet');
|
|
205
|
+
chip.setAttribute('data-tab', tab);
|
|
206
|
+
chip.setAttribute('role', 'tab');
|
|
207
|
+
chip.setAttribute('aria-selected', isPrimary ? 'true' : 'false');
|
|
208
|
+
chip.tabIndex = isPrimary ? 0 : -1;
|
|
209
|
+
chip.title = labelText;
|
|
210
|
+
const titleWrap = document.createElement('span');
|
|
211
|
+
titleWrap.className = 'studio-tab-title';
|
|
212
|
+
titleWrap.appendChild(createTabIconSvg(tab));
|
|
213
|
+
const label = document.createElement('span');
|
|
214
|
+
label.className = 'studio-tab-label';
|
|
215
|
+
label.textContent = labelText;
|
|
216
|
+
titleWrap.appendChild(label);
|
|
217
|
+
chip.appendChild(titleWrap);
|
|
218
|
+
chip.addEventListener('click', (e) => {
|
|
219
|
+
const target = e.target;
|
|
220
|
+
if (target && target.closest('.studio-tab-close'))
|
|
221
|
+
return;
|
|
222
|
+
setStudioTab(tab);
|
|
223
|
+
});
|
|
224
|
+
chip.addEventListener('keydown', (e) => {
|
|
225
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
setStudioTab(tab);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
if (closable) {
|
|
231
|
+
chip.addEventListener('auxclick', (e) => {
|
|
232
|
+
if (e.button === 1) {
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
closeStudioTab(tab);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
const closeBtn = document.createElement('button');
|
|
238
|
+
closeBtn.type = 'button';
|
|
239
|
+
closeBtn.className = 'studio-tab-close';
|
|
240
|
+
closeBtn.setAttribute('aria-label', `Close ${labelText}`);
|
|
241
|
+
closeBtn.title = `Close ${labelText}`;
|
|
242
|
+
closeBtn.appendChild(createCloseIconSvg());
|
|
243
|
+
closeBtn.addEventListener('click', (e) => {
|
|
244
|
+
e.stopPropagation();
|
|
245
|
+
closeStudioTab(tab);
|
|
246
|
+
});
|
|
247
|
+
chip.appendChild(closeBtn);
|
|
248
|
+
}
|
|
249
|
+
strip.appendChild(chip);
|
|
250
|
+
});
|
|
251
|
+
scrollActiveTabIntoView();
|
|
252
|
+
window.requestAnimationFrame(scrollActiveTabIntoView);
|
|
253
|
+
}
|
|
254
|
+
function syncStudioPanes() {
|
|
255
|
+
const effectiveSplit = state.studioSplit && state.studioSecondaryTab !== state.studioTab;
|
|
256
|
+
dom.appEl.classList.toggle('studio-split', effectiveSplit);
|
|
257
|
+
applySplitRatioVar();
|
|
258
|
+
if (dom.studioSplitBar)
|
|
259
|
+
dom.studioSplitBar.classList.toggle('open', effectiveSplit);
|
|
260
|
+
if (dom.studioSplitBtn) {
|
|
261
|
+
dom.studioSplitBtn.classList.toggle('active', effectiveSplit);
|
|
262
|
+
dom.studioSplitBtn.setAttribute('aria-pressed', effectiveSplit ? 'true' : 'false');
|
|
263
|
+
}
|
|
264
|
+
if (dom.studioSecondarySelect && dom.studioSecondarySelect.value !== state.studioSecondaryTab) {
|
|
265
|
+
dom.studioSecondarySelect.value = state.studioSecondaryTab;
|
|
266
|
+
}
|
|
267
|
+
renderStudioTabs();
|
|
268
|
+
document.querySelectorAll('.studio-pane').forEach((p) => {
|
|
269
|
+
const t = p.getAttribute('data-pane') || '';
|
|
270
|
+
const isPrimary = t === state.studioTab;
|
|
271
|
+
const isSecondary = effectiveSplit && t === state.studioSecondaryTab;
|
|
272
|
+
p.classList.toggle('active', isPrimary || isSecondary);
|
|
273
|
+
p.classList.toggle('pane-primary', isPrimary);
|
|
274
|
+
p.classList.toggle('pane-secondary', isSecondary);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function notifyVisibleTabs() {
|
|
278
|
+
if (!dom.appEl.classList.contains('studio-open'))
|
|
279
|
+
return;
|
|
280
|
+
if (isStudioTabVisible('files'))
|
|
281
|
+
tabHandlers.onFilesTab();
|
|
282
|
+
if (isStudioTabVisible('diff'))
|
|
283
|
+
tabHandlers.onDiffTab();
|
|
284
|
+
if (isStudioTabVisible('cli'))
|
|
285
|
+
tabHandlers.onCliTab();
|
|
286
|
+
if (isStudioTabVisible('terminal'))
|
|
287
|
+
tabHandlers.onTerminalActivate();
|
|
288
|
+
else
|
|
289
|
+
tabHandlers.onTerminalDeactivate();
|
|
290
|
+
if (isStudioTabVisible('browser') && state.browserEngine === 'agent') {
|
|
291
|
+
tabHandlers.onBrowserActivate();
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
tabHandlers.onBrowserDeactivate();
|
|
295
|
+
}
|
|
296
|
+
tabHandlers.onLayoutResized();
|
|
297
|
+
}
|
|
298
|
+
export function syncPanelChromeState() {
|
|
299
|
+
const isOpen = dom.appEl.classList.contains('studio-open');
|
|
300
|
+
dom.studioToggleBtn.classList.toggle('active', isOpen);
|
|
301
|
+
dom.studioToggleBtn.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
302
|
+
if (dom.studioExpandBtn) {
|
|
303
|
+
dom.studioExpandBtn.classList.toggle('active', state.studioExpanded);
|
|
304
|
+
dom.studioExpandBtn.title = state.studioExpanded ? 'Restore panel width' : 'Expand panel (⌘⌥↵)';
|
|
305
|
+
}
|
|
306
|
+
const navPairs = [
|
|
307
|
+
[dom.navFilesBtn, 'files'],
|
|
308
|
+
[dom.navCanvasBtn, 'canvas'],
|
|
309
|
+
[dom.navTerminalBtn, 'terminal'],
|
|
310
|
+
[dom.navBrowserBtn, 'browser'],
|
|
311
|
+
[dom.navCliBtn, 'cli'],
|
|
312
|
+
[dom.navDiffBtn, 'diff']
|
|
313
|
+
];
|
|
314
|
+
for (const [btn, tab] of navPairs) {
|
|
315
|
+
if (!btn)
|
|
316
|
+
continue;
|
|
317
|
+
btn.classList.toggle('active', isOpen && isStudioTabVisible(tab));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
export function restoreStudioLayoutPreference() {
|
|
321
|
+
const saved = loadPersistedStudioLayout();
|
|
322
|
+
state.studioOpenTabs = saved.openTabs;
|
|
323
|
+
state.studioTab = saved.primaryTab;
|
|
324
|
+
state.studioSplit = saved.splitActive;
|
|
325
|
+
state.studioSecondaryTab = saved.secondaryTab;
|
|
326
|
+
state.studioSplitRatio = saved.splitRatio;
|
|
327
|
+
syncStudioPanes();
|
|
328
|
+
}
|
|
329
|
+
export function setStudioTab(tab) {
|
|
330
|
+
const nextTab = isValidStudioTab(tab) ? tab : 'start';
|
|
331
|
+
if (state.studioTab && state.studioTab !== nextTab && state.studioTab !== 'start') {
|
|
332
|
+
lastActiveStudioTab = state.studioTab;
|
|
333
|
+
}
|
|
334
|
+
if (!state.studioOpenTabs.includes(nextTab)) {
|
|
335
|
+
// Opening a concrete tool from a lone Start tab replaces Start smoothly,
|
|
336
|
+
// while opening Start via "+" appends it as a launch tab.
|
|
337
|
+
if (nextTab !== 'start'
|
|
338
|
+
&& state.studioOpenTabs.length === 1
|
|
339
|
+
&& state.studioOpenTabs[0] === 'start'
|
|
340
|
+
&& !state.studioSplit) {
|
|
341
|
+
state.studioOpenTabs = [nextTab];
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
state.studioOpenTabs = [...state.studioOpenTabs, nextTab];
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (state.studioSplit && nextTab === state.studioSecondaryTab) {
|
|
348
|
+
state.studioSecondaryTab = pickDistinctSecondaryTab(nextTab, state.studioTab);
|
|
349
|
+
}
|
|
350
|
+
state.studioTab = nextTab;
|
|
351
|
+
persistCurrentLayout();
|
|
352
|
+
syncStudioPanes();
|
|
353
|
+
syncPanelChromeState();
|
|
354
|
+
notifyVisibleTabs();
|
|
355
|
+
}
|
|
356
|
+
export function closeStudioTab(tab) {
|
|
357
|
+
if (!isValidStudioTab(tab))
|
|
358
|
+
return;
|
|
359
|
+
const idx = state.studioOpenTabs.indexOf(tab);
|
|
360
|
+
if (idx === -1)
|
|
361
|
+
return;
|
|
362
|
+
if (tab === 'browser') {
|
|
363
|
+
dynamicTabTitles.delete('browser');
|
|
364
|
+
tabHandlers.onBrowserClose();
|
|
365
|
+
}
|
|
366
|
+
else if (tab === 'terminal') {
|
|
367
|
+
dynamicTabTitles.delete('terminal');
|
|
368
|
+
tabHandlers.onTerminalClose();
|
|
369
|
+
}
|
|
370
|
+
else if (tab === 'canvas') {
|
|
371
|
+
dynamicTabTitles.delete('canvas');
|
|
372
|
+
}
|
|
373
|
+
const remaining = state.studioOpenTabs.filter((t) => t !== tab);
|
|
374
|
+
if (remaining.length === 0) {
|
|
375
|
+
state.studioOpenTabs = ['start'];
|
|
376
|
+
state.studioTab = 'start';
|
|
377
|
+
state.studioSplit = false;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
state.studioOpenTabs = remaining;
|
|
381
|
+
if (state.studioSplit) {
|
|
382
|
+
if (remaining.length < 2) {
|
|
383
|
+
state.studioSplit = false;
|
|
384
|
+
state.studioTab = remaining[0] || 'start';
|
|
385
|
+
}
|
|
386
|
+
else if (tab === state.studioTab) {
|
|
387
|
+
const nextPrimary = remaining.find((t) => t !== state.studioSecondaryTab) || remaining[0] || 'start';
|
|
388
|
+
state.studioTab = nextPrimary;
|
|
389
|
+
}
|
|
390
|
+
else if (tab === state.studioSecondaryTab) {
|
|
391
|
+
const nextSecondary = remaining.find((t) => t !== state.studioTab) || pickDistinctSecondaryTab(state.studioTab);
|
|
392
|
+
state.studioSecondaryTab = nextSecondary;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else if (tab === state.studioTab) {
|
|
396
|
+
const nextIdx = Math.min(idx, remaining.length - 1);
|
|
397
|
+
state.studioTab = remaining[nextIdx] || 'start';
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
persistCurrentLayout();
|
|
401
|
+
syncStudioPanes();
|
|
402
|
+
syncPanelChromeState();
|
|
403
|
+
notifyVisibleTabs();
|
|
404
|
+
}
|
|
405
|
+
export function setSecondaryStudioTab(tab) {
|
|
406
|
+
if (!isValidStudioTab(tab))
|
|
407
|
+
return;
|
|
408
|
+
if (!state.studioOpenTabs.includes(tab)) {
|
|
409
|
+
state.studioOpenTabs = [...state.studioOpenTabs, tab];
|
|
410
|
+
}
|
|
411
|
+
if (tab === state.studioTab) {
|
|
412
|
+
const prevPrimary = state.studioTab;
|
|
413
|
+
state.studioTab = state.studioSecondaryTab;
|
|
414
|
+
state.studioSecondaryTab = prevPrimary;
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
state.studioSecondaryTab = tab;
|
|
418
|
+
}
|
|
419
|
+
persistCurrentLayout();
|
|
420
|
+
syncStudioPanes();
|
|
421
|
+
syncPanelChromeState();
|
|
422
|
+
notifyVisibleTabs();
|
|
423
|
+
}
|
|
424
|
+
export function toggleStudioSplit(force) {
|
|
425
|
+
const nextSplit = typeof force === 'boolean' ? force : !state.studioSplit;
|
|
426
|
+
if (nextSplit) {
|
|
427
|
+
if (!dom.appEl.classList.contains('studio-open')) {
|
|
428
|
+
openStudio(state.studioTab || 'start');
|
|
429
|
+
}
|
|
430
|
+
const studioRectW = dom.studioRoot?.getBoundingClientRect().width || state.studioWidth;
|
|
431
|
+
if (!halvesFitWidth(studioRectW) && !state.studioExpanded) {
|
|
432
|
+
state.studioExpanded = true;
|
|
433
|
+
if (window.innerWidth > 960 && window.innerWidth < 1380) {
|
|
434
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
435
|
+
}
|
|
436
|
+
syncExpandedStudioWidth();
|
|
437
|
+
dom.appEl.classList.toggle('studio-expanded', true);
|
|
438
|
+
}
|
|
439
|
+
const recentCandidate = lastActiveStudioTab
|
|
440
|
+
&& lastActiveStudioTab !== state.studioTab
|
|
441
|
+
&& state.studioOpenTabs.includes(lastActiveStudioTab)
|
|
442
|
+
? lastActiveStudioTab
|
|
443
|
+
: undefined;
|
|
444
|
+
const otherOpen = recentCandidate
|
|
445
|
+
|| state.studioOpenTabs.find((t) => t !== state.studioTab && t !== 'start')
|
|
446
|
+
|| state.studioOpenTabs.find((t) => t !== state.studioTab);
|
|
447
|
+
state.studioSecondaryTab = pickDistinctSecondaryTab(state.studioTab, otherOpen || state.studioSecondaryTab);
|
|
448
|
+
if (!state.studioOpenTabs.includes(state.studioSecondaryTab)) {
|
|
449
|
+
state.studioOpenTabs = [...state.studioOpenTabs, state.studioSecondaryTab];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
state.studioSplit = nextSplit;
|
|
453
|
+
persistCurrentLayout();
|
|
454
|
+
syncStudioPanes();
|
|
455
|
+
syncPanelChromeState();
|
|
456
|
+
notifyVisibleTabs();
|
|
457
|
+
}
|
|
458
|
+
export function swapStudioSplitPanes() {
|
|
459
|
+
if (!state.studioSplit)
|
|
460
|
+
return;
|
|
461
|
+
const prevPrimary = state.studioTab;
|
|
462
|
+
state.studioTab = state.studioSecondaryTab;
|
|
463
|
+
state.studioSecondaryTab = prevPrimary;
|
|
464
|
+
persistCurrentLayout();
|
|
465
|
+
syncStudioPanes();
|
|
466
|
+
syncPanelChromeState();
|
|
467
|
+
notifyVisibleTabs();
|
|
468
|
+
}
|
|
469
|
+
export function openStudio(tab) {
|
|
470
|
+
closeAllPopovers();
|
|
471
|
+
if (window.innerWidth <= 960)
|
|
472
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
473
|
+
if (dom.studioRoot) {
|
|
474
|
+
dom.studioRoot.style.flexBasis = '';
|
|
475
|
+
dom.studioRoot.style.width = '';
|
|
476
|
+
}
|
|
477
|
+
applyStudioWidth(state.studioWidth || DEFAULT_STUDIO_W, false);
|
|
478
|
+
dom.appEl.classList.add('studio-open');
|
|
479
|
+
dom.appEl.classList.toggle('studio-expanded', Boolean(state.studioExpanded));
|
|
480
|
+
if (tab) {
|
|
481
|
+
setStudioTab(tab);
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
syncStudioPanes();
|
|
485
|
+
syncPanelChromeState();
|
|
486
|
+
notifyVisibleTabs();
|
|
487
|
+
}
|
|
488
|
+
setTimeout(scrollActiveTabIntoView, 220);
|
|
489
|
+
}
|
|
490
|
+
export function closeStudio() {
|
|
491
|
+
state.studioExpanded = false;
|
|
492
|
+
dom.appEl.classList.remove('studio-open', 'studio-expanded', 'studio-resizing');
|
|
493
|
+
dom.studioResizer.classList.remove('dragging', 'snap-close');
|
|
494
|
+
if (dom.studioRoot) {
|
|
495
|
+
dom.studioRoot.style.flexBasis = '';
|
|
496
|
+
dom.studioRoot.style.width = '';
|
|
497
|
+
}
|
|
498
|
+
tabHandlers.onBrowserDeactivate();
|
|
499
|
+
tabHandlers.onTerminalDeactivate();
|
|
500
|
+
syncPanelChromeState();
|
|
501
|
+
}
|
|
502
|
+
export function toggleStudioNav(tab) {
|
|
503
|
+
if (dom.appEl.classList.contains('studio-open') && state.studioTab === tab && !state.studioSplit) {
|
|
504
|
+
closeStudio();
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
openStudio(tab);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
export function toggleStudioMaximize() {
|
|
511
|
+
if (!dom.appEl.classList.contains('studio-open'))
|
|
512
|
+
return;
|
|
513
|
+
state.studioExpanded = !state.studioExpanded;
|
|
514
|
+
if (state.studioExpanded && window.innerWidth > 960 && window.innerWidth < 1380) {
|
|
515
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
516
|
+
}
|
|
517
|
+
syncExpandedStudioWidth();
|
|
518
|
+
dom.appEl.classList.toggle('studio-expanded', state.studioExpanded);
|
|
519
|
+
syncPanelChromeState();
|
|
520
|
+
tabHandlers.onLayoutResized();
|
|
521
|
+
}
|
|
522
|
+
let resizing = false;
|
|
523
|
+
let snapClosePending = false;
|
|
524
|
+
let resizePointerId = null;
|
|
525
|
+
let resizeStartWidth = DEFAULT_STUDIO_W;
|
|
526
|
+
export function isStudioResizing() {
|
|
527
|
+
return resizing;
|
|
528
|
+
}
|
|
529
|
+
export function endStudioResize(cancelled) {
|
|
530
|
+
if (!resizing)
|
|
531
|
+
return;
|
|
532
|
+
resizing = false;
|
|
533
|
+
const shouldSnapClose = !cancelled && snapClosePending;
|
|
534
|
+
snapClosePending = false;
|
|
535
|
+
dom.appEl.classList.remove('studio-resizing');
|
|
536
|
+
dom.studioResizer.classList.remove('dragging', 'snap-close');
|
|
537
|
+
if (resizePointerId !== null) {
|
|
538
|
+
try {
|
|
539
|
+
dom.studioResizer.releasePointerCapture(resizePointerId);
|
|
540
|
+
}
|
|
541
|
+
catch { /* ignore */ }
|
|
542
|
+
resizePointerId = null;
|
|
543
|
+
}
|
|
544
|
+
if (shouldSnapClose) {
|
|
545
|
+
applyStudioWidth(resizeStartWidth, false);
|
|
546
|
+
closeStudio();
|
|
547
|
+
}
|
|
548
|
+
else if (cancelled) {
|
|
549
|
+
applyStudioWidth(resizeStartWidth, false);
|
|
550
|
+
tabHandlers.onLayoutResized();
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
applyStudioWidth(state.studioWidth, true);
|
|
554
|
+
tabHandlers.onLayoutResized();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
export function bindStudioResizer() {
|
|
558
|
+
dom.studioResizer.addEventListener('pointerdown', (e) => {
|
|
559
|
+
if (!dom.appEl.classList.contains('studio-open') || state.studioExpanded)
|
|
560
|
+
return;
|
|
561
|
+
e.preventDefault();
|
|
562
|
+
resizing = true;
|
|
563
|
+
snapClosePending = false;
|
|
564
|
+
resizeStartWidth = state.studioWidth || DEFAULT_STUDIO_W;
|
|
565
|
+
resizePointerId = e.pointerId;
|
|
566
|
+
dom.appEl.classList.add('studio-resizing');
|
|
567
|
+
dom.studioResizer.classList.add('dragging');
|
|
568
|
+
try {
|
|
569
|
+
dom.studioResizer.setPointerCapture(e.pointerId);
|
|
570
|
+
}
|
|
571
|
+
catch { /* ignore */ }
|
|
572
|
+
});
|
|
573
|
+
dom.studioResizer.addEventListener('pointermove', (e) => {
|
|
574
|
+
if (!resizing)
|
|
575
|
+
return;
|
|
576
|
+
const rawW = window.innerWidth - e.clientX;
|
|
577
|
+
if (rawW < 210) {
|
|
578
|
+
snapClosePending = true;
|
|
579
|
+
dom.studioResizer.classList.add('snap-close');
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
snapClosePending = false;
|
|
583
|
+
dom.studioResizer.classList.remove('snap-close');
|
|
584
|
+
applyStudioWidth(rawW, false);
|
|
585
|
+
});
|
|
586
|
+
dom.studioResizer.addEventListener('pointerup', () => endStudioResize(false));
|
|
587
|
+
dom.studioResizer.addEventListener('pointercancel', () => endStudioResize(true));
|
|
588
|
+
dom.studioResizer.addEventListener('dblclick', () => {
|
|
589
|
+
if (!dom.appEl.classList.contains('studio-open'))
|
|
590
|
+
return;
|
|
591
|
+
state.studioExpanded = false;
|
|
592
|
+
dom.appEl.classList.remove('studio-expanded');
|
|
593
|
+
applyStudioWidth(DEFAULT_STUDIO_W, true);
|
|
594
|
+
syncPanelChromeState();
|
|
595
|
+
tabHandlers.onLayoutResized();
|
|
596
|
+
});
|
|
597
|
+
window.addEventListener('resize', () => {
|
|
598
|
+
closeAllPopovers();
|
|
599
|
+
if (dom.appEl.classList.contains('studio-open') && window.innerWidth > 960) {
|
|
600
|
+
applyStudioWidth(state.studioWidth, false);
|
|
601
|
+
tabHandlers.onLayoutResized();
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
export function bindStudioSplitDivider() {
|
|
606
|
+
const divider = dom.studioSplitDivider;
|
|
607
|
+
const grid = dom.studioPanesGrid;
|
|
608
|
+
if (!divider || !grid)
|
|
609
|
+
return;
|
|
610
|
+
let splitDragging = false;
|
|
611
|
+
let splitPointerId = null;
|
|
612
|
+
const stopSplitDrag = (persist) => {
|
|
613
|
+
if (!splitDragging)
|
|
614
|
+
return;
|
|
615
|
+
splitDragging = false;
|
|
616
|
+
dom.appEl.classList.remove('studio-resizing');
|
|
617
|
+
divider.classList.remove('dragging');
|
|
618
|
+
if (splitPointerId !== null) {
|
|
619
|
+
try {
|
|
620
|
+
divider.releasePointerCapture(splitPointerId);
|
|
621
|
+
}
|
|
622
|
+
catch { /* ignore */ }
|
|
623
|
+
splitPointerId = null;
|
|
624
|
+
}
|
|
625
|
+
if (persist)
|
|
626
|
+
persistCurrentLayout();
|
|
627
|
+
tabHandlers.onLayoutResized();
|
|
628
|
+
};
|
|
629
|
+
divider.addEventListener('pointerdown', (e) => {
|
|
630
|
+
if (!state.studioSplit)
|
|
631
|
+
return;
|
|
632
|
+
e.preventDefault();
|
|
633
|
+
splitDragging = true;
|
|
634
|
+
splitPointerId = e.pointerId;
|
|
635
|
+
dom.appEl.classList.add('studio-resizing');
|
|
636
|
+
divider.classList.add('dragging');
|
|
637
|
+
try {
|
|
638
|
+
divider.setPointerCapture(e.pointerId);
|
|
639
|
+
}
|
|
640
|
+
catch { /* ignore */ }
|
|
641
|
+
});
|
|
642
|
+
divider.addEventListener('pointermove', (e) => {
|
|
643
|
+
if (!splitDragging)
|
|
644
|
+
return;
|
|
645
|
+
const rect = grid.getBoundingClientRect();
|
|
646
|
+
if (rect.width <= 0)
|
|
647
|
+
return;
|
|
648
|
+
const rawRatio = (e.clientX - rect.left) / rect.width;
|
|
649
|
+
state.studioSplitRatio = clampSplitRatio(rawRatio);
|
|
650
|
+
applySplitRatioVar();
|
|
651
|
+
});
|
|
652
|
+
divider.addEventListener('pointerup', () => stopSplitDrag(true));
|
|
653
|
+
divider.addEventListener('pointercancel', () => stopSplitDrag(false));
|
|
654
|
+
divider.addEventListener('dblclick', () => {
|
|
655
|
+
state.studioSplitRatio = 0.5;
|
|
656
|
+
applySplitRatioVar();
|
|
657
|
+
persistCurrentLayout();
|
|
658
|
+
tabHandlers.onLayoutResized();
|
|
659
|
+
});
|
|
660
|
+
}
|