@firstpick/pi-package-webui 0.5.6 → 0.5.8
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/README.md +3 -1
- package/bin/pi-webui.mjs +526 -28
- package/lib/git-worktrees.mjs +512 -0
- package/package.json +3 -3
- package/public/app.js +703 -118
- package/public/index.html +13 -7
- package/public/styles.css +365 -24
- package/tests/http-endpoints-harness.test.mjs +192 -1
- package/tests/mobile-static.test.mjs +52 -20
- package/tests/native-parity-harness.test.mjs +1 -1
- package/tests/native-parity.test.mjs +2 -2
- package/tests/streaming-ui-coupling.test.mjs +15 -4
- package/webui-rpc-helper.mjs +99 -1
- /package/{dev/docs → lib}/WEBUI_TUI_NATIVE_PARITY.json +0 -0
package/public/app.js
CHANGED
|
@@ -10,6 +10,7 @@ const elements = {
|
|
|
10
10
|
newTabMenuPanel: $("#newTabMenuPanel"),
|
|
11
11
|
newTabCurrentDirectoryButton: $("#newTabCurrentDirectoryButton"),
|
|
12
12
|
newTabChooseDirectoryButton: $("#newTabChooseDirectoryButton"),
|
|
13
|
+
newTabWorktreeButton: $("#newTabWorktreeButton"),
|
|
13
14
|
closeAllTabsButton: $("#closeAllTabsButton"),
|
|
14
15
|
commandPaletteButton: $("#commandPaletteButton"),
|
|
15
16
|
workspaceDashboardToggleButton: $("#workspaceDashboardToggleButton"),
|
|
@@ -415,7 +416,7 @@ let footerModelPickerOpen = false;
|
|
|
415
416
|
let footerThinkingPickerOpen = false;
|
|
416
417
|
let footerAutoCompactionToggleInFlight = false;
|
|
417
418
|
let footerBranchPickerOpen = false;
|
|
418
|
-
let footerBranchPickerState = { loading: false, error: "", branches: [], current: "", root: "", switching: "", tabId: null };
|
|
419
|
+
let footerBranchPickerState = { loading: false, error: "", branches: [], current: "", root: "", repoRoot: "", currentWorktreePath: "", defaultWorktreesRoot: "", worktrees: [], occupiedBranches: [], switching: "", tabId: null };
|
|
419
420
|
let footerBranchCreateDraft = { type: "", name: "" };
|
|
420
421
|
let footerBranchPickerRequestSerial = 0;
|
|
421
422
|
let footerScopedModelDragKey = "";
|
|
@@ -567,6 +568,7 @@ const todoProgressSignatureByTab = new Map();
|
|
|
567
568
|
const releaseNpmOutputExpandedByTab = new Map();
|
|
568
569
|
const appRunnerDataByTab = new Map();
|
|
569
570
|
const appRunnerInputDraftByRun = new Map();
|
|
571
|
+
const appRunnerContextLineDraftByRun = new Map();
|
|
570
572
|
const liveToolRuns = new Map();
|
|
571
573
|
const liveToolCards = new Map();
|
|
572
574
|
const liveToolRenderQueue = new Map();
|
|
@@ -589,6 +591,8 @@ const optionalFeatureAvailability = {
|
|
|
589
591
|
remoteWebui: false,
|
|
590
592
|
themeBundle: false,
|
|
591
593
|
};
|
|
594
|
+
const APP_RUNNER_CONTEXT_DEFAULT_LINES = 80;
|
|
595
|
+
const APP_RUNNER_CONTEXT_MAX_LINES = 1000;
|
|
592
596
|
const OPTIONAL_FEATURES = [
|
|
593
597
|
{
|
|
594
598
|
id: "btwCommand",
|
|
@@ -899,22 +903,24 @@ const GIT_INIT_WORKFLOW_ACTIVE_INDEX = {
|
|
|
899
903
|
done: 7,
|
|
900
904
|
};
|
|
901
905
|
const GIT_WORKFLOW_CREATE_PR_TOOLTIP = [
|
|
902
|
-
"Create PR
|
|
906
|
+
"Create PR worktree:",
|
|
903
907
|
"1. Ask Pi to generate a type/feature-name branch from staged changes.",
|
|
904
908
|
"2. Read dev/COMMIT/staged-branch-name.txt.",
|
|
905
909
|
"3. Let you confirm or edit the generated branch name.",
|
|
906
|
-
"4.
|
|
907
|
-
"5.
|
|
908
|
-
"6.
|
|
910
|
+
"4. Create or open a Git worktree for that branch instead of switching this checkout.",
|
|
911
|
+
"5. Copy staged changes and commit message files into the worktree, then switch to its tab.",
|
|
912
|
+
"6. Commit short, long, or typed input in the worktree tab.",
|
|
913
|
+
"7. Push and Create PR will push upstream, run /pr, let you review, then run gh pr create.",
|
|
909
914
|
].join("\n");
|
|
910
915
|
const GIT_WORKFLOW_MANUAL_BRANCH_TOOLTIP = [
|
|
911
|
-
"Manual PR
|
|
916
|
+
"Manual PR worktree:",
|
|
912
917
|
"1. Skip agent branch-name generation.",
|
|
913
918
|
"2. Prefill a branch from the commit message if possible.",
|
|
914
919
|
"3. Let you type or edit the type/feature-name branch name.",
|
|
915
|
-
"4.
|
|
916
|
-
"5.
|
|
917
|
-
"6.
|
|
920
|
+
"4. Create or open a Git worktree for that branch instead of switching this checkout.",
|
|
921
|
+
"5. Copy staged changes and commit message files into the worktree, then switch to its tab.",
|
|
922
|
+
"6. Commit short, long, or typed input in the worktree tab.",
|
|
923
|
+
"7. Push and Create PR will push upstream, run /pr, let you review, then run gh pr create.",
|
|
918
924
|
].join("\n");
|
|
919
925
|
const GIT_BRANCH_TYPE_SUGGESTIONS = ["feat", "fix", "change", "perf", "test", "chore", "refactor", "docs", "style", "build", "ci", "revert"];
|
|
920
926
|
const GIT_FOOTER_STATUS_SETUP_TOOLTIP = [
|
|
@@ -2354,7 +2360,7 @@ function setWorkspaceDashboardCollapsed(collapsed, { persist = true } = {}) {
|
|
|
2354
2360
|
elements.workspaceDashboardToggleButton.setAttribute("aria-expanded", workspaceDashboardCollapsed ? "false" : "true");
|
|
2355
2361
|
const tooltip = workspaceDashboardCollapsed ? "Show workspace overview" : "Hide workspace overview";
|
|
2356
2362
|
const tooltipDetail = `${tooltip}:\n• Shows current tab, cwd, model, context, session, and queue.\n• Opens common workspace/session actions from one place.`;
|
|
2357
|
-
elements.workspaceDashboardToggleButton.title
|
|
2363
|
+
elements.workspaceDashboardToggleButton.removeAttribute("title");
|
|
2358
2364
|
elements.workspaceDashboardToggleButton.setAttribute("aria-label", tooltip);
|
|
2359
2365
|
elements.workspaceDashboardToggleButton.setAttribute("data-tooltip", tooltipDetail);
|
|
2360
2366
|
}
|
|
@@ -4493,6 +4499,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
4493
4499
|
if (!tab?.id) continue;
|
|
4494
4500
|
liveIds.add(tab.id);
|
|
4495
4501
|
setTabActivity(tab.id, tab.activity);
|
|
4502
|
+
if (Object.prototype.hasOwnProperty.call(tab, "appRunner")) setAppRunnerData(tab.id, { activeRun: tab.appRunner });
|
|
4496
4503
|
}
|
|
4497
4504
|
for (const tabId of tabActivities.keys()) {
|
|
4498
4505
|
if (!liveIds.has(tabId)) {
|
|
@@ -4504,6 +4511,7 @@ function syncTabMetadata(nextTabs = []) {
|
|
|
4504
4511
|
skillUsageByTab.delete(tabId);
|
|
4505
4512
|
tabMessagesCache.delete(tabId);
|
|
4506
4513
|
widgetsByTab.delete(tabId);
|
|
4514
|
+
appRunnerDataByTab.delete(tabId);
|
|
4507
4515
|
clearGitWorkflowForTab(tabId);
|
|
4508
4516
|
}
|
|
4509
4517
|
}
|
|
@@ -4554,7 +4562,7 @@ function tabIndicator(tab) {
|
|
|
4554
4562
|
}
|
|
4555
4563
|
|
|
4556
4564
|
function hasWorkingTab() {
|
|
4557
|
-
return tabs.some((tab) => ["working", "blocked"].includes(tabIndicator(tab).state));
|
|
4565
|
+
return tabs.some((tab) => ["working", "blocked"].includes(tabIndicator(tab).state) || tabAppRunnerRunningRun(tab));
|
|
4558
4566
|
}
|
|
4559
4567
|
|
|
4560
4568
|
function scheduleRefreshTabs(delay = 1500) {
|
|
@@ -4999,15 +5007,43 @@ function terminalDisplayGroupDetail(group, fallback = "group") {
|
|
|
4999
5007
|
return `${cwdLabels[0]} + ${cwdLabels.length - 1} cwd${cwdLabels.length === 2 ? "" : "s"}`;
|
|
5000
5008
|
}
|
|
5001
5009
|
|
|
5010
|
+
function tabAppRunnerRun(tab) {
|
|
5011
|
+
if (!tab?.id) return null;
|
|
5012
|
+
const cached = appRunnerDataByTab.get(tab.id);
|
|
5013
|
+
if (cached && Object.prototype.hasOwnProperty.call(cached, "activeRun")) return cached.activeRun || null;
|
|
5014
|
+
if (Object.prototype.hasOwnProperty.call(tab, "appRunner")) return tab.appRunner || null;
|
|
5015
|
+
return null;
|
|
5016
|
+
}
|
|
5017
|
+
|
|
5018
|
+
function tabAppRunnerRunningRun(tab) {
|
|
5019
|
+
const run = tabAppRunnerRun(tab);
|
|
5020
|
+
return appRunnerIsRunning(run) ? run : null;
|
|
5021
|
+
}
|
|
5022
|
+
|
|
5023
|
+
function tabGroupAppRunnerRunningRun(groupTabs = []) {
|
|
5024
|
+
return groupTabs.map(tabAppRunnerRunningRun).find(Boolean) || null;
|
|
5025
|
+
}
|
|
5026
|
+
|
|
5027
|
+
function terminalAppRunnerLabel(run) {
|
|
5028
|
+
const command = cleanStatusText(run?.displayCommand || run?.label || run?.command || "app runner");
|
|
5029
|
+
return command && command !== "app runner" ? `app runner: ${command}` : "app runner running";
|
|
5030
|
+
}
|
|
5031
|
+
|
|
5032
|
+
function terminalAppRunnerTooltip(run) {
|
|
5033
|
+
return appRunnerIsRunning(run) ? ` · ${terminalAppRunnerLabel(run)}` : "";
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5002
5036
|
function terminalTabMeta(tab, indicator) {
|
|
5003
|
-
|
|
5037
|
+
const meta = tab.running ? `${indicator.meta} · pid ${tab.pid || "…"}` : "stopped";
|
|
5038
|
+
return tabAppRunnerRunningRun(tab) ? `${meta} · app runner` : meta;
|
|
5004
5039
|
}
|
|
5005
5040
|
|
|
5006
|
-
function appendTerminalTabContent(button, { title, indicator, meta, count = null }) {
|
|
5041
|
+
function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null }) {
|
|
5007
5042
|
const titleRow = make("span", "terminal-tab-title-row");
|
|
5008
5043
|
const indicatorDot = make("span", "terminal-tab-activity-indicator");
|
|
5009
5044
|
indicatorDot.setAttribute("aria-hidden", "true");
|
|
5010
5045
|
titleRow.append(indicatorDot, make("span", "terminal-tab-title", title));
|
|
5046
|
+
if (appRunnerIsRunning(appRunnerRun)) titleRow.append(make("span", "terminal-tab-app-runner-indicator", "app"));
|
|
5011
5047
|
if (count !== null) titleRow.append(make("span", "terminal-tab-group-count", String(count)));
|
|
5012
5048
|
button.append(titleRow, make("span", "terminal-tab-meta", meta));
|
|
5013
5049
|
}
|
|
@@ -5015,7 +5051,9 @@ function appendTerminalTabContent(button, { title, indicator, meta, count = null
|
|
|
5015
5051
|
function renderTerminalTab(tab) {
|
|
5016
5052
|
const isActive = tab.id === activeTabId;
|
|
5017
5053
|
const indicator = tabIndicator(tab);
|
|
5018
|
-
const
|
|
5054
|
+
const appRunnerRun = tabAppRunnerRunningRun(tab);
|
|
5055
|
+
const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
|
|
5056
|
+
const wrapper = make("div", `terminal-tab activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}`);
|
|
5019
5057
|
wrapper.dataset.tabId = tab.id;
|
|
5020
5058
|
bindTerminalTabDragAndDrop(wrapper, { sourceTabId: tab.id, target: { type: "tab", tabId: tab.id } });
|
|
5021
5059
|
const button = make("button", "terminal-tab-button");
|
|
@@ -5023,9 +5061,10 @@ function renderTerminalTab(tab) {
|
|
|
5023
5061
|
button.draggable = false;
|
|
5024
5062
|
button.setAttribute("role", "tab");
|
|
5025
5063
|
button.setAttribute("aria-selected", isActive ? "true" : "false");
|
|
5026
|
-
button.setAttribute("aria-label", `${tab.title}: ${indicator.label}`);
|
|
5027
|
-
|
|
5028
|
-
|
|
5064
|
+
button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}`);
|
|
5065
|
+
const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)} · drag onto another tab or group to group`;
|
|
5066
|
+
applyStyledTooltip(button, tooltip, { ariaLabel: false });
|
|
5067
|
+
appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun });
|
|
5029
5068
|
button.addEventListener("click", () => switchTab(tab.id));
|
|
5030
5069
|
wrapper.append(button);
|
|
5031
5070
|
|
|
@@ -5033,8 +5072,8 @@ function renderTerminalTab(tab) {
|
|
|
5033
5072
|
const close = make("button", "terminal-tab-close", "×");
|
|
5034
5073
|
close.type = "button";
|
|
5035
5074
|
close.draggable = false;
|
|
5036
|
-
|
|
5037
|
-
close
|
|
5075
|
+
const closeTooltip = `Close ${tab.title}`;
|
|
5076
|
+
applyStyledTooltip(close, closeTooltip, { ariaLabel: closeTooltip });
|
|
5038
5077
|
close.addEventListener("click", (event) => {
|
|
5039
5078
|
event.stopPropagation();
|
|
5040
5079
|
closeTerminalTab(tab.id);
|
|
@@ -5048,7 +5087,9 @@ function renderTerminalTab(tab) {
|
|
|
5048
5087
|
function renderTerminalTabGroupItem(tab, group) {
|
|
5049
5088
|
const isActive = tab.id === activeTabId;
|
|
5050
5089
|
const indicator = tabIndicator(tab);
|
|
5051
|
-
const
|
|
5090
|
+
const appRunnerRun = tabAppRunnerRunningRun(tab);
|
|
5091
|
+
const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
|
|
5092
|
+
const item = make("div", `terminal-tab-group-item activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}`);
|
|
5052
5093
|
item.dataset.tabId = tab.id;
|
|
5053
5094
|
bindTerminalTabDragAndDrop(item, { sourceTabId: tab.id, target: group?.custom ? { type: "group", group } : { type: "tab", tabId: tab.id } });
|
|
5054
5095
|
const button = make("button", "terminal-tab-button terminal-tab-group-item-button");
|
|
@@ -5056,9 +5097,10 @@ function renderTerminalTabGroupItem(tab, group) {
|
|
|
5056
5097
|
button.draggable = false;
|
|
5057
5098
|
button.setAttribute("role", "tab");
|
|
5058
5099
|
button.setAttribute("aria-selected", isActive ? "true" : "false");
|
|
5059
|
-
button.setAttribute("aria-label", `${tab.title}: ${indicator.label}`);
|
|
5060
|
-
|
|
5061
|
-
|
|
5100
|
+
button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}`);
|
|
5101
|
+
const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)} · drag onto another tab or group to group`;
|
|
5102
|
+
applyStyledTooltip(button, tooltip, { ariaLabel: false });
|
|
5103
|
+
appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun });
|
|
5062
5104
|
button.addEventListener("click", (event) => {
|
|
5063
5105
|
event.stopPropagation();
|
|
5064
5106
|
switchTab(tab.id);
|
|
@@ -5069,8 +5111,8 @@ function renderTerminalTabGroupItem(tab, group) {
|
|
|
5069
5111
|
const close = make("button", "terminal-tab-close terminal-tab-group-item-close", "×");
|
|
5070
5112
|
close.type = "button";
|
|
5071
5113
|
close.draggable = false;
|
|
5072
|
-
|
|
5073
|
-
close
|
|
5114
|
+
const closeTooltip = `Close ${tab.title}`;
|
|
5115
|
+
applyStyledTooltip(close, closeTooltip, { ariaLabel: closeTooltip });
|
|
5074
5116
|
close.addEventListener("click", (event) => {
|
|
5075
5117
|
event.stopPropagation();
|
|
5076
5118
|
closeTerminalTab(tab.id);
|
|
@@ -5092,10 +5134,14 @@ function renderTerminalTabGroup(group, groupCount = 1) {
|
|
|
5092
5134
|
const isActive = groupTabs.some((tab) => tab.id === activeTabId);
|
|
5093
5135
|
const isStopped = groupTabs.every((tab) => !tab.running);
|
|
5094
5136
|
const indicator = tabGroupIndicator(groupTabs);
|
|
5137
|
+
const appRunnerRun = tabGroupAppRunnerRunningRun(groupTabs);
|
|
5138
|
+
const appRunnerCount = groupTabs.filter(tabAppRunnerRunningRun).length;
|
|
5139
|
+
const appRunnerSummary = appRunnerCount > 1 ? `${appRunnerCount} app runners running` : appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
|
|
5140
|
+
const groupAppRunnerMeta = appRunnerCount > 1 ? `${appRunnerCount} app runners` : appRunnerRun ? "app runner" : "";
|
|
5095
5141
|
const groupTitle = terminalDisplayGroupTitle(group, activeGroupTab?.title || "group");
|
|
5096
5142
|
const activeTitle = activeGroupTab?.title || groupTitle;
|
|
5097
5143
|
const groupDetail = terminalDisplayGroupDetail(group, groupTitle);
|
|
5098
|
-
const wrapper = make("div", `terminal-tab terminal-tab-group${group.custom ? " terminal-tab-custom-group" : ""} activity-${indicator.state}${isActive ? " active" : ""}${isStopped ? " stopped" : ""}`);
|
|
5144
|
+
const wrapper = make("div", `terminal-tab terminal-tab-group${group.custom ? " terminal-tab-custom-group" : ""} activity-${indicator.state}${isActive ? " active" : ""}${isStopped ? " stopped" : ""}${appRunnerRun ? " app-runner-running" : ""}`);
|
|
5099
5145
|
wrapper.dataset.groupKey = group.key;
|
|
5100
5146
|
if (group.customGroupId) wrapper.dataset.customGroupId = group.customGroupId;
|
|
5101
5147
|
bindTerminalTabDragAndDrop(wrapper, { sourceTabId: activeGroupTab?.id || "", target: { type: "group", group } });
|
|
@@ -5114,9 +5160,10 @@ function renderTerminalTabGroup(group, groupCount = 1) {
|
|
|
5114
5160
|
button.setAttribute("aria-selected", isActive ? "true" : "false");
|
|
5115
5161
|
button.setAttribute("aria-haspopup", "true");
|
|
5116
5162
|
button.setAttribute("aria-expanded", group.key === openTerminalTabGroupKey ? "true" : "false");
|
|
5117
|
-
button.setAttribute("aria-label", `${groupTitle} ${group.custom ? "custom" : "cwd"} group: ${groupTabs.length} tabs, ${indicator.label}. Active ${activeTitle}`);
|
|
5118
|
-
|
|
5119
|
-
|
|
5163
|
+
button.setAttribute("aria-label", `${groupTitle} ${group.custom ? "custom" : "cwd"} group: ${groupTabs.length} tabs, ${indicator.label}${appRunnerSummary ? `, ${appRunnerSummary}` : ""}. Active ${activeTitle}`);
|
|
5164
|
+
const tooltip = `${activeTitle} · ${groupTitle} · ${groupDetail} · ${groupTabs.length} tabs · ${indicator.label}${appRunnerSummary ? ` · ${appRunnerSummary}` : ""} · drop tabs here to add to group`;
|
|
5165
|
+
applyStyledTooltip(button, tooltip, { ariaLabel: false });
|
|
5166
|
+
appendTerminalTabContent(button, { title: activeTitle, indicator, meta: `${groupTitle} · ${indicator.meta}${groupAppRunnerMeta ? ` · ${groupAppRunnerMeta}` : ""}`, appRunnerRun, count: groupTabs.length });
|
|
5120
5167
|
button.addEventListener("click", () => switchTab(activeGroupTab.id));
|
|
5121
5168
|
wrapper.append(button);
|
|
5122
5169
|
|
|
@@ -5124,8 +5171,8 @@ function renderTerminalTabGroup(group, groupCount = 1) {
|
|
|
5124
5171
|
const close = make("button", "terminal-tab-close terminal-tab-group-close", "×");
|
|
5125
5172
|
close.type = "button";
|
|
5126
5173
|
close.draggable = false;
|
|
5127
|
-
|
|
5128
|
-
close
|
|
5174
|
+
const closeTooltip = `Close ${groupTitle} group`;
|
|
5175
|
+
applyStyledTooltip(close, closeTooltip, { ariaLabel: closeTooltip });
|
|
5129
5176
|
close.addEventListener("click", (event) => {
|
|
5130
5177
|
event.stopPropagation();
|
|
5131
5178
|
closeTerminalTabGroup(group);
|
|
@@ -5141,8 +5188,8 @@ function renderTerminalTabGroup(group, groupCount = 1) {
|
|
|
5141
5188
|
const add = make("button", "terminal-tab-group-add", "+ Tab");
|
|
5142
5189
|
add.type = "button";
|
|
5143
5190
|
add.draggable = false;
|
|
5144
|
-
|
|
5145
|
-
add
|
|
5191
|
+
const addTooltip = `Add tab in ${groupTitle}`;
|
|
5192
|
+
applyStyledTooltip(add, addTooltip, { ariaLabel: addTooltip });
|
|
5146
5193
|
add.addEventListener("click", (event) => {
|
|
5147
5194
|
event.stopPropagation();
|
|
5148
5195
|
createTerminalTab(activeGroupTab?.cwd || group.cwd || currentDirectoryForNewTab(), { triggerButton: add, customGroupId: group.customGroupId || null });
|
|
@@ -5181,6 +5228,11 @@ function setNewTabMenuOpen(open) {
|
|
|
5181
5228
|
if (!newTabMenuOpen) scheduleDeferredUiFlushAfterDropdownClose();
|
|
5182
5229
|
}
|
|
5183
5230
|
|
|
5231
|
+
function initializeTerminalHeaderTooltips() {
|
|
5232
|
+
applyStyledTooltip(elements.newTabButton, "Start a separate isolated Pi terminal", { ariaLabel: "Start a separate isolated Pi terminal" });
|
|
5233
|
+
applyStyledTooltip(elements.closeAllTabsButton, "Close all terminal tabs", { ariaLabel: "Close all terminal tabs" });
|
|
5234
|
+
}
|
|
5235
|
+
|
|
5184
5236
|
function openNewTabMenu() {
|
|
5185
5237
|
setPublishMenuOpen(false);
|
|
5186
5238
|
setNativeCommandMenuOpen(false);
|
|
@@ -5189,14 +5241,18 @@ function openNewTabMenu() {
|
|
|
5189
5241
|
setNewTabMenuOpen(true);
|
|
5190
5242
|
}
|
|
5191
5243
|
|
|
5244
|
+
function newTabMenuItems() {
|
|
5245
|
+
return [elements.newTabCurrentDirectoryButton, elements.newTabChooseDirectoryButton, elements.newTabWorktreeButton].filter(Boolean);
|
|
5246
|
+
}
|
|
5247
|
+
|
|
5192
5248
|
function focusNewTabMenuItem(direction = "first") {
|
|
5193
|
-
const items =
|
|
5249
|
+
const items = newTabMenuItems();
|
|
5194
5250
|
const item = direction === "last" ? items.at(-1) : items[0];
|
|
5195
5251
|
item?.focus({ preventScroll: true });
|
|
5196
5252
|
}
|
|
5197
5253
|
|
|
5198
5254
|
function moveNewTabMenuFocus(delta) {
|
|
5199
|
-
const items =
|
|
5255
|
+
const items = newTabMenuItems();
|
|
5200
5256
|
if (!items.length) return;
|
|
5201
5257
|
const currentIndex = Math.max(0, items.indexOf(document.activeElement));
|
|
5202
5258
|
const nextIndex = (currentIndex + delta + items.length) % items.length;
|
|
@@ -5218,7 +5274,9 @@ function renderTabs() {
|
|
|
5218
5274
|
const active = activeTab();
|
|
5219
5275
|
const activeIndicator = active ? tabIndicator(active) : null;
|
|
5220
5276
|
elements.terminalTabsToggleButton.textContent = active ? `${activeIndicator.glyph} ${active.title}${tabs.length > 1 ? ` · ${tabs.length}` : ""}` : "Tabs";
|
|
5221
|
-
|
|
5277
|
+
const toggleTooltip = active ? `Show terminal tabs · active: ${active.title} · ${activeIndicator.label}` : "Show terminal tabs";
|
|
5278
|
+
applyStyledTooltip(elements.terminalTabsToggleButton, toggleTooltip, { ariaLabel: toggleTooltip });
|
|
5279
|
+
if (footerTooltipTarget && elements.tabBar.contains(footerTooltipTarget)) hideFooterTooltip();
|
|
5222
5280
|
elements.tabBar.replaceChildren();
|
|
5223
5281
|
elements.tabBar.dataset.tabCount = String(tabs.length);
|
|
5224
5282
|
elements.tabBar.classList.toggle("terminal-tabs-dense", tabs.length >= 10);
|
|
@@ -6155,6 +6213,24 @@ function normalizeDisplayPath(value) {
|
|
|
6155
6213
|
return String(value || "").replace(/\\/g, "/");
|
|
6156
6214
|
}
|
|
6157
6215
|
|
|
6216
|
+
function normalizeGitWorkspaceInfo(workspace) {
|
|
6217
|
+
if (!workspace || typeof workspace !== "object") return null;
|
|
6218
|
+
return {
|
|
6219
|
+
repoRoot: normalizeDisplayPath(workspace.repoRoot || ""),
|
|
6220
|
+
commonGitDir: normalizeDisplayPath(workspace.commonGitDir || ""),
|
|
6221
|
+
worktreePath: normalizeDisplayPath(workspace.worktreePath || workspace.path || ""),
|
|
6222
|
+
branch: cleanStatusText(workspace.branch || ""),
|
|
6223
|
+
worktreeCount: Number.isFinite(Number(workspace.worktreeCount)) ? Number(workspace.worktreeCount) : null,
|
|
6224
|
+
isMainWorktree: workspace.isMainWorktree === true,
|
|
6225
|
+
};
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6228
|
+
function gitWorkspaceBadgeLabel(workspace = normalizeGitWorkspaceInfo(activeTab()?.gitWorkspace)) {
|
|
6229
|
+
if (!workspace?.worktreePath) return "";
|
|
6230
|
+
const branch = workspace.branch || "detached";
|
|
6231
|
+
return workspace.isMainWorktree ? `main worktree · ${branch}` : `worktree · ${branch}`;
|
|
6232
|
+
}
|
|
6233
|
+
|
|
6158
6234
|
function textFromContent(content) {
|
|
6159
6235
|
if (typeof content === "string") return content;
|
|
6160
6236
|
if (!Array.isArray(content)) return JSON.stringify(content ?? "");
|
|
@@ -6174,9 +6250,13 @@ function cleanTooltipText(value) {
|
|
|
6174
6250
|
return stripAnsi(value).replace(/\r\n?/g, "\n").replace(/[^\S\n]+/g, " ").replace(/\n{3,}/g, "\n\n").trim();
|
|
6175
6251
|
}
|
|
6176
6252
|
|
|
6253
|
+
const TOOLTIP_HOVER_DELAY_MS = 500;
|
|
6254
|
+
|
|
6177
6255
|
let footerTooltipNode = null;
|
|
6178
6256
|
let footerTooltipTarget = null;
|
|
6179
6257
|
let footerTooltipEventsBound = false;
|
|
6258
|
+
let footerTooltipHoverTimer = null;
|
|
6259
|
+
let footerTooltipPendingTarget = null;
|
|
6180
6260
|
|
|
6181
6261
|
function ensureFooterTooltipNode() {
|
|
6182
6262
|
if (!footerTooltipNode) {
|
|
@@ -6217,7 +6297,15 @@ function positionFooterTooltip(target) {
|
|
|
6217
6297
|
footerTooltipNode.style.top = `${Math.round(top)}px`;
|
|
6218
6298
|
}
|
|
6219
6299
|
|
|
6300
|
+
function clearFooterTooltipHoverTimer(target) {
|
|
6301
|
+
if (target && footerTooltipPendingTarget && target !== footerTooltipPendingTarget) return;
|
|
6302
|
+
if (footerTooltipHoverTimer) clearTimeout(footerTooltipHoverTimer);
|
|
6303
|
+
footerTooltipHoverTimer = null;
|
|
6304
|
+
footerTooltipPendingTarget = null;
|
|
6305
|
+
}
|
|
6306
|
+
|
|
6220
6307
|
function showFooterTooltip(target) {
|
|
6308
|
+
clearFooterTooltipHoverTimer();
|
|
6221
6309
|
const text = target?.getAttribute("data-tooltip");
|
|
6222
6310
|
if (!text) return;
|
|
6223
6311
|
footerTooltipTarget = target;
|
|
@@ -6228,7 +6316,21 @@ function showFooterTooltip(target) {
|
|
|
6228
6316
|
positionFooterTooltip(target);
|
|
6229
6317
|
}
|
|
6230
6318
|
|
|
6319
|
+
function scheduleFooterTooltip(target) {
|
|
6320
|
+
const text = target?.getAttribute("data-tooltip");
|
|
6321
|
+
if (!text) return;
|
|
6322
|
+
clearFooterTooltipHoverTimer();
|
|
6323
|
+
footerTooltipPendingTarget = target;
|
|
6324
|
+
footerTooltipHoverTimer = setTimeout(() => {
|
|
6325
|
+
const pendingTarget = footerTooltipPendingTarget;
|
|
6326
|
+
clearFooterTooltipHoverTimer();
|
|
6327
|
+
if (!pendingTarget?.isConnected || !pendingTarget.matches?.(":hover")) return;
|
|
6328
|
+
showFooterTooltip(pendingTarget);
|
|
6329
|
+
}, TOOLTIP_HOVER_DELAY_MS);
|
|
6330
|
+
}
|
|
6331
|
+
|
|
6231
6332
|
function hideFooterTooltip(target) {
|
|
6333
|
+
clearFooterTooltipHoverTimer(target);
|
|
6232
6334
|
if (target && target !== footerTooltipTarget) return;
|
|
6233
6335
|
footerTooltipTarget = null;
|
|
6234
6336
|
if (!footerTooltipNode) return;
|
|
@@ -6236,19 +6338,34 @@ function hideFooterTooltip(target) {
|
|
|
6236
6338
|
footerTooltipNode.classList.remove("visible");
|
|
6237
6339
|
}
|
|
6238
6340
|
|
|
6239
|
-
function
|
|
6341
|
+
function bindStyledTooltipEvents(node) {
|
|
6342
|
+
if (!node || node._styledTooltipBound) return;
|
|
6343
|
+
node._styledTooltipBound = true;
|
|
6344
|
+
node.addEventListener("mouseenter", () => scheduleFooterTooltip(node));
|
|
6345
|
+
node.addEventListener("mouseleave", () => hideFooterTooltip(node));
|
|
6346
|
+
node.addEventListener("focus", () => showFooterTooltip(node));
|
|
6347
|
+
node.addEventListener("blur", () => hideFooterTooltip(node));
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
function applyStyledTooltip(node, tooltip, options = {}) {
|
|
6351
|
+
if (!node) return node;
|
|
6240
6352
|
const text = cleanTooltipText(tooltip);
|
|
6241
6353
|
if (!text) return node;
|
|
6242
6354
|
node.setAttribute("data-tooltip", text);
|
|
6243
|
-
node.
|
|
6355
|
+
node.removeAttribute("title");
|
|
6356
|
+
if (options.ariaLabel !== false) {
|
|
6357
|
+
const ariaLabel = typeof options.ariaLabel === "string" ? options.ariaLabel : text.replace(/\s+/g, " ");
|
|
6358
|
+
node.setAttribute("aria-label", ariaLabel);
|
|
6359
|
+
}
|
|
6244
6360
|
if (options.align) node.setAttribute("data-tooltip-align", options.align);
|
|
6245
|
-
|
|
6246
|
-
node.addEventListener("mouseleave", () => hideFooterTooltip(node));
|
|
6247
|
-
node.addEventListener("focus", () => showFooterTooltip(node));
|
|
6248
|
-
node.addEventListener("blur", () => hideFooterTooltip(node));
|
|
6361
|
+
bindStyledTooltipEvents(node);
|
|
6249
6362
|
return node;
|
|
6250
6363
|
}
|
|
6251
6364
|
|
|
6365
|
+
function applyFooterTooltip(node, tooltip, options = {}) {
|
|
6366
|
+
return applyStyledTooltip(node, tooltip, options);
|
|
6367
|
+
}
|
|
6368
|
+
|
|
6252
6369
|
function footerMetric(icon, label, value, tone = "", options = {}) {
|
|
6253
6370
|
const isAction = typeof options.onClick === "function";
|
|
6254
6371
|
const node = make(isAction ? "button" : "span", ["footer-metric", tone, isAction ? "footer-metric-action" : ""].filter(Boolean).join(" "));
|
|
@@ -6327,6 +6444,7 @@ const FOOTER_META_CLASS_BY_KEY = new Map([
|
|
|
6327
6444
|
["sync", "footer-sync"],
|
|
6328
6445
|
["changes", "footer-changes"],
|
|
6329
6446
|
["git-extra", "footer-git-extra"],
|
|
6447
|
+
["worktree", "footer-worktree"],
|
|
6330
6448
|
["context", "footer-context"],
|
|
6331
6449
|
["model", "footer-model"],
|
|
6332
6450
|
["thinking", "footer-thinking"],
|
|
@@ -6345,6 +6463,7 @@ const GIT_FOOTER_TOOLTIP_COPY = {
|
|
|
6345
6463
|
sync: "Remote tracking divergence. ↑ means local commits ahead; ↓ means remote commits to pull.",
|
|
6346
6464
|
changes: "Working tree and fetched remote summary. 🟢 staged, ✏️ modified unstaged, ➕ untracked, ⚠️ conflicted; ⬇️ means fetched remote commits to pull; 🔄/✓/⚠️ fetch shows the tab git fetch state; ✅ means no changes.",
|
|
6347
6465
|
"git-extra": "Extra Git signals. 📦 stash, 🧩 dirty submodules, 🌳 worktrees, 🏷️ tag at HEAD, 🕒 last commit age, 🔓 signing mismatch.",
|
|
6466
|
+
worktree: "Git worktree checkout for this tab. Use branch worktrees to work on branches in parallel without switching this checkout.",
|
|
6348
6467
|
model: "Scoped model for this tab.",
|
|
6349
6468
|
thinking: "Reasoning/thinking effort for this tab.",
|
|
6350
6469
|
};
|
|
@@ -6517,7 +6636,10 @@ function footerPayloadWithLiveModel(payload) {
|
|
|
6517
6636
|
if (!payload) return payload;
|
|
6518
6637
|
const model = currentState?.model ? shortModelLabel(currentState.model) : "";
|
|
6519
6638
|
const effort = footerThinkingDisplay();
|
|
6639
|
+
const workspace = normalizeGitWorkspaceInfo(activeTab()?.gitWorkspace);
|
|
6640
|
+
const worktreeLabel = gitWorkspaceBadgeLabel(workspace);
|
|
6520
6641
|
const hasThinkingChip = [...payload.main, ...payload.meta].some((chip) => chip?.key === "thinking");
|
|
6642
|
+
const hasWorktreeChip = [...payload.main, ...payload.meta].some((chip) => chip?.key === "worktree");
|
|
6521
6643
|
const contextChip = (chip) => {
|
|
6522
6644
|
const usageUnknown = contextUsageUnknownAfterCompaction();
|
|
6523
6645
|
const value = usageUnknown ? footerContextDisplayWithAuto(unknownFooterContextText(chip?.contextUsage)) : footerContextDisplayWithAuto(chip?.value);
|
|
@@ -6525,6 +6647,7 @@ function footerPayloadWithLiveModel(payload) {
|
|
|
6525
6647
|
return { ...chip, value, title: `context: ${value}`, ...(contextUsage ? { contextUsage } : {}) };
|
|
6526
6648
|
};
|
|
6527
6649
|
const effortChip = (chip) => ({ ...chip, key: "thinking", label: "effort", value: effort, title: `effort: ${effort}`, tone: "mauve" });
|
|
6650
|
+
const worktreeChip = () => ({ key: "worktree", label: "worktree", value: worktreeLabel, icon: "🌳", tone: workspace?.isMainWorktree ? "teal" : "green", title: workspace?.worktreePath || "Git worktree" });
|
|
6528
6651
|
const splitChip = (chip) => {
|
|
6529
6652
|
if (chip?.key === "context") return [contextChip(chip)];
|
|
6530
6653
|
if (chip?.key === "thinking") return [effortChip(chip)];
|
|
@@ -6532,9 +6655,11 @@ function footerPayloadWithLiveModel(payload) {
|
|
|
6532
6655
|
const modelChip = { ...chip, value: model, title: `model: ${model}` };
|
|
6533
6656
|
return hasThinkingChip ? [modelChip] : [modelChip, effortChip(chip)];
|
|
6534
6657
|
};
|
|
6658
|
+
const meta = payload.meta.flatMap(splitChip);
|
|
6659
|
+
if (worktreeLabel && !hasWorktreeChip) meta.splice(Math.min(meta.length, 2), 0, worktreeChip());
|
|
6535
6660
|
return {
|
|
6536
6661
|
main: payload.main.flatMap(splitChip),
|
|
6537
|
-
meta
|
|
6662
|
+
meta,
|
|
6538
6663
|
};
|
|
6539
6664
|
}
|
|
6540
6665
|
|
|
@@ -6582,11 +6707,14 @@ function footerTuiItem(value, className = "", options = {}) {
|
|
|
6582
6707
|
|
|
6583
6708
|
function renderTuiFooterLine({ cwd, cwdTitle, message = "", stats = [], model = "" } = {}) {
|
|
6584
6709
|
const tab = activeTab();
|
|
6710
|
+
const workspace = normalizeGitWorkspaceInfo(tab?.gitWorkspace);
|
|
6711
|
+
const worktreeLabel = gitWorkspaceBadgeLabel(workspace);
|
|
6585
6712
|
const line = make("div", "footer-line footer-line-tui");
|
|
6586
6713
|
line.append(footerTuiItem(cwd || "loading…", "footer-tui-cwd", tab ? {
|
|
6587
6714
|
onClick: changeActiveTabCwd,
|
|
6588
6715
|
title: cwdTitle || `Change cwd for ${tab.title}: ${cwd}`,
|
|
6589
6716
|
} : { title: cwdTitle }));
|
|
6717
|
+
if (worktreeLabel) line.append(footerTuiItem(worktreeLabel, "footer-tui-worktree", { title: workspace?.worktreePath || worktreeLabel }));
|
|
6590
6718
|
if (message) line.append(footerTuiItem(message, "footer-tui-status"));
|
|
6591
6719
|
for (const stat of stats.filter(Boolean)) line.append(footerTuiItem(stat, "footer-tui-stat"));
|
|
6592
6720
|
if (model) {
|
|
@@ -6684,7 +6812,10 @@ function renderGitFooterPayloadMeta(chip, tab) {
|
|
|
6684
6812
|
action = "No Git repository detected. Click to initialize a repo, create README.md, add origin, and push main.";
|
|
6685
6813
|
} else if (chip.key === "git") {
|
|
6686
6814
|
options.onClick = () => setFooterBranchPickerOpen(!footerBranchPickerOpen);
|
|
6687
|
-
action = "Click to switch
|
|
6815
|
+
action = "Click to open, create, or switch branches. Worktree actions are the safe default for parallel work.";
|
|
6816
|
+
} else if (chip.key === "worktree") {
|
|
6817
|
+
options.onClick = () => setFooterBranchPickerOpen(!footerBranchPickerOpen);
|
|
6818
|
+
action = "Click to manage branch worktrees for this repository.";
|
|
6688
6819
|
} else if (chip.key === "changes") {
|
|
6689
6820
|
options.onClick = openGitChangesDialog;
|
|
6690
6821
|
action = "Click to view the current git diff.";
|
|
@@ -6700,7 +6831,7 @@ function renderGitFooterPayloadMeta(chip, tab) {
|
|
|
6700
6831
|
options.tooltipAlign = gitFooterTooltipAlign(chip);
|
|
6701
6832
|
const node = footerMeta(chip.label, chip.value, footerMetaClassForPayload(chip), options);
|
|
6702
6833
|
applyFooterChangedFilesDropdown(node, chip);
|
|
6703
|
-
if (chip.key
|
|
6834
|
+
if (["git", "worktree"].includes(chip.key) && options.onClick && cleanFooterPayloadText(chip.value, "").toLowerCase() !== "no repo") {
|
|
6704
6835
|
node.setAttribute("aria-haspopup", "listbox");
|
|
6705
6836
|
node.setAttribute("aria-expanded", footerBranchPickerOpen ? "true" : "false");
|
|
6706
6837
|
}
|
|
@@ -6724,7 +6855,10 @@ function gitFooterChipShapeKey(chip) {
|
|
|
6724
6855
|
}
|
|
6725
6856
|
|
|
6726
6857
|
function gitFooterPickerStateKey() {
|
|
6727
|
-
|
|
6858
|
+
const tabContext = activeTabContext();
|
|
6859
|
+
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
6860
|
+
const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
|
|
6861
|
+
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}`;
|
|
6728
6862
|
}
|
|
6729
6863
|
|
|
6730
6864
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
@@ -6740,6 +6874,40 @@ function invalidateGitFooterRenderCache() {
|
|
|
6740
6874
|
gitFooterRenderCache = null;
|
|
6741
6875
|
}
|
|
6742
6876
|
|
|
6877
|
+
function triggerGitFooterRefreshFromButton() {
|
|
6878
|
+
const tabContext = activeTabContext();
|
|
6879
|
+
if (!tabContext.tabId || gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId)) return;
|
|
6880
|
+
if (!resolveAvailableCommandName("git-footer-refresh", { rpcOnly: true })) {
|
|
6881
|
+
addEvent(optionalFeatureUnavailableMessage("gitFooterStatus"), "warn");
|
|
6882
|
+
return;
|
|
6883
|
+
}
|
|
6884
|
+
requestGitFooterWebuiPayload(tabContext, { force: true, silent: false, allowDuringRun: true });
|
|
6885
|
+
}
|
|
6886
|
+
|
|
6887
|
+
function renderGitFooterRefreshButton() {
|
|
6888
|
+
const tabContext = activeTabContext();
|
|
6889
|
+
const inFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
6890
|
+
const commandAvailable = !!resolveAvailableCommandName("git-footer-refresh", { rpcOnly: true });
|
|
6891
|
+
const button = make("button", "git-footer-refresh-button");
|
|
6892
|
+
button.type = "button";
|
|
6893
|
+
button.title = inFlight
|
|
6894
|
+
? "Refreshing git footer status…"
|
|
6895
|
+
: commandAvailable
|
|
6896
|
+
? "Refresh git footer status (/git-footer-refresh)"
|
|
6897
|
+
: optionalFeatureUnavailableMessage("gitFooterStatus");
|
|
6898
|
+
button.setAttribute("aria-label", inFlight ? "Refreshing git footer status" : "Refresh git footer status");
|
|
6899
|
+
if (!commandAvailable) button.setAttribute("aria-disabled", "true");
|
|
6900
|
+
if (inFlight) button.setAttribute("aria-busy", "true");
|
|
6901
|
+
button.disabled = inFlight || !tabContext.tabId;
|
|
6902
|
+
button.append(make("span", "git-footer-refresh-icon", "↻"));
|
|
6903
|
+
button.addEventListener("click", (event) => {
|
|
6904
|
+
event.preventDefault();
|
|
6905
|
+
event.stopPropagation();
|
|
6906
|
+
triggerGitFooterRefreshFromButton();
|
|
6907
|
+
});
|
|
6908
|
+
return button;
|
|
6909
|
+
}
|
|
6910
|
+
|
|
6743
6911
|
function renderGitFooterPayload(payload) {
|
|
6744
6912
|
const tab = activeTab();
|
|
6745
6913
|
const pickerKey = gitFooterPickerStateKey();
|
|
@@ -6786,7 +6954,7 @@ function renderGitFooterPayload(payload) {
|
|
|
6786
6954
|
const row2 = make("div", "footer-line footer-line-meta");
|
|
6787
6955
|
row2.append(...metaNodes, footerToggle);
|
|
6788
6956
|
|
|
6789
|
-
elements.statusBar.append(row1, row2);
|
|
6957
|
+
elements.statusBar.append(row1, row2, renderGitFooterRefreshButton());
|
|
6790
6958
|
if (footerModelPickerOpen) elements.statusBar.append(renderFooterModelPicker());
|
|
6791
6959
|
if (footerThinkingPickerOpen) elements.statusBar.append(renderFooterThinkingPicker());
|
|
6792
6960
|
if (footerBranchPickerOpen) elements.statusBar.append(renderFooterBranchPicker());
|
|
@@ -7576,6 +7744,8 @@ function renderWorkspaceDashboard() {
|
|
|
7576
7744
|
const tab = activeTab();
|
|
7577
7745
|
const snapshot = contextUsageSnapshot();
|
|
7578
7746
|
const workspaceLabel = latestWorkspace?.displayCwd || (tab?.cwd ? normalizeDisplayPath(tab.cwd) : "Choose or create a tab to start");
|
|
7747
|
+
const workspaceInfo = normalizeGitWorkspaceInfo(tab?.gitWorkspace);
|
|
7748
|
+
const worktreeLabel = gitWorkspaceBadgeLabel(workspaceInfo);
|
|
7579
7749
|
const queueCount = Number(currentState?.pendingMessageCount || 0) || 0;
|
|
7580
7750
|
const tabIndicatorState = tab ? tabIndicator(tab) : null;
|
|
7581
7751
|
const sessionSummary = dashboardSessionSummary();
|
|
@@ -7588,6 +7758,12 @@ function renderWorkspaceDashboard() {
|
|
|
7588
7758
|
const signature = JSON.stringify({
|
|
7589
7759
|
title: tab?.title || "Pi Web UI",
|
|
7590
7760
|
workspaceLabel,
|
|
7761
|
+
gitWorkspace: workspaceInfo ? {
|
|
7762
|
+
branch: workspaceInfo.branch,
|
|
7763
|
+
worktreePath: workspaceInfo.worktreePath,
|
|
7764
|
+
isMainWorktree: workspaceInfo.isMainWorktree,
|
|
7765
|
+
worktreeCount: workspaceInfo.worktreeCount,
|
|
7766
|
+
} : null,
|
|
7591
7767
|
tabIndicatorState,
|
|
7592
7768
|
tabsLength: tabs.length,
|
|
7593
7769
|
queueCount,
|
|
@@ -7617,6 +7793,13 @@ function renderWorkspaceDashboard() {
|
|
|
7617
7793
|
statusChip.append(make("span", "workspace-dashboard-chip-dot", tabIndicatorState.glyph), make("span", undefined, tabIndicatorState.label));
|
|
7618
7794
|
meta.append(statusChip);
|
|
7619
7795
|
}
|
|
7796
|
+
if (worktreeLabel) {
|
|
7797
|
+
const worktreeChip = make("button", "workspace-dashboard-chip worktree", worktreeLabel);
|
|
7798
|
+
worktreeChip.type = "button";
|
|
7799
|
+
worktreeChip.title = workspaceInfo?.worktreePath || worktreeLabel;
|
|
7800
|
+
worktreeChip.addEventListener("click", () => openBranchWorktreePicker());
|
|
7801
|
+
meta.append(worktreeChip);
|
|
7802
|
+
}
|
|
7620
7803
|
meta.append(
|
|
7621
7804
|
make("span", "workspace-dashboard-chip", `${tabs.length} tab${tabs.length === 1 ? "" : "s"}`),
|
|
7622
7805
|
make("span", `workspace-dashboard-chip ${queueCount ? "attention" : ""}`.trim(), queueCount ? `${queueCount} queued` : "queue clear"),
|
|
@@ -7626,6 +7809,7 @@ function renderWorkspaceDashboard() {
|
|
|
7626
7809
|
actions.append(
|
|
7627
7810
|
dashboardAction("Command palette", () => openCommandPalette(), "primary"),
|
|
7628
7811
|
dashboardAction("New tab", () => createTerminalTab()),
|
|
7812
|
+
dashboardAction("Branch worktree", () => openBranchWorktreePicker(), "worktree"),
|
|
7629
7813
|
dashboardAction("Resume", () => runNativeCommandMenu("/resume")),
|
|
7630
7814
|
dashboardAction("Model", () => runNativeCommandMenu("/model")),
|
|
7631
7815
|
dashboardAction("Settings", () => runNativeCommandMenu("/settings")),
|
|
@@ -7720,19 +7904,50 @@ function setFooterThinkingPickerOpen(open) {
|
|
|
7720
7904
|
}
|
|
7721
7905
|
|
|
7722
7906
|
function normalizeFooterGitBranches(data = {}) {
|
|
7723
|
-
const current = cleanStatusText(data.current || "");
|
|
7907
|
+
const current = cleanStatusText(data.current || data.currentBranch || "");
|
|
7724
7908
|
const seen = new Set();
|
|
7725
7909
|
const branches = [];
|
|
7726
7910
|
for (const item of Array.isArray(data.branches) ? data.branches : []) {
|
|
7727
7911
|
const name = cleanStatusText(typeof item === "string" ? item : item?.name);
|
|
7728
7912
|
if (!name || seen.has(name)) continue;
|
|
7729
7913
|
seen.add(name);
|
|
7730
|
-
branches.push({
|
|
7914
|
+
branches.push({
|
|
7915
|
+
name,
|
|
7916
|
+
current: Boolean(item?.current) || (!!current && name === current),
|
|
7917
|
+
occupied: Boolean(item?.occupied),
|
|
7918
|
+
worktreePath: cleanFooterPayloadText(item?.worktreePath, "", 4000),
|
|
7919
|
+
worktreeCurrent: Boolean(item?.worktreeCurrent),
|
|
7920
|
+
mainWorktree: Boolean(item?.mainWorktree),
|
|
7921
|
+
});
|
|
7731
7922
|
}
|
|
7923
|
+
const worktrees = (Array.isArray(data.worktrees) ? data.worktrees : [])
|
|
7924
|
+
.map((item) => ({
|
|
7925
|
+
path: cleanFooterPayloadText(item?.path, "", 4000),
|
|
7926
|
+
branch: cleanStatusText(item?.branch || ""),
|
|
7927
|
+
current: Boolean(item?.current),
|
|
7928
|
+
isMainWorktree: Boolean(item?.isMainWorktree),
|
|
7929
|
+
prunable: Boolean(item?.prunable),
|
|
7930
|
+
locked: Boolean(item?.locked),
|
|
7931
|
+
}))
|
|
7932
|
+
.filter((item) => item.path);
|
|
7933
|
+
const occupiedBranches = (Array.isArray(data.occupiedBranches) ? data.occupiedBranches : [])
|
|
7934
|
+
.map((item) => ({
|
|
7935
|
+
branch: cleanStatusText(item?.branch || ""),
|
|
7936
|
+
path: cleanFooterPayloadText(item?.path, "", 4000),
|
|
7937
|
+
current: Boolean(item?.current),
|
|
7938
|
+
isMainWorktree: Boolean(item?.isMainWorktree),
|
|
7939
|
+
}))
|
|
7940
|
+
.filter((item) => item.branch && item.path);
|
|
7732
7941
|
return {
|
|
7733
|
-
root: cleanFooterPayloadText(data.root, "", 4000),
|
|
7942
|
+
root: cleanFooterPayloadText(data.root || data.currentWorktreePath, "", 4000),
|
|
7943
|
+
repoRoot: cleanFooterPayloadText(data.repoRoot || data.root, "", 4000),
|
|
7944
|
+
commonGitDir: cleanFooterPayloadText(data.commonGitDir, "", 4000),
|
|
7945
|
+
currentWorktreePath: cleanFooterPayloadText(data.currentWorktreePath || data.root, "", 4000),
|
|
7946
|
+
defaultWorktreesRoot: cleanFooterPayloadText(data.defaultWorktreesRoot, "", 4000),
|
|
7734
7947
|
current,
|
|
7735
7948
|
branches,
|
|
7949
|
+
worktrees,
|
|
7950
|
+
occupiedBranches,
|
|
7736
7951
|
};
|
|
7737
7952
|
}
|
|
7738
7953
|
|
|
@@ -7757,12 +7972,19 @@ function applyOptimisticGitFooterBranch(branch, tabContext = activeTabContext())
|
|
|
7757
7972
|
async function loadFooterBranchPicker(tabContext = activeTabContext()) {
|
|
7758
7973
|
const requestSerial = ++footerBranchPickerRequestSerial;
|
|
7759
7974
|
const tabId = tabContext.tabId || activeTabId;
|
|
7975
|
+
const preserveState = footerBranchPickerState.tabId === tabId ? footerBranchPickerState : {};
|
|
7760
7976
|
footerBranchPickerState = {
|
|
7761
7977
|
loading: true,
|
|
7762
7978
|
error: "",
|
|
7763
|
-
branches:
|
|
7764
|
-
current:
|
|
7765
|
-
root:
|
|
7979
|
+
branches: preserveState.branches || [],
|
|
7980
|
+
current: preserveState.current || "",
|
|
7981
|
+
root: preserveState.root || "",
|
|
7982
|
+
repoRoot: preserveState.repoRoot || "",
|
|
7983
|
+
commonGitDir: preserveState.commonGitDir || "",
|
|
7984
|
+
currentWorktreePath: preserveState.currentWorktreePath || "",
|
|
7985
|
+
defaultWorktreesRoot: preserveState.defaultWorktreesRoot || "",
|
|
7986
|
+
worktrees: preserveState.worktrees || [],
|
|
7987
|
+
occupiedBranches: preserveState.occupiedBranches || [],
|
|
7766
7988
|
switching: "",
|
|
7767
7989
|
tabId,
|
|
7768
7990
|
};
|
|
@@ -7855,6 +8077,24 @@ function confirmFooterGitBranchAction(branch, { create = false, requireConfirm =
|
|
|
7855
8077
|
return window.confirm(message);
|
|
7856
8078
|
}
|
|
7857
8079
|
|
|
8080
|
+
function confirmFooterGitWorktreeAction(branch, { path = "", create = false, requireConfirm = false } = {}) {
|
|
8081
|
+
const branchName = cleanStatusText(branch);
|
|
8082
|
+
if (!requireConfirm) return true;
|
|
8083
|
+
const targetPath = cleanFooterPayloadText(path, "", 4000);
|
|
8084
|
+
const message = [
|
|
8085
|
+
`${create ? "Create" : "Open"} branch worktree: ${branchName || targetPath}?`,
|
|
8086
|
+
"",
|
|
8087
|
+
`Repository: ${footerBranchPickerState.repoRoot || footerBranchPickerState.root || currentGitFooterCacheCwd() || "current tab"}`,
|
|
8088
|
+
targetPath ? `Worktree: ${targetPath}` : `Default location: ${footerBranchPickerState.defaultWorktreesRoot || "repo sibling .worktrees directory"}`,
|
|
8089
|
+
"",
|
|
8090
|
+
"This opens a separate checkout in a separate Pi tab and does not switch this tab's branch.",
|
|
8091
|
+
"Ignored dependencies such as node_modules or .venv are not copied; bootstrap them manually if needed.",
|
|
8092
|
+
"",
|
|
8093
|
+
"Continue?",
|
|
8094
|
+
].join("\n");
|
|
8095
|
+
return window.confirm(message);
|
|
8096
|
+
}
|
|
8097
|
+
|
|
7858
8098
|
function footerBranchCreateType(value = footerBranchCreateDraft.type) {
|
|
7859
8099
|
return slugifyGitBranchPart(value);
|
|
7860
8100
|
}
|
|
@@ -7897,20 +8137,42 @@ function gitSwitchCreateCommandDisplay(branch) {
|
|
|
7897
8137
|
return `git switch -c ${quoteGitBranchForDisplay(branch)}`;
|
|
7898
8138
|
}
|
|
7899
8139
|
|
|
7900
|
-
function
|
|
7901
|
-
|
|
8140
|
+
function slugifyWorktreePathPart(value) {
|
|
8141
|
+
return String(value || "")
|
|
8142
|
+
.toLowerCase()
|
|
8143
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
8144
|
+
.replace(/[-.]{2,}/g, "-")
|
|
8145
|
+
.replace(/^-+|-+$/g, "")
|
|
8146
|
+
.slice(0, 96) || "branch";
|
|
8147
|
+
}
|
|
8148
|
+
|
|
8149
|
+
function footerBranchCreateWorktreePathPreview(branch = footerBranchCreateName(), state = footerBranchPickerState) {
|
|
8150
|
+
const root = state.defaultWorktreesRoot || "<repo>.worktrees";
|
|
8151
|
+
return `${root.replace(/\/+$/, "")}/${slugifyWorktreePathPart(branch || footerBranchCreatePreviewName())}`;
|
|
8152
|
+
}
|
|
8153
|
+
|
|
8154
|
+
function gitWorktreeCreateCommandDisplay(branch, state = footerBranchPickerState) {
|
|
8155
|
+
return `git worktree add -b ${quoteGitBranchForDisplay(branch)} ${quoteGitBranchForDisplay(footerBranchCreateWorktreePathPreview(branch, state))}`;
|
|
8156
|
+
}
|
|
8157
|
+
|
|
8158
|
+
function gitWorktreeOpenCommandDisplay(path) {
|
|
8159
|
+
return `pi-webui --cwd ${quoteGitBranchForDisplay(path || "<worktree-path>")}`;
|
|
8160
|
+
}
|
|
8161
|
+
|
|
8162
|
+
function footerBranchCreateTooltip(branchName = footerBranchCreateName(), state = footerBranchPickerState) {
|
|
8163
|
+
const command = gitWorktreeCreateCommandDisplay(branchName || footerBranchCreatePreviewName(), state);
|
|
7902
8164
|
return [
|
|
7903
|
-
"Create
|
|
7904
|
-
"A branch is a
|
|
8165
|
+
"Create branch worktree",
|
|
8166
|
+
"A branch worktree is a separate checkout for parallel changes.",
|
|
7905
8167
|
"",
|
|
7906
|
-
`This will run: ${command}`,
|
|
8168
|
+
`This will run roughly: ${command}`,
|
|
7907
8169
|
"",
|
|
7908
8170
|
"What happens:",
|
|
7909
|
-
"• creates the branch from the current
|
|
7910
|
-
"•
|
|
7911
|
-
"• does not commit, push, or delete anything",
|
|
8171
|
+
"• creates the branch from the current HEAD when it does not exist",
|
|
8172
|
+
"• opens a separate Pi tab rooted at that worktree",
|
|
8173
|
+
"• does not switch this tab's branch, commit, push, or delete anything",
|
|
7912
8174
|
"",
|
|
7913
|
-
"Tip:
|
|
8175
|
+
"Tip: ignored dependencies such as node_modules or .venv are not copied.",
|
|
7914
8176
|
].join("\n");
|
|
7915
8177
|
}
|
|
7916
8178
|
|
|
@@ -7925,6 +8187,72 @@ async function createFooterGitBranch(branch = footerBranchCreateName()) {
|
|
|
7925
8187
|
await applyFooterGitBranch(branchName, { create: true, tabContext, skipConfirm: true });
|
|
7926
8188
|
}
|
|
7927
8189
|
|
|
8190
|
+
async function openWorktreeResponseTab(response, { branchName = "", action = "open" } = {}) {
|
|
8191
|
+
if (!response.ok) throw new Error(response.error || `Failed to ${action} branch worktree`);
|
|
8192
|
+
const payload = response.data || {};
|
|
8193
|
+
if (Array.isArray(payload.tabs)) {
|
|
8194
|
+
tabs = payload.tabs;
|
|
8195
|
+
syncTabMetadata(tabs);
|
|
8196
|
+
}
|
|
8197
|
+
if (payload.tab) applyTabMetadata(payload.tab);
|
|
8198
|
+
footerBranchPickerOpen = false;
|
|
8199
|
+
footerBranchPickerRequestSerial += 1;
|
|
8200
|
+
footerBranchPickerState = { ...footerBranchPickerState, loading: false, switching: "" };
|
|
8201
|
+
renderTabs();
|
|
8202
|
+
const targetTab = payload.tab;
|
|
8203
|
+
if (targetTab?.id) await switchTab(targetTab.id);
|
|
8204
|
+
const branch = cleanStatusText(payload.worktree?.branch || payload.branch || branchName || targetTab?.gitWorkspace?.branch || "");
|
|
8205
|
+
const where = payload.worktree?.path || payload.path || targetTab?.cwd || "worktree";
|
|
8206
|
+
const prefix = payload.created ? "Created" : payload.openedExisting || payload.openedExistingTab ? "Opened existing" : "Opened";
|
|
8207
|
+
addEvent(`${prefix} branch worktree${branch ? ` ${branch}` : ""} at ${normalizeDisplayPath(where)}.`, "success");
|
|
8208
|
+
if (payload.session?.warning) addEvent(payload.session.warning, "warn");
|
|
8209
|
+
if (payload.dependencyHint) addEvent(payload.dependencyHint, "info");
|
|
8210
|
+
requestGitFooterWebuiPayload(activeTabContext(), { force: true });
|
|
8211
|
+
}
|
|
8212
|
+
|
|
8213
|
+
async function createFooterGitBranchWorktree(branch = footerBranchCreateName(), { tabContext = activeTabContext(), skipConfirm = false } = {}) {
|
|
8214
|
+
const branchName = cleanStatusText(branch);
|
|
8215
|
+
if (!branchName) {
|
|
8216
|
+
addEvent("Enter a branch name before creating a branch worktree.", "warn");
|
|
8217
|
+
return;
|
|
8218
|
+
}
|
|
8219
|
+
if (!skipConfirm && !confirmFooterGitWorktreeAction(branchName, { create: true, requireConfirm: true })) return;
|
|
8220
|
+
const tabId = tabContext.tabId || activeTabId;
|
|
8221
|
+
try {
|
|
8222
|
+
footerBranchPickerState = { ...footerBranchPickerState, loading: true, error: "", switching: branchName, tabId };
|
|
8223
|
+
renderFooter();
|
|
8224
|
+
const response = await api("/api/git-worktrees", { method: "POST", body: { branchName, sessionMode: "fork-current", openTab: true }, tabId });
|
|
8225
|
+
await openWorktreeResponseTab(response, { branchName, action: "create" });
|
|
8226
|
+
} catch (error) {
|
|
8227
|
+
if (isCurrentTabContext(tabContext)) {
|
|
8228
|
+
footerBranchPickerState = { ...footerBranchPickerState, loading: false, switching: "", error: error.message || String(error) };
|
|
8229
|
+
renderFooter();
|
|
8230
|
+
updateFooterModelPickerPosition();
|
|
8231
|
+
}
|
|
8232
|
+
addEvent(error.message || String(error), "error");
|
|
8233
|
+
}
|
|
8234
|
+
}
|
|
8235
|
+
|
|
8236
|
+
async function openFooterGitWorktree(path, { branchName = "", tabContext = activeTabContext(), skipConfirm = false } = {}) {
|
|
8237
|
+
const worktreePath = cleanFooterPayloadText(path, "", 4000);
|
|
8238
|
+
if (!worktreePath) return;
|
|
8239
|
+
if (!skipConfirm && !confirmFooterGitWorktreeAction(branchName, { path: worktreePath, requireConfirm: false })) return;
|
|
8240
|
+
const tabId = tabContext.tabId || activeTabId;
|
|
8241
|
+
try {
|
|
8242
|
+
footerBranchPickerState = { ...footerBranchPickerState, loading: true, error: "", switching: branchName || worktreePath, tabId };
|
|
8243
|
+
renderFooter();
|
|
8244
|
+
const response = await api("/api/git-worktrees/open", { method: "POST", body: { path: worktreePath, sessionMode: "fork-current", openTab: true }, tabId });
|
|
8245
|
+
await openWorktreeResponseTab(response, { branchName, action: "open" });
|
|
8246
|
+
} catch (error) {
|
|
8247
|
+
if (isCurrentTabContext(tabContext)) {
|
|
8248
|
+
footerBranchPickerState = { ...footerBranchPickerState, loading: false, switching: "", error: error.message || String(error) };
|
|
8249
|
+
renderFooter();
|
|
8250
|
+
updateFooterModelPickerPosition();
|
|
8251
|
+
}
|
|
8252
|
+
addEvent(error.message || String(error), "error");
|
|
8253
|
+
}
|
|
8254
|
+
}
|
|
8255
|
+
|
|
7928
8256
|
async function applyFooterGitBranch(branch, { create = false, tabContext = activeTabContext(), skipConfirm = false } = {}) {
|
|
7929
8257
|
const branchName = cleanStatusText(branch);
|
|
7930
8258
|
if (!branchName) return;
|
|
@@ -7960,10 +8288,10 @@ async function applyFooterGitBranch(branch, { create = false, tabContext = activ
|
|
|
7960
8288
|
|
|
7961
8289
|
function renderFooterBranchCreateForm(state = footerBranchPickerState) {
|
|
7962
8290
|
const form = make("form", "footer-branch-create-form");
|
|
7963
|
-
form.setAttribute("aria-label", "Create
|
|
8291
|
+
form.setAttribute("aria-label", "Create branch worktree");
|
|
7964
8292
|
|
|
7965
8293
|
const header = make("div", "footer-branch-create-header");
|
|
7966
|
-
header.append(make("strong", "footer-branch-create-title", "Create
|
|
8294
|
+
header.append(make("strong", "footer-branch-create-title", "Create branch worktree"));
|
|
7967
8295
|
|
|
7968
8296
|
const fields = make("div", "footer-branch-create-fields");
|
|
7969
8297
|
const typeField = make("div", "footer-branch-create-type-field");
|
|
@@ -8012,19 +8340,19 @@ function renderFooterBranchCreateForm(state = footerBranchPickerState) {
|
|
|
8012
8340
|
nameInput.spellcheck = false;
|
|
8013
8341
|
nameInput.setAttribute("aria-label", "New branch name");
|
|
8014
8342
|
|
|
8015
|
-
const submitButton = make("button", "footer-branch-create-submit", state.switching ? "
|
|
8343
|
+
const submitButton = make("button", "footer-branch-create-submit", state.switching ? "Opening…" : "Open worktree tab");
|
|
8016
8344
|
submitButton.type = "submit";
|
|
8017
8345
|
|
|
8018
8346
|
const preview = make("div", "footer-branch-create-preview");
|
|
8019
8347
|
const updatePreview = () => {
|
|
8020
8348
|
const branchName = footerBranchCreateName();
|
|
8021
|
-
preview.textContent =
|
|
8349
|
+
preview.textContent = gitWorktreeCreateCommandDisplay(branchName || footerBranchCreatePreviewName(), state);
|
|
8022
8350
|
const submitDisabled = Boolean(state.switching) || !branchName;
|
|
8023
8351
|
submitButton.disabled = false;
|
|
8024
8352
|
submitButton.classList.toggle("footer-branch-create-submit-disabled", submitDisabled);
|
|
8025
8353
|
submitButton.setAttribute("aria-disabled", submitDisabled ? "true" : "false");
|
|
8026
8354
|
submitButton.dataset.tooltip = footerBranchCreateTooltip(branchName);
|
|
8027
|
-
submitButton.setAttribute("aria-label", branchName ? `Create and
|
|
8355
|
+
submitButton.setAttribute("aria-label", branchName ? `Create and open branch worktree ${branchName}` : "Create branch worktree: enter both a branch type and name first");
|
|
8028
8356
|
submitButton.removeAttribute("title");
|
|
8029
8357
|
};
|
|
8030
8358
|
|
|
@@ -8065,7 +8393,7 @@ function renderFooterBranchCreateForm(state = footerBranchPickerState) {
|
|
|
8065
8393
|
event.preventDefault();
|
|
8066
8394
|
if (state.switching) return;
|
|
8067
8395
|
const branchName = footerBranchCreateName();
|
|
8068
|
-
|
|
8396
|
+
createFooterGitBranchWorktree(branchName).catch((error) => addEvent(error.message || String(error), "error"));
|
|
8069
8397
|
});
|
|
8070
8398
|
|
|
8071
8399
|
updatePreview();
|
|
@@ -8076,14 +8404,94 @@ function renderFooterBranchCreateForm(state = footerBranchPickerState) {
|
|
|
8076
8404
|
return form;
|
|
8077
8405
|
}
|
|
8078
8406
|
|
|
8407
|
+
function footerBranchWorktreePath(branch, state = footerBranchPickerState) {
|
|
8408
|
+
const direct = cleanFooterPayloadText(branch?.worktreePath, "", 4000);
|
|
8409
|
+
if (direct) return direct;
|
|
8410
|
+
return cleanFooterPayloadText(state.occupiedBranches?.find((item) => item.branch === branch?.name)?.path, "", 4000);
|
|
8411
|
+
}
|
|
8412
|
+
|
|
8413
|
+
function footerBranchOptionDetail(branch, state, { selected, worktreePath } = {}) {
|
|
8414
|
+
if (state.switching === branch.name) return "opening…";
|
|
8415
|
+
if (selected) return branch.worktreeCurrent ? "current branch in this worktree" : "current branch";
|
|
8416
|
+
if (worktreePath) return branch.mainWorktree ? "checked out in main worktree · open tab" : "checked out in another worktree · open tab";
|
|
8417
|
+
return "open branch in a new worktree tab";
|
|
8418
|
+
}
|
|
8419
|
+
|
|
8420
|
+
function openFooterBranchOption(branch, state = footerBranchPickerState) {
|
|
8421
|
+
const worktreePath = footerBranchWorktreePath(branch, state);
|
|
8422
|
+
if (worktreePath && !branch.worktreeCurrent) return openFooterGitWorktree(worktreePath, { branchName: branch.name, skipConfirm: true });
|
|
8423
|
+
return createFooterGitBranchWorktree(branch.name, { skipConfirm: true });
|
|
8424
|
+
}
|
|
8425
|
+
|
|
8426
|
+
function renderFooterBranchOption(branch, state = footerBranchPickerState) {
|
|
8427
|
+
const selected = branch.current || (!!state.current && branch.name === state.current);
|
|
8428
|
+
const worktreePath = footerBranchWorktreePath(branch, state);
|
|
8429
|
+
const busy = state.loading || !!state.switching;
|
|
8430
|
+
const primaryDisabled = busy || selected;
|
|
8431
|
+
const row = make("div", `footer-branch-option-row${selected ? " active" : ""}${worktreePath && !branch.worktreeCurrent ? " worktree-occupied" : ""}`);
|
|
8432
|
+
row.setAttribute("role", "option");
|
|
8433
|
+
row.setAttribute("aria-selected", selected ? "true" : "false");
|
|
8434
|
+
|
|
8435
|
+
const primary = make("button", "footer-model-option footer-branch-option footer-branch-primary-action");
|
|
8436
|
+
primary.type = "button";
|
|
8437
|
+
primary.disabled = primaryDisabled;
|
|
8438
|
+
primary.title = selected ? `Current branch: ${branch.name}` : worktreePath ? `Open existing worktree: ${worktreePath}` : `Open ${branch.name} in a new Git worktree tab`;
|
|
8439
|
+
primary.append(
|
|
8440
|
+
make("span", "footer-model-option-main", branch.name),
|
|
8441
|
+
make("span", "footer-model-option-name", footerBranchOptionDetail(branch, state, { selected, worktreePath })),
|
|
8442
|
+
);
|
|
8443
|
+
if (!primaryDisabled) primary.addEventListener("click", () => openFooterBranchOption(branch, state));
|
|
8444
|
+
row.append(primary);
|
|
8445
|
+
|
|
8446
|
+
if (!selected) {
|
|
8447
|
+
const advanced = make("button", "footer-branch-advanced-action", "Switch here");
|
|
8448
|
+
advanced.type = "button";
|
|
8449
|
+
advanced.disabled = busy || !!worktreePath;
|
|
8450
|
+
advanced.title = worktreePath
|
|
8451
|
+
? "This branch is already checked out elsewhere; use the primary worktree action instead of switching this checkout."
|
|
8452
|
+
: `Advanced: git switch ${branch.name} in this checkout`;
|
|
8453
|
+
advanced.addEventListener("click", () => applyFooterGitBranch(branch.name));
|
|
8454
|
+
row.append(advanced);
|
|
8455
|
+
}
|
|
8456
|
+
return row;
|
|
8457
|
+
}
|
|
8458
|
+
|
|
8459
|
+
function renderFooterWorktreeList(state = footerBranchPickerState) {
|
|
8460
|
+
const worktrees = (state.worktrees || []).filter((item) => item.path && !item.prunable);
|
|
8461
|
+
if (worktrees.length <= 1) return null;
|
|
8462
|
+
const section = make("div", "footer-branch-worktree-section");
|
|
8463
|
+
section.append(make("div", "footer-branch-section-title", `Open worktrees (${worktrees.length})`));
|
|
8464
|
+
for (const worktree of worktrees.slice(0, 8)) {
|
|
8465
|
+
const selected = worktree.current || worktree.path === state.currentWorktreePath;
|
|
8466
|
+
const button = make("button", `footer-model-option footer-worktree-option${selected ? " active" : ""}`);
|
|
8467
|
+
button.type = "button";
|
|
8468
|
+
button.disabled = selected || state.loading || !!state.switching;
|
|
8469
|
+
button.title = selected ? `Current worktree: ${worktree.path}` : `Open worktree: ${worktree.path}`;
|
|
8470
|
+
button.append(
|
|
8471
|
+
make("span", "footer-model-option-main", worktree.branch || "detached"),
|
|
8472
|
+
make("span", "footer-model-option-name", `${selected ? "current" : "open"} · ${normalizeDisplayPath(worktree.path)}`),
|
|
8473
|
+
);
|
|
8474
|
+
if (!button.disabled) button.addEventListener("click", () => openFooterGitWorktree(worktree.path, { branchName: worktree.branch || "", skipConfirm: true }));
|
|
8475
|
+
section.append(button);
|
|
8476
|
+
}
|
|
8477
|
+
return section;
|
|
8478
|
+
}
|
|
8479
|
+
|
|
8480
|
+
function openBranchWorktreePicker() {
|
|
8481
|
+
setNewTabMenuOpen(false);
|
|
8482
|
+
setMobileTabsExpanded(false);
|
|
8483
|
+
setComposerActionsOpen(false);
|
|
8484
|
+
setFooterBranchPickerOpen(true);
|
|
8485
|
+
}
|
|
8486
|
+
|
|
8079
8487
|
function renderFooterBranchPicker() {
|
|
8080
8488
|
const picker = make("div", "footer-model-picker footer-branch-picker");
|
|
8081
8489
|
picker.setAttribute("role", "listbox");
|
|
8082
|
-
picker.setAttribute("aria-label", "Git branches");
|
|
8490
|
+
picker.setAttribute("aria-label", "Git branches and worktrees");
|
|
8083
8491
|
const state = footerBranchPickerState;
|
|
8084
8492
|
const current = state.current || "detached";
|
|
8085
|
-
picker.append(make("div", "footer-model-picker-title", "Git branches"));
|
|
8086
|
-
picker.append(make("div", "footer-model-picker-source", `${state.loading ? "Refreshing" : "Current"}: ${state.switching || current}${state.root ? ` · ${state.root}` : ""}`));
|
|
8493
|
+
picker.append(make("div", "footer-model-picker-title", "Git branches & worktrees"));
|
|
8494
|
+
picker.append(make("div", "footer-model-picker-source", `${state.loading ? "Refreshing" : "Current"}: ${state.switching || current}${state.currentWorktreePath ? ` · ${normalizeDisplayPath(state.currentWorktreePath)}` : state.root ? ` · ${state.root}` : ""}`));
|
|
8087
8495
|
|
|
8088
8496
|
if (state.error) {
|
|
8089
8497
|
const error = make("div", "footer-model-picker-empty error");
|
|
@@ -8092,35 +8500,23 @@ function renderFooterBranchPicker() {
|
|
|
8092
8500
|
return picker;
|
|
8093
8501
|
}
|
|
8094
8502
|
if (state.loading && state.branches.length === 0) {
|
|
8095
|
-
picker.append(make("div", "footer-model-picker-empty muted", "Loading existing local branches…
|
|
8503
|
+
picker.append(make("div", "footer-model-picker-empty muted", "Loading existing local branches and worktrees… Worktree creation is available once branch data loads."), renderFooterBranchCreateForm(state));
|
|
8096
8504
|
return picker;
|
|
8097
8505
|
}
|
|
8098
8506
|
|
|
8099
8507
|
const hasOtherBranches = state.branches.some((branch) => !branch.current && branch.name !== state.current);
|
|
8100
8508
|
if (!state.loading && !hasOtherBranches) {
|
|
8101
8509
|
const empty = make("div", "footer-model-picker-empty muted");
|
|
8102
|
-
empty.append(make("strong", undefined, "No other local branches available."), make("span", undefined, " Create a branch from the current HEAD to continue."));
|
|
8510
|
+
empty.append(make("strong", undefined, "No other local branches available."), make("span", undefined, " Create a branch worktree from the current HEAD to continue."));
|
|
8103
8511
|
picker.append(empty);
|
|
8104
8512
|
}
|
|
8105
8513
|
|
|
8106
8514
|
picker.append(renderFooterBranchCreateForm(state));
|
|
8515
|
+
const worktreeSection = renderFooterWorktreeList(state);
|
|
8516
|
+
if (worktreeSection) picker.append(worktreeSection);
|
|
8517
|
+
picker.append(make("div", "footer-branch-section-title", "Branches"));
|
|
8107
8518
|
|
|
8108
|
-
for (const branch of state.branches)
|
|
8109
|
-
const selected = branch.current || (!!state.current && branch.name === state.current);
|
|
8110
|
-
const disabled = selected || state.loading || !!state.switching;
|
|
8111
|
-
const button = make("button", `footer-model-option footer-branch-option${selected ? " active" : ""}`);
|
|
8112
|
-
button.type = "button";
|
|
8113
|
-
button.disabled = disabled;
|
|
8114
|
-
button.setAttribute("role", "option");
|
|
8115
|
-
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
8116
|
-
button.title = selected ? `Current branch: ${branch.name}` : `git switch ${branch.name}`;
|
|
8117
|
-
button.append(
|
|
8118
|
-
make("span", "footer-model-option-main", branch.name),
|
|
8119
|
-
make("span", "footer-model-option-name", selected ? "current branch" : state.switching === branch.name ? "switching…" : "switch to this branch"),
|
|
8120
|
-
);
|
|
8121
|
-
if (!disabled) button.addEventListener("click", () => applyFooterGitBranch(branch.name));
|
|
8122
|
-
picker.append(button);
|
|
8123
|
-
}
|
|
8519
|
+
for (const branch of state.branches) picker.append(renderFooterBranchOption(branch, state));
|
|
8124
8520
|
return picker;
|
|
8125
8521
|
}
|
|
8126
8522
|
|
|
@@ -9675,12 +10071,18 @@ function activeAppRunnerData() {
|
|
|
9675
10071
|
function setAppRunnerData(tabId, data = {}) {
|
|
9676
10072
|
if (!tabId) return;
|
|
9677
10073
|
const previous = appRunnerDataByTab.get(tabId) || { runners: [], activeRun: null, customRunnerConfig: null };
|
|
9678
|
-
|
|
10074
|
+
const hasActiveRun = Object.prototype.hasOwnProperty.call(data, "activeRun");
|
|
10075
|
+
const next = {
|
|
9679
10076
|
cwd: data.cwd || previous.cwd || "",
|
|
9680
10077
|
runners: Array.isArray(data.runners) ? data.runners : previous.runners || [],
|
|
9681
10078
|
customRunnerConfig: data.customRunnerConfig || previous.customRunnerConfig || null,
|
|
9682
|
-
activeRun:
|
|
9683
|
-
}
|
|
10079
|
+
activeRun: hasActiveRun ? data.activeRun : previous.activeRun || null,
|
|
10080
|
+
};
|
|
10081
|
+
appRunnerDataByTab.set(tabId, next);
|
|
10082
|
+
if (hasActiveRun) {
|
|
10083
|
+
const tab = tabs.find((item) => item.id === tabId);
|
|
10084
|
+
if (tab) tab.appRunner = next.activeRun || null;
|
|
10085
|
+
}
|
|
9684
10086
|
}
|
|
9685
10087
|
|
|
9686
10088
|
function appRunnerIsRunning(run) {
|
|
@@ -9753,6 +10155,7 @@ async function runAppRunner(runnerId) {
|
|
|
9753
10155
|
setAppRunnerData(tabContext.tabId, response.data || {});
|
|
9754
10156
|
renderAppRunnerControls();
|
|
9755
10157
|
renderWidgets();
|
|
10158
|
+
renderTabs();
|
|
9756
10159
|
const command = response.data?.activeRun?.displayCommand || "app runner";
|
|
9757
10160
|
addEvent(`started ${command}`, "info");
|
|
9758
10161
|
} catch (error) {
|
|
@@ -9761,6 +10164,7 @@ async function runAppRunner(runnerId) {
|
|
|
9761
10164
|
setAppRunnerData(tabContext.tabId, { activeRun: appRunnerFailureState(runnerId, error, activeAppRunnerData()) });
|
|
9762
10165
|
renderAppRunnerControls();
|
|
9763
10166
|
renderWidgets();
|
|
10167
|
+
renderTabs();
|
|
9764
10168
|
addEvent(`app runner failed: ${message}`, "error");
|
|
9765
10169
|
}
|
|
9766
10170
|
}
|
|
@@ -9774,6 +10178,7 @@ async function stopAppRunner() {
|
|
|
9774
10178
|
setAppRunnerData(tabContext.tabId, response.data || {});
|
|
9775
10179
|
renderAppRunnerControls();
|
|
9776
10180
|
renderWidgets();
|
|
10181
|
+
renderTabs();
|
|
9777
10182
|
addEvent("app runner stop requested", "warn");
|
|
9778
10183
|
} catch (error) {
|
|
9779
10184
|
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
@@ -9789,6 +10194,7 @@ async function clearAppRunner() {
|
|
|
9789
10194
|
setAppRunnerData(tabContext.tabId, response.data || {});
|
|
9790
10195
|
renderAppRunnerControls();
|
|
9791
10196
|
renderWidgets();
|
|
10197
|
+
renderTabs();
|
|
9792
10198
|
} catch (error) {
|
|
9793
10199
|
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
9794
10200
|
}
|
|
@@ -9832,6 +10238,73 @@ function appRunnerInputDraftKey(run) {
|
|
|
9832
10238
|
return run?.id || run?.runnerId || "active";
|
|
9833
10239
|
}
|
|
9834
10240
|
|
|
10241
|
+
function normalizeAppRunnerContextLineCount(value) {
|
|
10242
|
+
const number = Number.parseInt(String(value ?? ""), 10);
|
|
10243
|
+
if (!Number.isFinite(number)) return APP_RUNNER_CONTEXT_DEFAULT_LINES;
|
|
10244
|
+
return Math.max(1, Math.min(APP_RUNNER_CONTEXT_MAX_LINES, number));
|
|
10245
|
+
}
|
|
10246
|
+
|
|
10247
|
+
function appRunnerContextDraftKey(run) {
|
|
10248
|
+
return appRunnerInputDraftKey(run);
|
|
10249
|
+
}
|
|
10250
|
+
|
|
10251
|
+
async function transferAppRunnerOutputToContext(run, form) {
|
|
10252
|
+
const tabContext = activeTabContext();
|
|
10253
|
+
if (!tabContext.tabId || !run) return;
|
|
10254
|
+
const key = appRunnerContextDraftKey(run);
|
|
10255
|
+
const input = form?.querySelector?.(".app-runner-context-lines-input");
|
|
10256
|
+
const lineCount = normalizeAppRunnerContextLineCount(input?.value || appRunnerContextLineDraftByRun.get(key) || APP_RUNNER_CONTEXT_DEFAULT_LINES);
|
|
10257
|
+
if (input) input.value = String(lineCount);
|
|
10258
|
+
appRunnerContextLineDraftByRun.set(key, String(lineCount));
|
|
10259
|
+
const buttons = [...(form?.querySelectorAll?.("button") || [])];
|
|
10260
|
+
buttons.forEach((button) => { button.disabled = true; });
|
|
10261
|
+
try {
|
|
10262
|
+
const response = await api("/api/app-runner/context", { method: "POST", body: { lineCount }, tabId: tabContext.tabId });
|
|
10263
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
10264
|
+
const data = response.data || {};
|
|
10265
|
+
if (data.activeRun) setAppRunnerData(tabContext.tabId, { activeRun: data.activeRun });
|
|
10266
|
+
const deliveredAsSteer = data.delivery === "steer";
|
|
10267
|
+
addEvent(deliveredAsSteer
|
|
10268
|
+
? `sent last ${data.lineCount || lineCount} app runner output lines as live steering context`
|
|
10269
|
+
: `added last ${data.lineCount || lineCount} app runner output lines to agent context`, "info");
|
|
10270
|
+
scheduleRefreshMessages(120, tabContext);
|
|
10271
|
+
scheduleRefreshState(120, tabContext);
|
|
10272
|
+
} catch (error) {
|
|
10273
|
+
if (isCurrentTabContext(tabContext)) addEvent(`app runner context transfer failed: ${error.message || String(error)}`, "error");
|
|
10274
|
+
} finally {
|
|
10275
|
+
buttons.forEach((button) => { button.disabled = false; });
|
|
10276
|
+
}
|
|
10277
|
+
}
|
|
10278
|
+
|
|
10279
|
+
function renderAppRunnerContextForm(run) {
|
|
10280
|
+
const key = appRunnerContextDraftKey(run);
|
|
10281
|
+
const form = make("form", "app-runner-context-form");
|
|
10282
|
+
form.dataset.runId = key;
|
|
10283
|
+
const label = make("label", "app-runner-context-lines-label");
|
|
10284
|
+
label.append(make("span", "", "Context lines"));
|
|
10285
|
+
const input = make("input", "app-runner-context-lines-input");
|
|
10286
|
+
input.type = "number";
|
|
10287
|
+
input.min = "1";
|
|
10288
|
+
input.max = String(APP_RUNNER_CONTEXT_MAX_LINES);
|
|
10289
|
+
input.step = "1";
|
|
10290
|
+
input.inputMode = "numeric";
|
|
10291
|
+
input.value = String(normalizeAppRunnerContextLineCount(appRunnerContextLineDraftByRun.get(key) || APP_RUNNER_CONTEXT_DEFAULT_LINES));
|
|
10292
|
+
input.setAttribute("aria-label", "Number of recent app runner output lines to add to agent context");
|
|
10293
|
+
input.addEventListener("input", () => {
|
|
10294
|
+
appRunnerContextLineDraftByRun.set(key, String(normalizeAppRunnerContextLineCount(input.value)));
|
|
10295
|
+
});
|
|
10296
|
+
label.append(input);
|
|
10297
|
+
const transfer = make("button", "release-npm-action app-runner-context-action", "Add to context");
|
|
10298
|
+
transfer.type = "submit";
|
|
10299
|
+
transfer.title = "Add the selected number of recent app runner output lines to this agent session's context";
|
|
10300
|
+
form.addEventListener("submit", (event) => {
|
|
10301
|
+
event.preventDefault();
|
|
10302
|
+
transferAppRunnerOutputToContext(run, form);
|
|
10303
|
+
});
|
|
10304
|
+
form.append(label, transfer);
|
|
10305
|
+
return form;
|
|
10306
|
+
}
|
|
10307
|
+
|
|
9835
10308
|
function captureAppRunnerInputFocus() {
|
|
9836
10309
|
const input = document.activeElement;
|
|
9837
10310
|
if (!input?.classList?.contains("app-runner-stdin-input")) return null;
|
|
@@ -10332,11 +10805,12 @@ function renderAppRunnerWidget() {
|
|
|
10332
10805
|
actions.append(appRunnerActionButton("Clear", clearAppRunner));
|
|
10333
10806
|
}
|
|
10334
10807
|
const inputForm = running ? renderAppRunnerInputForm(run) : null;
|
|
10808
|
+
const contextForm = renderAppRunnerContextForm(run);
|
|
10335
10809
|
const pills = make("div", "app-runner-output-pills");
|
|
10336
10810
|
if (run.kind) pills.append(make("span", "release-npm-pill", run.kind));
|
|
10337
10811
|
pills.append(make("span", `release-npm-pill app-runner-status ${run.status || "running"}`.trim(), status));
|
|
10338
10812
|
if (elapsed) pills.append(make("span", "release-npm-pill elapsed", elapsed));
|
|
10339
|
-
controls.append(actions);
|
|
10813
|
+
controls.append(actions, contextForm);
|
|
10340
10814
|
if (inputForm) controls.append(inputForm);
|
|
10341
10815
|
controls.append(pills, make("span", "app-runner-output-meta", controlParts.join(" · ")));
|
|
10342
10816
|
const outputDetails = renderReleaseNpmOutputDetails(`app-runner:${run.id || run.runnerId || "active"}`, streamHeader, terminal, controls);
|
|
@@ -11451,9 +11925,15 @@ function formatGitCommandResult(result) {
|
|
|
11451
11925
|
return lines.join("\n");
|
|
11452
11926
|
}
|
|
11453
11927
|
|
|
11928
|
+
function gitWorkflowMessagePreviewPath(message, key, fallback) {
|
|
11929
|
+
return normalizeDisplayPath(message?.[`${key}RelativePath`] || message?.[`${key}RepoRelativePath`] || fallback);
|
|
11930
|
+
}
|
|
11931
|
+
|
|
11454
11932
|
function formatCommitMessagePreview(message) {
|
|
11455
11933
|
if (!message) return "No commit message loaded yet.";
|
|
11456
|
-
|
|
11934
|
+
const shortPath = gitWorkflowMessagePreviewPath(message, "short", "dev/COMMIT/staged-commit-short.txt");
|
|
11935
|
+
const longPath = gitWorkflowMessagePreviewPath(message, "long", "dev/COMMIT/staged-commit-long.txt");
|
|
11936
|
+
return [`=== SHORT (${shortPath}) ===`, message.short || "(empty)", "", `=== LONG (${longPath}) ===`, message.long || "(empty)"].join("\n");
|
|
11457
11937
|
}
|
|
11458
11938
|
|
|
11459
11939
|
function formatInputCommitMessagePreview(message) {
|
|
@@ -11943,7 +12423,7 @@ function gitWorkflowTitle() {
|
|
|
11943
12423
|
case "generating": return "Waiting for /git-staged-msg";
|
|
11944
12424
|
case "message": return gitWorkflow.prMode ? "Choose PR branch commit message" : "Choose commit message";
|
|
11945
12425
|
case "branchNaming": return "Waiting for branch name";
|
|
11946
|
-
case "branching": return "
|
|
12426
|
+
case "branching": return "Opening PR branch worktree";
|
|
11947
12427
|
case "committing": return "Committing";
|
|
11948
12428
|
case "push": return gitWorkflow.prMode ? "Push branch and create PR" : "Push commit";
|
|
11949
12429
|
case "pushing": return "Pushing";
|
|
@@ -11978,11 +12458,11 @@ function gitWorkflowHint() {
|
|
|
11978
12458
|
case "add": return "Step 1: run git add . in the current Pi working directory.";
|
|
11979
12459
|
case "generate": return "Step 2: run /git-staged-msg, or type a commit message and use Commit input.";
|
|
11980
12460
|
case "generating": return "Pi is generating dev/COMMIT/staged-commit-short.txt and staged-commit-long.txt.";
|
|
11981
|
-
case "message": return gitWorkflow.prMode ? `
|
|
11982
|
-
case "branchNaming": return "Pi is generating dev/COMMIT/staged-branch-name.txt. Cancel will request Pi abort.";
|
|
11983
|
-
case "branching": return "Creating a
|
|
12461
|
+
case "message": return gitWorkflow.prMode ? `Worktree branch ${gitWorkflow.prBranch || "created"}: choose short, long, or typed input before opening a PR.` : "Step 3/4: preview the native g-msg output, type a commit message if needed, commit here, or create a PR branch worktree first.";
|
|
12462
|
+
case "branchNaming": return "Pi is generating dev/COMMIT/staged-branch-name.txt for a PR branch worktree. Cancel will request Pi abort.";
|
|
12463
|
+
case "branching": return "Creating or opening a branch worktree, copying staged changes, and switching to that tab before committing.";
|
|
11984
12464
|
case "committing": return "Running native git commit with the selected message.";
|
|
11985
|
-
case "push": return gitWorkflow.prMode ? "Push the PR branch, generate /pr, review the description, then create the pull request." : "Step 5: push the new commit to the configured remote.";
|
|
12465
|
+
case "push": return gitWorkflow.prMode ? "Push the PR worktree branch, generate /pr, review the description, then create the pull request." : "Step 5: push the new commit to the configured remote.";
|
|
11986
12466
|
case "pushing": return "Running git push. Cancel will request process termination.";
|
|
11987
12467
|
case "prGenerating": return "Pi is generating dev/PR/<current-branch>.md with /pr.";
|
|
11988
12468
|
case "prReview": return "Review or edit the generated PR description before creating the pull request.";
|
|
@@ -12100,8 +12580,8 @@ function renderGitWorkflow() {
|
|
|
12100
12580
|
addGitWorkflowAction("Refresh message preview", () => loadGitWorkflowMessage({ requireFresh: true }), "", false);
|
|
12101
12581
|
} else if (gitWorkflow.step === "message") {
|
|
12102
12582
|
if (!gitWorkflow.prMode) {
|
|
12103
|
-
addGitWorkflowAction("Create PR", () => createGitPrBranch(), "primary", false, GIT_WORKFLOW_CREATE_PR_TOOLTIP);
|
|
12104
|
-
addGitWorkflowAction("Manual
|
|
12583
|
+
addGitWorkflowAction("Create PR worktree", () => createGitPrBranch(), "primary", false, GIT_WORKFLOW_CREATE_PR_TOOLTIP);
|
|
12584
|
+
addGitWorkflowAction("Manual worktree", () => createGitPrBranchManually(), "", false, GIT_WORKFLOW_MANUAL_BRANCH_TOOLTIP);
|
|
12105
12585
|
}
|
|
12106
12586
|
const commitInputButton = renderGitWorkflowManualCommitInput({ appendCommitButton: false });
|
|
12107
12587
|
addGitWorkflowAction("Commit short", () => commitGitWorkflow("short"), gitWorkflow.prMode ? "primary" : "", false);
|
|
@@ -12110,9 +12590,9 @@ function renderGitWorkflow() {
|
|
|
12110
12590
|
elements.gitWorkflowActions.append(commitInputButton);
|
|
12111
12591
|
} else if (gitWorkflow.step === "branchNaming") {
|
|
12112
12592
|
addGitWorkflowAction("Refresh branch name", () => loadGitWorkflowBranchName({ requireFresh: true }), "", false);
|
|
12113
|
-
addGitWorkflowAction("Manual
|
|
12593
|
+
addGitWorkflowAction("Manual worktree", () => createGitPrBranchManually(), "", !!gitWorkflow.busy, GIT_WORKFLOW_MANUAL_BRANCH_TOOLTIP);
|
|
12114
12594
|
} else if (gitWorkflow.step === "branching") {
|
|
12115
|
-
addGitWorkflowAction("
|
|
12595
|
+
addGitWorkflowAction("Opening worktree…", () => {}, "primary", true);
|
|
12116
12596
|
} else if (gitWorkflow.step === "push") {
|
|
12117
12597
|
if (gitWorkflow.prMode) addGitWorkflowAction("Push and Create PR", () => pushAndCreatePrGitWorkflow(), "primary", false);
|
|
12118
12598
|
else addGitWorkflowAction("Run git push", () => pushGitWorkflow(), "primary", false);
|
|
@@ -12183,7 +12663,7 @@ function startGitWorkflow(tabId = activeTabId) {
|
|
|
12183
12663
|
step: "add",
|
|
12184
12664
|
process: "stage",
|
|
12185
12665
|
busy: false,
|
|
12186
|
-
output: "Ready to stage all changes with git add .\n\nNative mode is used for g-msg/g-short/g-long: dev/COMMIT message files are read directly and git commit is run without fish. In the Message stage you can also type a commit message and use Commit input. After the message is generated, use Create PR to
|
|
12666
|
+
output: "Ready to stage all changes with git add .\n\nNative mode is used for g-msg/g-short/g-long: dev/COMMIT message files are read directly and git commit is run without fish. In the Message stage you can also type a commit message and use Commit input. After the message is generated, use Create PR worktree to open a branch worktree before committing.",
|
|
12187
12667
|
error: "",
|
|
12188
12668
|
githubUsername: "",
|
|
12189
12669
|
repoName: "",
|
|
@@ -12733,26 +13213,89 @@ async function loadGitWorkflowBranchName({ requireFresh = false, retries = 0, ru
|
|
|
12733
13213
|
}
|
|
12734
13214
|
}
|
|
12735
13215
|
|
|
13216
|
+
function syncGitWorkflowWorktreeTabs(result) {
|
|
13217
|
+
if (Array.isArray(result?.tabs)) {
|
|
13218
|
+
tabs = result.tabs;
|
|
13219
|
+
syncTabMetadata(tabs);
|
|
13220
|
+
}
|
|
13221
|
+
if (result?.tab) applyTabMetadata(result.tab);
|
|
13222
|
+
renderTabs();
|
|
13223
|
+
}
|
|
13224
|
+
|
|
13225
|
+
function gitWorkflowWorktreeOutput(result, branch) {
|
|
13226
|
+
const prBranch = cleanStatusText(result?.branch || result?.tab?.gitWorkspace?.branch || branch);
|
|
13227
|
+
const worktreePath = result?.worktree?.path || result?.path || result?.tab?.cwd || "worktree";
|
|
13228
|
+
const copied = result?.carriedStagedChanges
|
|
13229
|
+
? "Staged changes were copied into the worktree index."
|
|
13230
|
+
: result?.openedExisting || result?.openedExistingTab
|
|
13231
|
+
? "Existing worktree opened; review its current changes before committing."
|
|
13232
|
+
: "Source index was clean; no staged changes were copied.";
|
|
13233
|
+
return `${formatGitCommandResult(result)}\n\nOpened PR branch worktree ${prBranch || branch} at ${normalizeDisplayPath(worktreePath)}. ${copied}\n\nChoose Commit short, Commit long, or Commit input to commit in this worktree tab.`;
|
|
13234
|
+
}
|
|
13235
|
+
|
|
12736
13236
|
async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowActionTabId(), expectedRunId) {
|
|
12737
13237
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
12738
13238
|
if (!workflow) return;
|
|
12739
|
-
const
|
|
13239
|
+
const sourceWorkflow = { ...workflow, actionsDone: createGitWorkflowActionsDone(workflow.actionsDone) };
|
|
13240
|
+
const proposedBranch = prompt("New PR branch worktree name (example: type/feature-name)", suggestion || defaultGitPrBranchName(workflow.message));
|
|
12740
13241
|
if (expectedRunId !== undefined && !isCurrentGitWorkflowRun(expectedRunId, tabId)) return;
|
|
12741
13242
|
if (proposedBranch === null) {
|
|
12742
|
-
setGitWorkflow({ step: "message", busy: false, output: `${formatCommitMessagePreview(
|
|
13243
|
+
setGitWorkflow({ step: "message", busy: false, output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nPR branch worktree creation cancelled. Use Create PR worktree to generate a branch name again or Manual worktree to type one.` }, { tabId });
|
|
12743
13244
|
return;
|
|
12744
13245
|
}
|
|
12745
13246
|
const branch = proposedBranch.trim();
|
|
12746
13247
|
if (!branch) {
|
|
12747
|
-
failGitWorkflow(new Error("Branch name is required to create a PR branch."), "message", { tabId });
|
|
13248
|
+
failGitWorkflow(new Error("Branch name is required to create a PR branch worktree."), "message", { tabId });
|
|
12748
13249
|
return;
|
|
12749
13250
|
}
|
|
12750
13251
|
const runId = workflow.runId;
|
|
12751
|
-
setGitWorkflow({ step: "branching", prMode: true, prBranch: branch, branchName: branch, busy: true, error: "", output: `${formatCommitMessagePreview(
|
|
13252
|
+
setGitWorkflow({ step: "branching", prMode: true, prBranch: branch, branchName: branch, busy: true, error: "", output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nCreating or opening branch worktree ${branch}…` }, { tabId });
|
|
12752
13253
|
try {
|
|
12753
|
-
const result = await gitWorkflowRequest("/api/git-workflow/branch", { body: { branch }, runId, tabId });
|
|
13254
|
+
const result = await gitWorkflowRequest("/api/git-workflow/branch", { body: { branch, sessionMode: "fork-current", openTab: true }, runId, tabId });
|
|
12754
13255
|
if (!result) return;
|
|
12755
|
-
|
|
13256
|
+
syncGitWorkflowWorktreeTabs(result);
|
|
13257
|
+
const targetTabId = result.tab?.id && tabs.some((tab) => tab.id === result.tab.id) ? result.tab.id : tabId;
|
|
13258
|
+
const prBranch = cleanStatusText(result.branch || result.tab?.gitWorkspace?.branch || branch);
|
|
13259
|
+
const output = gitWorkflowWorktreeOutput(result, prBranch || branch);
|
|
13260
|
+
const nextState = {
|
|
13261
|
+
active: true,
|
|
13262
|
+
mode: "standard",
|
|
13263
|
+
step: "message",
|
|
13264
|
+
process: "commit",
|
|
13265
|
+
busy: false,
|
|
13266
|
+
runId,
|
|
13267
|
+
output,
|
|
13268
|
+
error: "",
|
|
13269
|
+
githubUsername: "",
|
|
13270
|
+
repoName: "",
|
|
13271
|
+
remoteUrl: "",
|
|
13272
|
+
stack: "",
|
|
13273
|
+
readmeRequestedAt: 0,
|
|
13274
|
+
gitignoreRequestedAt: 0,
|
|
13275
|
+
initFilesStatus: null,
|
|
13276
|
+
message: sourceWorkflow.message,
|
|
13277
|
+
manualCommitMessage: sourceWorkflow.manualCommitMessage || "",
|
|
13278
|
+
manualCommitMessageDefault: sourceWorkflow.manualCommitMessageDefault || "",
|
|
13279
|
+
manualCommitMessageDefaultReason: sourceWorkflow.manualCommitMessageDefaultReason || "",
|
|
13280
|
+
manualCommitMessageDefaultPath: sourceWorkflow.manualCommitMessageDefaultPath || "",
|
|
13281
|
+
manualCommitMessageDefaultAction: sourceWorkflow.manualCommitMessageDefaultAction || "",
|
|
13282
|
+
manualCommitMessageDefaultRequestedAt: sourceWorkflow.manualCommitMessageDefaultRequestedAt || 0,
|
|
13283
|
+
manualCommitMessageDefaultLoading: false,
|
|
13284
|
+
messageRequestedAt: sourceWorkflow.messageRequestedAt || 0,
|
|
13285
|
+
branchName: prBranch || branch,
|
|
13286
|
+
branchNameRequestedAt: sourceWorkflow.branchNameRequestedAt || 0,
|
|
13287
|
+
actionsDone: createGitWorkflowActionsDone({ ...sourceWorkflow.actionsDone, branch: true }),
|
|
13288
|
+
prMode: true,
|
|
13289
|
+
prBranch: prBranch || branch,
|
|
13290
|
+
pr: null,
|
|
13291
|
+
prRequestedAt: 0,
|
|
13292
|
+
};
|
|
13293
|
+
if (targetTabId !== tabId) {
|
|
13294
|
+
setGitWorkflow({ step: "message", prMode: false, prBranch: "", branchName: prBranch || branch, busy: false, output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nOpened PR branch worktree ${prBranch || branch} in ${result.tab?.title || "a new tab"}. Continue the commit and PR flow there; this checkout stayed on its current branch.` }, { tabId });
|
|
13295
|
+
}
|
|
13296
|
+
setGitWorkflow(nextState, { tabId: targetTabId });
|
|
13297
|
+
if (targetTabId !== tabId) await switchTab(targetTabId);
|
|
13298
|
+
addEvent(`Opened PR branch worktree ${prBranch || branch}. Continue the guided Git workflow in its tab.`, "success");
|
|
12756
13299
|
} catch (error) {
|
|
12757
13300
|
if (isCurrentGitWorkflowRun(runId, tabId)) {
|
|
12758
13301
|
setGitWorkflow({ prMode: false, prBranch: "" }, { tabId });
|
|
@@ -12993,14 +13536,51 @@ function queueSummaryPill(label, count, tone) {
|
|
|
12993
13536
|
return pill;
|
|
12994
13537
|
}
|
|
12995
13538
|
|
|
12996
|
-
function
|
|
13539
|
+
async function removeQueuedFollowUpPrompt(index, message, tabId = activeTabId) {
|
|
13540
|
+
if (!tabId) return false;
|
|
13541
|
+
const tabContext = activeTabContext(tabId);
|
|
13542
|
+
try {
|
|
13543
|
+
const response = await api("/api/queue/remove", { method: "POST", body: { kind: "followUp", index, message }, tabId });
|
|
13544
|
+
const data = response?.data || {};
|
|
13545
|
+
if (data.queue && isCurrentTabContext(tabContext)) renderQueue({ tabId, ...data.queue });
|
|
13546
|
+
if (data.removed) {
|
|
13547
|
+
if (isCurrentTabContext(tabContext)) addEvent(`removed queued follow-up #${index + 1}`);
|
|
13548
|
+
scheduleRefreshState(120, tabContext);
|
|
13549
|
+
return true;
|
|
13550
|
+
}
|
|
13551
|
+
if (isCurrentTabContext(tabContext)) addEvent("queued follow-up changed before it could be removed; refreshed queue", "warn");
|
|
13552
|
+
scheduleRefreshState(120, tabContext);
|
|
13553
|
+
return false;
|
|
13554
|
+
} catch (error) {
|
|
13555
|
+
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
13556
|
+
return false;
|
|
13557
|
+
}
|
|
13558
|
+
}
|
|
13559
|
+
|
|
13560
|
+
function renderQueueGroup(label, items, tone, { removable = false, tabId } = {}) {
|
|
12997
13561
|
const group = make("section", `queue-group ${tone}`.trim());
|
|
12998
13562
|
const heading = make("h3", "queue-group-title");
|
|
12999
13563
|
heading.append(make("span", undefined, label), make("span", "queue-group-count", String(items.length)));
|
|
13000
13564
|
const list = make("ol", "queue-list");
|
|
13001
13565
|
items.forEach((item, index) => {
|
|
13002
|
-
const row = make("li",
|
|
13566
|
+
const row = make("li", `queue-item${removable ? " can-remove" : ""}`);
|
|
13003
13567
|
row.append(make("span", "queue-item-number", `#${index + 1}`), make("div", "queue-item-text", item));
|
|
13568
|
+
if (removable) {
|
|
13569
|
+
const removeButton = make("button", "queue-remove-button", "Remove");
|
|
13570
|
+
removeButton.type = "button";
|
|
13571
|
+
removeButton.title = `Remove queued follow-up #${index + 1}`;
|
|
13572
|
+
removeButton.setAttribute("aria-label", `Remove queued follow-up #${index + 1}`);
|
|
13573
|
+
removeButton.addEventListener("click", async () => {
|
|
13574
|
+
removeButton.disabled = true;
|
|
13575
|
+
removeButton.textContent = "Removing…";
|
|
13576
|
+
const removed = await removeQueuedFollowUpPrompt(index, item, tabId);
|
|
13577
|
+
if (!removed && removeButton.isConnected) {
|
|
13578
|
+
removeButton.disabled = false;
|
|
13579
|
+
removeButton.textContent = "Remove";
|
|
13580
|
+
}
|
|
13581
|
+
});
|
|
13582
|
+
row.append(removeButton);
|
|
13583
|
+
}
|
|
13004
13584
|
list.append(row);
|
|
13005
13585
|
});
|
|
13006
13586
|
group.append(heading, list);
|
|
@@ -13033,9 +13613,9 @@ function renderQueue(event) {
|
|
|
13033
13613
|
summary.append(counts);
|
|
13034
13614
|
|
|
13035
13615
|
elements.queueBox.append(summary);
|
|
13036
|
-
if (steering.length) elements.queueBox.append(renderQueueGroup("Steering", steering, "steering"));
|
|
13037
|
-
if (followUp.length) elements.queueBox.append(renderQueueGroup("Follow-up", followUp, "follow-up"));
|
|
13038
|
-
elements.queueBox.append(make("div", "queue-hint", "Alt+Up restores this queue snapshot to the composer
|
|
13616
|
+
if (steering.length) elements.queueBox.append(renderQueueGroup("Steering", steering, "steering", { tabId }));
|
|
13617
|
+
if (followUp.length) elements.queueBox.append(renderQueueGroup("Follow-up", followUp, "follow-up", { removable: true, tabId }));
|
|
13618
|
+
elements.queueBox.append(make("div", "queue-hint", "Alt+Up restores this queue snapshot to the composer without clearing Pi's queue. Use Remove beside follow-ups to drop them from the queue."));
|
|
13039
13619
|
updateStickyUserPromptButton();
|
|
13040
13620
|
}
|
|
13041
13621
|
|
|
@@ -16344,9 +16924,9 @@ async function refreshOptionalFeaturePackageStatuses({ announce = false } = {})
|
|
|
16344
16924
|
}
|
|
16345
16925
|
}
|
|
16346
16926
|
|
|
16347
|
-
function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force = false } = {}) {
|
|
16927
|
+
function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force = false, silent = true, allowDuringRun = false } = {}) {
|
|
16348
16928
|
if (!tabContext.tabId || isOptionalFeatureDisabled("gitFooterStatus")) return;
|
|
16349
|
-
if (currentState?.isStreaming || currentState?.isCompacting) return;
|
|
16929
|
+
if (!allowDuringRun && (currentState?.isStreaming || currentState?.isCompacting)) return;
|
|
16350
16930
|
const refreshCommand = resolveAvailableCommandName("git-footer-refresh", { rpcOnly: true });
|
|
16351
16931
|
if (!refreshCommand || (!force && statusEntries.has(GIT_FOOTER_WEBUI_STATUS_KEY))) return;
|
|
16352
16932
|
if (gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId)) return;
|
|
@@ -16355,7 +16935,7 @@ function requestGitFooterWebuiPayload(tabContext = activeTabContext(), { force =
|
|
|
16355
16935
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
16356
16936
|
api("/api/prompt", {
|
|
16357
16937
|
method: "POST",
|
|
16358
|
-
body: { message: `/${refreshCommand} --webui-silent`, streamingBehavior: "steer" },
|
|
16938
|
+
body: { message: `/${refreshCommand}${silent ? " --webui-silent" : ""}`, streamingBehavior: "steer" },
|
|
16359
16939
|
tabId: tabContext.tabId,
|
|
16360
16940
|
}).catch((error) => {
|
|
16361
16941
|
if (isCurrentTabContext(tabContext)) addEvent(`git footer payload refresh failed: ${error.message || String(error)}`, "warn");
|
|
@@ -18972,6 +19552,7 @@ function commandPaletteCoreItems() {
|
|
|
18972
19552
|
const items = [
|
|
18973
19553
|
{ kind: "Action", label: "New tab", description: "Start an isolated Pi terminal in the current directory", keywords: "workspace session", run: () => createTerminalTab() },
|
|
18974
19554
|
{ kind: "Action", label: "Choose directory for new tab", description: "Pick a cwd before starting a tab", keywords: "cwd folder workspace", run: () => createTerminalTabFromChosenDirectory({ triggerButton: elements.commandPaletteButton }) },
|
|
19555
|
+
{ kind: "Git", label: "Branch worktree", description: "Create or open a Git worktree tab for parallel branch work", keywords: "git branch worktree parallel checkout", run: () => openBranchWorktreePicker() },
|
|
18975
19556
|
{ kind: "Action", label: "New session", description: "Start a fresh session in the active tab", keywords: "/new clear", run: () => elements.newSessionButton.click() },
|
|
18976
19557
|
{ kind: "Action", label: "Compact context", description: contextUsageDetail(), keywords: "/compact context window tokens", run: () => requestManualCompaction() },
|
|
18977
19558
|
{ kind: "Action", label: footerAutoCompactionEnabled() ? "Disable auto-compaction" : "Enable auto-compaction", description: footerAutoCompactionToggleAction(), keywords: "context automatic", run: () => toggleFooterAutoCompaction() },
|
|
@@ -19879,12 +20460,14 @@ function handleEvent(event) {
|
|
|
19879
20460
|
setAppRunnerData(event.tabId || activeTabId, { cwd: event.cwd, activeRun: event.activeRun });
|
|
19880
20461
|
renderAppRunnerControls();
|
|
19881
20462
|
renderWidgets();
|
|
20463
|
+
renderTabs();
|
|
19882
20464
|
break;
|
|
19883
20465
|
case "webui_cwd_changed":
|
|
19884
20466
|
addEvent(`${event.tabTitle || "terminal"} cwd changed to ${event.cwd}`);
|
|
19885
20467
|
setAppRunnerData(event.tabId || activeTabId, { cwd: event.cwd, activeRun: null, runners: [] });
|
|
19886
20468
|
renderAppRunnerControls();
|
|
19887
20469
|
renderWidgets();
|
|
20470
|
+
renderTabs();
|
|
19888
20471
|
refreshTabs().catch((error) => addEvent(error.message, "error"));
|
|
19889
20472
|
refreshAppRunners(tabContext).catch((error) => addEvent(error.message, "error"));
|
|
19890
20473
|
scheduleRefreshFooter();
|
|
@@ -20250,6 +20833,7 @@ elements.newTabMenu?.addEventListener("focusout", () => {
|
|
|
20250
20833
|
});
|
|
20251
20834
|
elements.newTabCurrentDirectoryButton?.addEventListener("click", () => createTerminalTab(currentDirectoryForNewTab(), { triggerButton: elements.newTabCurrentDirectoryButton }));
|
|
20252
20835
|
elements.newTabChooseDirectoryButton?.addEventListener("click", () => createTerminalTabFromChosenDirectory({ triggerButton: elements.newTabChooseDirectoryButton }));
|
|
20836
|
+
elements.newTabWorktreeButton?.addEventListener("click", () => openBranchWorktreePicker());
|
|
20253
20837
|
elements.closeAllTabsButton.addEventListener("click", () => closeAllTerminalTabs());
|
|
20254
20838
|
elements.commandPaletteButton?.addEventListener("click", () => openCommandPalette());
|
|
20255
20839
|
elements.workspaceDashboardToggleButton?.addEventListener("click", () => setWorkspaceDashboardCollapsed(!workspaceDashboardCollapsed));
|
|
@@ -21335,6 +21919,7 @@ restoreTerminalTabsLayoutSetting();
|
|
|
21335
21919
|
restoreTerminalCustomGroups();
|
|
21336
21920
|
restoreToolOutputExpansionSetting();
|
|
21337
21921
|
restoreWorkspaceDashboardState();
|
|
21922
|
+
initializeTerminalHeaderTooltips();
|
|
21338
21923
|
restoreSidePanelSectionState();
|
|
21339
21924
|
bindSidePanelSectionToggles();
|
|
21340
21925
|
restoreSidePanelState();
|