@firstpick/pi-package-webui 0.9.7 → 0.9.9
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/DEVELOPMENT.md +882 -0
- package/README.md +8 -4
- package/TECHNICAL.md +415 -0
- package/bin/pi-webui.mjs +154 -26
- package/index.ts +2 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/windows-drive-roots.mjs +114 -0
- package/package.json +3 -1
- package/public/app.js +683 -115
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +17 -10
- package/public/service-worker.js +1 -1
- package/public/styles.css +146 -32
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/footer-model-advanced-layout.spec.mjs +512 -0
- package/tests/browser/guided-git-extension-command.spec.mjs +180 -0
- package/tests/browser/guided-git-fallback.spec.mjs +68 -3
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/browser/windows-drive-parent.spec.mjs +198 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compaction-static.test.mjs +1 -1
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +34 -3
- package/tests/git-footer-context-menu-static.test.mjs +103 -1
- package/tests/guided-git-activation-http.test.mjs +194 -0
- package/tests/guided-git-activation-static.test.mjs +80 -0
- package/tests/guided-git-activation.test.mjs +244 -0
- package/tests/guided-git-fallback-runtime.test.mjs +1 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
- package/tests/guided-git-message-reliability-static.test.mjs +2 -1
- package/tests/guided-git-optional-feature.test.mjs +31 -0
- package/tests/http-endpoints-harness.test.mjs +3 -0
- package/tests/interaction-state-stability-static.test.mjs +1 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
- package/tests/main-output-loading-static.test.mjs +11 -9
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +85 -4
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +6 -6
- package/tests/prompt-routing-input-clear-static.test.mjs +1 -1
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +2 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/tests/windows-drive-cwd-picker-static.test.mjs +81 -0
- package/tests/windows-drive-roots.test.mjs +130 -0
package/public/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aurReviewSafePath as parsedAurReviewSafePath, parseAurReviewPayload as parseValidatedAurReviewPayload } from "./aur-review-payload.mjs";
|
|
2
|
-
import { guidedGitReviewAvailableForTabCatalog, resolveCommandForTabCatalog, resolveRpcSlashCommandForTabCatalog } from "./guided-git-command-state.mjs";
|
|
2
|
+
import { GUIDED_GIT_START_STATUS_KEY, createGuidedGitActivationController, createGuidedGitLaunchPermitController, guidedGitLaunchBlockedReason, guidedGitLaunchModeForTabCatalog, guidedGitReviewAvailableForTabCatalog, guidedGitWorkflowCommandForTabCatalog, resolveCommandForTabCatalog, resolveRpcSlashCommandForTabCatalog } from "./guided-git-command-state.mjs";
|
|
3
3
|
import { guidedGitReviewCanRequestStagedContent, guidedGitReviewHasApprovedBinding, guidedGitReviewProcessNavigationAllowed, guidedGitReviewProcessSelectionPatch, guidedGitReviewTransition, guidedGitReviewWidgetRemovalTransition } from "./guided-git-review-state.mjs";
|
|
4
4
|
import { createFastOutputLiveState, createSustainedFlushScheduler, fastOutputLiveTextAndThinking, reduceFastOutputLiveEvent, seedFastOutputLiveState, shouldConsumeFastOutputLiveEvent } from "./fast-output-live.mjs";
|
|
5
5
|
import { addLaunchSlot, cloneLaunchSlotRoles, launchSlotRolesEqual, removeLaunchSlot, subagentLaunchSlotSaveState, updateLaunchSlot } from "./subagent-launch-slot-state.mjs";
|
|
@@ -8,7 +8,7 @@ import { groupConsecutiveWorkflowStatusItems, isCompletedWorkflowStatusExecution
|
|
|
8
8
|
import { buildIssuePayload, createIssueWizardCatalog, createIssueWizardState, getCompatibleTemplates, isIssueWizardStepValid, issueClipboardText, reduceIssueWizardState } from "./issue-wizard-state.mjs";
|
|
9
9
|
import { createIssueBotClient, readIssueBotRuntimeConfig } from "./issue-bot-client.mjs";
|
|
10
10
|
import { MOBILE_SHELL_STORAGE_KEY, TABLET_SHELL_STORAGE_KEY, createMobileShellState, isMobileShellV2Enabled, mobileNavigationTargetFromSearch, normalizeMobileNavigationTarget, reduceMobileShellState, resolveMobileShellFeatureMode, resolveTabletShellFeatureMode } from "./mobile-shell-state.mjs";
|
|
11
|
-
import { createTranscriptRenderer } from "./transcript-renderer.mjs";
|
|
11
|
+
import { createTranscriptRenderer, groupConsecutiveThinkingItems, groupConsecutiveThinkingMessages } from "./transcript-renderer.mjs";
|
|
12
12
|
import { createStreamDerivedOutputState } from "./stream-derived-output.mjs";
|
|
13
13
|
import { advanceStreamingMarkdownTail } from "./stream-markdown-tail.mjs";
|
|
14
14
|
import { createLatestWinsRenderScheduler } from "./stream-render-scheduler.mjs";
|
|
@@ -541,6 +541,8 @@ const elements = {
|
|
|
541
541
|
pathPickerTitle: $("#pathPickerTitle"),
|
|
542
542
|
pathPickerCurrent: $("#pathPickerCurrent"),
|
|
543
543
|
pathPickerAddFastPickButton: $("#pathPickerAddFastPickButton"),
|
|
544
|
+
pathPickerPathInput: $("#pathPickerPathInput"),
|
|
545
|
+
pathPickerPathButton: $("#pathPickerPathButton"),
|
|
544
546
|
pathPickerCreateNameInput: $("#pathPickerCreateNameInput"),
|
|
545
547
|
pathPickerCreateButton: $("#pathPickerCreateButton"),
|
|
546
548
|
pathPickerSearchInput: $("#pathPickerSearchInput"),
|
|
@@ -1086,6 +1088,7 @@ let gitChangesRequestSerial = 0;
|
|
|
1086
1088
|
const gitChangesUntrackedContentRequests = new Set();
|
|
1087
1089
|
let nativeCommandTabId = null;
|
|
1088
1090
|
let nativeSettingsDirty = false;
|
|
1091
|
+
let guidedGitSetupDialogOwner = null;
|
|
1089
1092
|
let sessionSummaryOverlayTabId = null;
|
|
1090
1093
|
let sessionSummaryOverlayFocusReturn = null;
|
|
1091
1094
|
let sessionSummaryOverlayFocusReturnKey = "";
|
|
@@ -1278,6 +1281,7 @@ let customBackgroundLoading = false;
|
|
|
1278
1281
|
let footerScopedModels = [];
|
|
1279
1282
|
let footerScopedModelPatterns = [];
|
|
1280
1283
|
let footerScopedModelSource = "none";
|
|
1284
|
+
let footerScopedModelLayout = "flat";
|
|
1281
1285
|
const contextUsageUnknownAfterCompactionByTab = new Map();
|
|
1282
1286
|
let autoFollowChat = true;
|
|
1283
1287
|
let chatFollowFrame = null;
|
|
@@ -1291,6 +1295,7 @@ let chatPausedScrollRestoreUntil = 0;
|
|
|
1291
1295
|
let chatLastTouchClientY = null;
|
|
1292
1296
|
let mobileFooterExpanded = false;
|
|
1293
1297
|
let footerModelPickerOpen = false;
|
|
1298
|
+
let footerModelApplyInFlight = false;
|
|
1294
1299
|
let footerThinkingPickerOpen = false;
|
|
1295
1300
|
let footerAutoCompactionToggleInFlight = false;
|
|
1296
1301
|
let footerBranchPickerOpen = false;
|
|
@@ -1369,6 +1374,8 @@ const SUBAGENT_AUTO_CLEAR_STORAGE_KEY = "pi-webui-subagent-auto-clear";
|
|
|
1369
1374
|
const TERMINAL_CUSTOM_GROUPS_STORAGE_KEY = "pi-webui-terminal-custom-groups-v1";
|
|
1370
1375
|
const TERMINAL_TAB_DRAG_MIME = "application/x-pi-terminal-tab-id";
|
|
1371
1376
|
const FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY = "pi-webui-footer-scoped-model-order-v1";
|
|
1377
|
+
const FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY = "pi-webui-footer-scoped-model-layout-v1";
|
|
1378
|
+
footerScopedModelLayout = readStoredFooterScopedModelLayout();
|
|
1372
1379
|
const FOOTER_SCOPED_MODEL_POINTER_DRAG_THRESHOLD_PX = 6;
|
|
1373
1380
|
const TOOL_OUTPUT_EXPANDED_STORAGE_KEY = "pi-webui-tool-output-expanded";
|
|
1374
1381
|
const THEME_STORAGE_KEY = "pi-webui-theme";
|
|
@@ -2819,9 +2826,9 @@ const OPTIONAL_FEATURES = [
|
|
|
2819
2826
|
{
|
|
2820
2827
|
id: "gitWorkflow",
|
|
2821
2828
|
label: "Guided Git workflow",
|
|
2822
|
-
packageName: "@firstpick/pi-
|
|
2823
|
-
capabilityLabel: "/git-
|
|
2824
|
-
description: "
|
|
2829
|
+
packageName: "@firstpick/pi-extension-git-guided-workflow",
|
|
2830
|
+
capabilityLabel: "/git-guided-workflow",
|
|
2831
|
+
description: "Cross-surface launcher with bundled commit, branch, and pull-request prompt templates.",
|
|
2825
2832
|
setup: "git-workflow",
|
|
2826
2833
|
},
|
|
2827
2834
|
{
|
|
@@ -3370,6 +3377,7 @@ const OPTIONAL_COMMAND_FEATURES = new Map([
|
|
|
3370
3377
|
["btw", "btwCommand"],
|
|
3371
3378
|
["btw-transfer", "btwCommand"],
|
|
3372
3379
|
["btw-status", "btwCommand"],
|
|
3380
|
+
["git-guided-workflow", "gitWorkflow"],
|
|
3373
3381
|
["git-staged-msg", "gitWorkflow"],
|
|
3374
3382
|
["git-branch-name", "gitWorkflow"],
|
|
3375
3383
|
["pr", "gitWorkflow"],
|
|
@@ -3560,6 +3568,10 @@ function createGitWorkflowState() {
|
|
|
3560
3568
|
|
|
3561
3569
|
const gitWorkflowsByTab = new Map();
|
|
3562
3570
|
const gitWorkflowMessageLoadsByTab = new Map();
|
|
3571
|
+
const guidedGitLaunchPermits = createGuidedGitLaunchPermitController();
|
|
3572
|
+
const guidedGitActivationController = createGuidedGitActivationController({
|
|
3573
|
+
claimStart: (tabId, _payload, request, now) => guidedGitLaunchPermits.consume(tabId, request?.guidedGitLaunchId, now),
|
|
3574
|
+
});
|
|
3563
3575
|
let gitWorkflow = createGitWorkflowState();
|
|
3564
3576
|
let gitWorkflowPreferences = null;
|
|
3565
3577
|
|
|
@@ -3584,6 +3596,8 @@ function gitWorkflowActionTabId() {
|
|
|
3584
3596
|
|
|
3585
3597
|
function resetGitWorkflowForTab(tabId = activeTabId) {
|
|
3586
3598
|
if (!tabId) return;
|
|
3599
|
+
guidedGitLaunchPermits.clearTab(tabId);
|
|
3600
|
+
guidedGitActivationController.clearTab(tabId);
|
|
3587
3601
|
gitWorkflowsByTab.set(tabId, createGitWorkflowState());
|
|
3588
3602
|
if (tabId === activeTabId) {
|
|
3589
3603
|
bindGitWorkflowToActiveTab();
|
|
@@ -3593,6 +3607,8 @@ function resetGitWorkflowForTab(tabId = activeTabId) {
|
|
|
3593
3607
|
|
|
3594
3608
|
function clearGitWorkflowForTab(tabId) {
|
|
3595
3609
|
if (!tabId) return;
|
|
3610
|
+
guidedGitLaunchPermits.clearTab(tabId);
|
|
3611
|
+
guidedGitActivationController.clearTab(tabId);
|
|
3596
3612
|
gitWorkflowsByTab.delete(tabId);
|
|
3597
3613
|
if (tabId === activeTabId) {
|
|
3598
3614
|
bindGitWorkflowToActiveTab();
|
|
@@ -7449,10 +7465,13 @@ function isAbortAvailable() {
|
|
|
7449
7465
|
function resizePromptInput() {
|
|
7450
7466
|
const input = elements.promptInput;
|
|
7451
7467
|
input.style.height = "auto";
|
|
7452
|
-
const
|
|
7453
|
-
const
|
|
7454
|
-
|
|
7455
|
-
input.
|
|
7468
|
+
const style = getComputedStyle(input);
|
|
7469
|
+
const maxHeight = Number.parseFloat(style.maxHeight);
|
|
7470
|
+
const borderBlock = Number.parseFloat(style.borderTopWidth) + Number.parseFloat(style.borderBottomWidth);
|
|
7471
|
+
const naturalHeight = input.scrollHeight + borderBlock;
|
|
7472
|
+
const isCapped = Number.isFinite(maxHeight) && naturalHeight > Math.ceil(maxHeight);
|
|
7473
|
+
input.style.height = `${Math.ceil(isCapped ? maxHeight : naturalHeight)}px`;
|
|
7474
|
+
input.style.overflowY = isCapped ? "auto" : "hidden";
|
|
7456
7475
|
}
|
|
7457
7476
|
|
|
7458
7477
|
function updateComposerModeButtons() {
|
|
@@ -17813,7 +17832,7 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", all
|
|
|
17813
17832
|
} else {
|
|
17814
17833
|
renderTabs();
|
|
17815
17834
|
}
|
|
17816
|
-
addEvent(`closed ${closedIds.length || targetTabs.length} terminal ${closedIds.length === 1 ? "tab" : "tabs"}`, "
|
|
17835
|
+
addEvent(`closed ${closedIds.length || targetTabs.length} terminal ${closedIds.length === 1 ? "tab" : "tabs"}`, "info");
|
|
17817
17836
|
} catch (error) {
|
|
17818
17837
|
addEvent(error.message, "error");
|
|
17819
17838
|
} finally {
|
|
@@ -18091,11 +18110,26 @@ function setEventDisplayMode(value, { persist = true } = {}) {
|
|
|
18091
18110
|
}
|
|
18092
18111
|
}
|
|
18093
18112
|
|
|
18094
|
-
function addEvent(message, level = "info", { toolCallId = "", toolEventPhase = "", details = [], notify = true, occurredAt = Date.now() } = {}) {
|
|
18113
|
+
function addEvent(message, level = "info", { toolCallId = "", toolEventPhase = "", details = [], notify = true, occurredAt = Date.now(), aggregateKey = "", aggregateIncrement = 1, aggregateSingular = "", aggregatePlural = "" } = {}) {
|
|
18114
|
+
const stableAggregateKey = String(aggregateKey || "").trim();
|
|
18115
|
+
const priorAggregate = stableAggregateKey
|
|
18116
|
+
? [...(elements.eventLog?.children || [])].find((candidate) => candidate.dataset.eventAggregateKey === stableAggregateKey)
|
|
18117
|
+
: null;
|
|
18118
|
+
const aggregateCount = stableAggregateKey
|
|
18119
|
+
? Math.max(0, Number.parseInt(priorAggregate?.dataset.eventAggregateCount || "0", 10) || 0) + Math.max(1, Math.trunc(Number(aggregateIncrement) || 1))
|
|
18120
|
+
: 0;
|
|
18121
|
+
const eventMessage = stableAggregateKey && aggregateSingular
|
|
18122
|
+
? `${message} ${aggregateCount} ${aggregateCount === 1 ? aggregateSingular : aggregatePlural || aggregateSingular}`
|
|
18123
|
+
: String(message || "");
|
|
18124
|
+
priorAggregate?.remove();
|
|
18095
18125
|
const line = make("button", `event ${level}`.trim());
|
|
18096
18126
|
line.type = "button";
|
|
18097
18127
|
line.dataset.eventLevel = String(level || "info").trim().toLowerCase() || "info";
|
|
18098
18128
|
line.dataset.chatEventTimestamp = String(occurredAt);
|
|
18129
|
+
if (stableAggregateKey) {
|
|
18130
|
+
line.dataset.eventAggregateKey = stableAggregateKey;
|
|
18131
|
+
line.dataset.eventAggregateCount = String(aggregateCount);
|
|
18132
|
+
}
|
|
18099
18133
|
const stableToolCallId = String(toolCallId || "").trim();
|
|
18100
18134
|
const toolLifecycle = ["start", "finish"].includes(toolEventPhase);
|
|
18101
18135
|
const treeEligible = stableToolCallId && toolLifecycle;
|
|
@@ -18104,7 +18138,7 @@ function addEvent(message, level = "info", { toolCallId = "", toolEventPhase = "
|
|
|
18104
18138
|
if (toolLifecycle) line.dataset.eventToolPhase = toolEventPhase;
|
|
18105
18139
|
line.setAttribute("aria-keyshortcuts", "ContextMenu Shift+F10");
|
|
18106
18140
|
const time = make("span", "event-time", `[${new Date(occurredAt).toLocaleTimeString()}]`);
|
|
18107
|
-
const summary = make("span", "event-summary",
|
|
18141
|
+
const summary = make("span", "event-summary", eventMessage);
|
|
18108
18142
|
const main = make("span", "event-main");
|
|
18109
18143
|
main.append(time, summary);
|
|
18110
18144
|
line.append(main);
|
|
@@ -18126,7 +18160,7 @@ function addEvent(message, level = "info", { toolCallId = "", toolEventPhase = "
|
|
|
18126
18160
|
while (elements.eventLog.children.length > 120) elements.eventLog.lastElementChild?.remove();
|
|
18127
18161
|
applyEventFilter();
|
|
18128
18162
|
if (notify && (level === "error" || level === "warn")) {
|
|
18129
|
-
showNoticeToast(
|
|
18163
|
+
showNoticeToast(eventMessage, level);
|
|
18130
18164
|
noteUnreadEvent();
|
|
18131
18165
|
}
|
|
18132
18166
|
}
|
|
@@ -19775,6 +19809,14 @@ function closeGitFooterContextMenu({ returnFocus = true } = {}) {
|
|
|
19775
19809
|
if (returnFocus && trigger?.isConnected) queueMicrotask(() => trigger.focus?.({ preventScroll: true }));
|
|
19776
19810
|
}
|
|
19777
19811
|
|
|
19812
|
+
function syncGitFooterAdvancedMenuItem(key = gitFooterContextMenuState?.key) {
|
|
19813
|
+
const advancedButton = elements.gitFooterContextMenu?.querySelector('[data-git-footer-menu-action="toggle-advanced"]');
|
|
19814
|
+
if (!advancedButton) return;
|
|
19815
|
+
advancedButton.hidden = key !== "model";
|
|
19816
|
+
advancedButton.textContent = footerScopedModelLayout === "advanced" ? "Toggle Simple" : "Toggle advanced";
|
|
19817
|
+
advancedButton.setAttribute("aria-checked", footerScopedModelLayout === "advanced" ? "true" : "false");
|
|
19818
|
+
}
|
|
19819
|
+
|
|
19778
19820
|
function showGitFooterContextMenu(event, chip, trigger) {
|
|
19779
19821
|
const menu = elements.gitFooterContextMenu;
|
|
19780
19822
|
const key = cleanStatusText(chip?.key);
|
|
@@ -19792,6 +19834,7 @@ function showGitFooterContextMenu(event, chip, trigger) {
|
|
|
19792
19834
|
gitFooterContextMenuState = { key, label, trigger };
|
|
19793
19835
|
const disableButton = menu.querySelector('[data-git-footer-menu-action="disable"]');
|
|
19794
19836
|
if (disableButton) disableButton.textContent = `Disable ${label} box`;
|
|
19837
|
+
syncGitFooterAdvancedMenuItem(key);
|
|
19795
19838
|
menu.hidden = false;
|
|
19796
19839
|
const rect = menu.getBoundingClientRect();
|
|
19797
19840
|
const left = Math.min(event.clientX, Math.max(8, window.innerWidth - rect.width - 8));
|
|
@@ -20625,13 +20668,18 @@ function footerBranchPickerRenderKey() {
|
|
|
20625
20668
|
return footerBranchPickerOpen ? JSON.stringify(footerBranchPickerState) : "";
|
|
20626
20669
|
}
|
|
20627
20670
|
|
|
20671
|
+
function footerModelPickerRenderKey() {
|
|
20672
|
+
if (!footerModelPickerOpen) return "";
|
|
20673
|
+
return `${footerScopedModelLayout}:${orderedFooterScopedModels().map(footerScopedModelKey).join(",")}`;
|
|
20674
|
+
}
|
|
20675
|
+
|
|
20628
20676
|
function gitFooterPickerStateKey(payload) {
|
|
20629
20677
|
const tabContext = activeTabContext();
|
|
20630
20678
|
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
20631
20679
|
const syncInFlight = tabContext.tabId ? gitFooterSyncInFlightByTab.has(tabContext.tabId) : false;
|
|
20632
20680
|
const piCalibrationInFlight = tabContext.tabId ? gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId) : false;
|
|
20633
20681
|
const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
|
|
20634
|
-
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${footerBranchPickerRenderKey()}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncInFlight ? 1 : 0}|${piCalibrationInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}|${gitFooterPayloadVisibilityKey(payload)}`;
|
|
20682
|
+
return `${footerModelPickerOpen ? 1 : 0}|${footerModelPickerRenderKey()}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${footerBranchPickerRenderKey()}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncInFlight ? 1 : 0}|${piCalibrationInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}|${gitFooterPayloadVisibilityKey(payload)}`;
|
|
20635
20683
|
}
|
|
20636
20684
|
|
|
20637
20685
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
@@ -22924,7 +22972,7 @@ function renderSavedWorkspacePicker() {
|
|
|
22924
22972
|
return panel;
|
|
22925
22973
|
}
|
|
22926
22974
|
|
|
22927
|
-
function setFooterModelPickerOpen(open) {
|
|
22975
|
+
function setFooterModelPickerOpen(open, { restoreFocus = false } = {}) {
|
|
22928
22976
|
const wasOpen = footerModelPickerOpen;
|
|
22929
22977
|
footerModelPickerOpen = !!open;
|
|
22930
22978
|
if (footerModelPickerOpen) {
|
|
@@ -22941,7 +22989,11 @@ function setFooterModelPickerOpen(open) {
|
|
|
22941
22989
|
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
22942
22990
|
renderFooter();
|
|
22943
22991
|
updateFooterModelPickerPosition();
|
|
22944
|
-
if (
|
|
22992
|
+
if (footerModelPickerOpen && footerScopedModelLayout === "advanced") focusFooterModelPickerInitialOption();
|
|
22993
|
+
if (wasOpen && !footerModelPickerOpen) {
|
|
22994
|
+
scheduleDeferredUiFlushAfterDropdownClose();
|
|
22995
|
+
if (restoreFocus) focusFooterModelTrigger();
|
|
22996
|
+
}
|
|
22945
22997
|
}
|
|
22946
22998
|
|
|
22947
22999
|
function setFooterThinkingPickerOpen(open) {
|
|
@@ -23794,6 +23846,55 @@ function footerScopedModelKey(model) {
|
|
|
23794
23846
|
return model?.provider && model?.id ? `${model.provider}/${model.id}` : "";
|
|
23795
23847
|
}
|
|
23796
23848
|
|
|
23849
|
+
function normalizeFooterScopedModelLayout(value) {
|
|
23850
|
+
return value === "advanced" ? "advanced" : "flat";
|
|
23851
|
+
}
|
|
23852
|
+
|
|
23853
|
+
function readStoredFooterScopedModelLayout() {
|
|
23854
|
+
try {
|
|
23855
|
+
return normalizeFooterScopedModelLayout(localStorage.getItem(FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY));
|
|
23856
|
+
} catch {
|
|
23857
|
+
return "flat";
|
|
23858
|
+
}
|
|
23859
|
+
}
|
|
23860
|
+
|
|
23861
|
+
function setFooterScopedModelLayout(value, { persist = true } = {}) {
|
|
23862
|
+
const next = normalizeFooterScopedModelLayout(value);
|
|
23863
|
+
if (persist) {
|
|
23864
|
+
try {
|
|
23865
|
+
localStorage.setItem(FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY, next);
|
|
23866
|
+
} catch {}
|
|
23867
|
+
}
|
|
23868
|
+
const changed = next !== footerScopedModelLayout;
|
|
23869
|
+
footerScopedModelLayout = next;
|
|
23870
|
+
syncGitFooterAdvancedMenuItem();
|
|
23871
|
+
if (!changed || !footerModelPickerOpen) return;
|
|
23872
|
+
renderFooter();
|
|
23873
|
+
updateFooterModelPickerPosition();
|
|
23874
|
+
focusFooterModelPickerInitialOption();
|
|
23875
|
+
}
|
|
23876
|
+
|
|
23877
|
+
function toggleFooterScopedModelLayout() {
|
|
23878
|
+
setFooterScopedModelLayout(footerScopedModelLayout === "advanced" ? "flat" : "advanced");
|
|
23879
|
+
}
|
|
23880
|
+
|
|
23881
|
+
function compareFooterScopedModelProviders(a, b) {
|
|
23882
|
+
const baseOrder = String(a).localeCompare(String(b), undefined, { sensitivity: "base" });
|
|
23883
|
+
return baseOrder || String(a).localeCompare(String(b));
|
|
23884
|
+
}
|
|
23885
|
+
|
|
23886
|
+
function footerScopedModelProviderGroups(models = orderedFooterScopedModels()) {
|
|
23887
|
+
const modelsByProvider = new Map();
|
|
23888
|
+
for (const model of models) {
|
|
23889
|
+
const provider = String(model?.provider || "");
|
|
23890
|
+
if (!modelsByProvider.has(provider)) modelsByProvider.set(provider, []);
|
|
23891
|
+
modelsByProvider.get(provider).push(model);
|
|
23892
|
+
}
|
|
23893
|
+
return [...modelsByProvider.entries()]
|
|
23894
|
+
.sort(([a], [b]) => compareFooterScopedModelProviders(a, b))
|
|
23895
|
+
.map(([provider, providerModels]) => ({ provider, models: providerModels }));
|
|
23896
|
+
}
|
|
23897
|
+
|
|
23797
23898
|
function readFooterScopedModelOrder() {
|
|
23798
23899
|
try {
|
|
23799
23900
|
const parsed = JSON.parse(localStorage.getItem(FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY) || "[]");
|
|
@@ -23821,14 +23922,30 @@ function orderedFooterScopedModels() {
|
|
|
23821
23922
|
});
|
|
23822
23923
|
}
|
|
23823
23924
|
|
|
23925
|
+
function focusFooterScopedModelOrderButton(modelKey) {
|
|
23926
|
+
if (!modelKey) return;
|
|
23927
|
+
const movedButton = document.querySelector(`[data-footer-model-key="${CSS.escape(modelKey)}"]`);
|
|
23928
|
+
if (!movedButton) return;
|
|
23929
|
+
const advancedPicker = movedButton.closest(".footer-model-picker-advanced");
|
|
23930
|
+
if (advancedPicker) focusAdvancedFooterModelOption(advancedPicker, movedButton);
|
|
23931
|
+
else movedButton.focus();
|
|
23932
|
+
}
|
|
23933
|
+
|
|
23934
|
+
function rebuildOpenFooterModelPicker() {
|
|
23935
|
+
const picker = elements.statusBar.querySelector(".footer-model-picker");
|
|
23936
|
+
if (!footerModelPickerOpen || !picker) {
|
|
23937
|
+
renderFooter();
|
|
23938
|
+
return;
|
|
23939
|
+
}
|
|
23940
|
+
picker.replaceWith(renderFooterModelPicker());
|
|
23941
|
+
updateFooterModelPickerPosition();
|
|
23942
|
+
}
|
|
23943
|
+
|
|
23824
23944
|
function commitFooterScopedModelOrder(order, { render = true, focusKey = "" } = {}) {
|
|
23825
23945
|
writeFooterScopedModelOrder(order);
|
|
23826
23946
|
footerScopedModels = orderedFooterScopedModels();
|
|
23827
|
-
if (render)
|
|
23828
|
-
|
|
23829
|
-
const movedButton = document.querySelector(`[data-footer-model-key="${CSS.escape(focusKey)}"]`);
|
|
23830
|
-
if (movedButton) movedButton.focus();
|
|
23831
|
-
}
|
|
23947
|
+
if (render) rebuildOpenFooterModelPicker();
|
|
23948
|
+
focusFooterScopedModelOrderButton(focusKey);
|
|
23832
23949
|
}
|
|
23833
23950
|
|
|
23834
23951
|
function reorderFooterScopedModel(fromKey, toKey, { focus = true } = {}) {
|
|
@@ -23854,6 +23971,50 @@ function moveFooterScopedModelByOffset(modelKey, offset) {
|
|
|
23854
23971
|
return true;
|
|
23855
23972
|
}
|
|
23856
23973
|
|
|
23974
|
+
function footerScopedModelOrderWithProviderOrder(provider, providerOrder) {
|
|
23975
|
+
const models = orderedFooterScopedModels();
|
|
23976
|
+
const providerKeys = models
|
|
23977
|
+
.filter((model) => String(model?.provider || "") === provider)
|
|
23978
|
+
.map(footerScopedModelKey);
|
|
23979
|
+
const allowedKeys = new Set(providerKeys);
|
|
23980
|
+
const nextProviderKeys = [...new Set(providerOrder.filter((key) => allowedKeys.has(key)))];
|
|
23981
|
+
for (const key of providerKeys) {
|
|
23982
|
+
if (!nextProviderKeys.includes(key)) nextProviderKeys.push(key);
|
|
23983
|
+
}
|
|
23984
|
+
let providerIndex = 0;
|
|
23985
|
+
return models.map((model) => String(model?.provider || "") === provider
|
|
23986
|
+
? nextProviderKeys[providerIndex++]
|
|
23987
|
+
: footerScopedModelKey(model));
|
|
23988
|
+
}
|
|
23989
|
+
|
|
23990
|
+
function commitFooterScopedModelProviderOrder(provider, providerOrder, { render = true, focusKey = "" } = {}) {
|
|
23991
|
+
if (!provider || !providerOrder.length) return false;
|
|
23992
|
+
const currentOrder = orderedFooterScopedModels().map(footerScopedModelKey);
|
|
23993
|
+
const nextOrder = footerScopedModelOrderWithProviderOrder(provider, providerOrder);
|
|
23994
|
+
if (nextOrder.every((key, index) => key === currentOrder[index])) {
|
|
23995
|
+
focusFooterScopedModelOrderButton(focusKey);
|
|
23996
|
+
return false;
|
|
23997
|
+
}
|
|
23998
|
+
commitFooterScopedModelOrder(nextOrder, { render, focusKey });
|
|
23999
|
+
return true;
|
|
24000
|
+
}
|
|
24001
|
+
|
|
24002
|
+
function moveFooterScopedModelWithinProviderByOffset(modelKey, offset) {
|
|
24003
|
+
const models = orderedFooterScopedModels();
|
|
24004
|
+
const model = models.find((candidate) => footerScopedModelKey(candidate) === modelKey);
|
|
24005
|
+
const provider = String(model?.provider || "");
|
|
24006
|
+
if (!provider) return false;
|
|
24007
|
+
const providerOrder = models
|
|
24008
|
+
.filter((candidate) => String(candidate?.provider || "") === provider)
|
|
24009
|
+
.map(footerScopedModelKey);
|
|
24010
|
+
const fromIndex = providerOrder.indexOf(modelKey);
|
|
24011
|
+
const toIndex = fromIndex + offset;
|
|
24012
|
+
if (fromIndex < 0 || toIndex < 0 || toIndex >= providerOrder.length) return false;
|
|
24013
|
+
const [moved] = providerOrder.splice(fromIndex, 1);
|
|
24014
|
+
providerOrder.splice(toIndex, 0, moved);
|
|
24015
|
+
return commitFooterScopedModelProviderOrder(provider, providerOrder, { focusKey: modelKey });
|
|
24016
|
+
}
|
|
24017
|
+
|
|
23857
24018
|
function footerScopedModelButtons() {
|
|
23858
24019
|
return [...document.querySelectorAll(".footer-model-picker .footer-model-option[data-footer-model-key]")];
|
|
23859
24020
|
}
|
|
@@ -23868,9 +24029,16 @@ function clearFooterScopedModelDragMarkers() {
|
|
|
23868
24029
|
}
|
|
23869
24030
|
}
|
|
23870
24031
|
|
|
23871
|
-
function commitVisibleFooterScopedModelOrder({ render = false, focusKey = "" } = {}) {
|
|
23872
|
-
const order = footerScopedModelButtons()
|
|
24032
|
+
function commitVisibleFooterScopedModelOrder({ render = false, focusKey = "", provider = "" } = {}) {
|
|
24033
|
+
const order = footerScopedModelButtons()
|
|
24034
|
+
.filter((button) => !provider || button.dataset.footerProvider === provider)
|
|
24035
|
+
.map((button) => button.dataset.footerModelKey)
|
|
24036
|
+
.filter(Boolean);
|
|
23873
24037
|
if (!order.length) return;
|
|
24038
|
+
if (provider) {
|
|
24039
|
+
commitFooterScopedModelProviderOrder(provider, order, { render, focusKey });
|
|
24040
|
+
return;
|
|
24041
|
+
}
|
|
23874
24042
|
commitFooterScopedModelOrder(order, { render, focusKey });
|
|
23875
24043
|
}
|
|
23876
24044
|
|
|
@@ -23890,7 +24058,7 @@ function moveVisibleFooterScopedModel(fromKey, targetButton, clientY) {
|
|
|
23890
24058
|
|
|
23891
24059
|
if (insertBefore) parent.insertBefore(sourceButton, targetButton);
|
|
23892
24060
|
else parent.insertBefore(sourceButton, targetButton.nextSibling);
|
|
23893
|
-
commitVisibleFooterScopedModelOrder({ render: false });
|
|
24061
|
+
commitVisibleFooterScopedModelOrder({ render: false, provider: parent.dataset.footerProvider || "" });
|
|
23894
24062
|
return true;
|
|
23895
24063
|
}
|
|
23896
24064
|
|
|
@@ -23935,6 +24103,7 @@ function endFooterScopedModelPointerDrag(event) {
|
|
|
23935
24103
|
window.removeEventListener("pointercancel", endFooterScopedModelPointerDrag, { capture: true });
|
|
23936
24104
|
const wasActive = drag.active;
|
|
23937
24105
|
const sourceButton = document.querySelector(`[data-footer-model-key="${CSS.escape(drag.modelKey)}"]`);
|
|
24106
|
+
const provider = sourceButton?.dataset.footerProvider || "";
|
|
23938
24107
|
footerScopedModelPointerDrag = null;
|
|
23939
24108
|
footerScopedModelDragKey = "";
|
|
23940
24109
|
footerScopedModelLastDragOverKey = "";
|
|
@@ -23943,15 +24112,18 @@ function endFooterScopedModelPointerDrag(event) {
|
|
|
23943
24112
|
if (wasActive) {
|
|
23944
24113
|
footerScopedModelSuppressClickUntil = Date.now() + 250;
|
|
23945
24114
|
event.preventDefault();
|
|
23946
|
-
commitVisibleFooterScopedModelOrder({ render: false, focusKey: drag.modelKey });
|
|
24115
|
+
commitVisibleFooterScopedModelOrder({ render: false, focusKey: drag.modelKey, provider });
|
|
23947
24116
|
}
|
|
23948
24117
|
}
|
|
23949
24118
|
|
|
23950
24119
|
async function applyFooterModel(model) {
|
|
23951
|
-
if (!model?.provider || !model?.id) return;
|
|
24120
|
+
if (!model?.provider || !model?.id || footerModelApplyInFlight) return;
|
|
23952
24121
|
const tabContext = activeTabContext();
|
|
24122
|
+
footerModelApplyInFlight = true;
|
|
24123
|
+
footerModelPickerOpen = false;
|
|
24124
|
+
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
24125
|
+
renderFooter();
|
|
23953
24126
|
try {
|
|
23954
|
-
footerModelPickerOpen = false;
|
|
23955
24127
|
const response = await api("/api/model", { method: "POST", body: { provider: model.provider, modelId: model.id }, tabId: tabContext.tabId });
|
|
23956
24128
|
if (!isCurrentTabContext(tabContext)) return;
|
|
23957
24129
|
applyOptimisticModelSelection(response.data || model, tabContext);
|
|
@@ -23960,6 +24132,7 @@ async function applyFooterModel(model) {
|
|
|
23960
24132
|
} catch (error) {
|
|
23961
24133
|
if (isCurrentTabContext(tabContext)) addEvent(error.message, "error");
|
|
23962
24134
|
} finally {
|
|
24135
|
+
footerModelApplyInFlight = false;
|
|
23963
24136
|
if (isCurrentTabContext(tabContext)) {
|
|
23964
24137
|
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
23965
24138
|
renderFooter();
|
|
@@ -23967,12 +24140,159 @@ async function applyFooterModel(model) {
|
|
|
23967
24140
|
}
|
|
23968
24141
|
}
|
|
23969
24142
|
|
|
24143
|
+
function focusFooterModelTrigger() {
|
|
24144
|
+
queueMicrotask(() => {
|
|
24145
|
+
const trigger = elements.statusBar.querySelector(".footer-model.footer-meta-action, .footer-tui-model");
|
|
24146
|
+
trigger?.focus({ preventScroll: true });
|
|
24147
|
+
});
|
|
24148
|
+
}
|
|
24149
|
+
|
|
24150
|
+
function footerModelPickerInitialKey() {
|
|
24151
|
+
const models = orderedFooterScopedModels();
|
|
24152
|
+
const currentKey = footerScopedModelKey(currentState?.model);
|
|
24153
|
+
return models.some((model) => footerScopedModelKey(model) === currentKey) ? currentKey : footerScopedModelKey(models[0]);
|
|
24154
|
+
}
|
|
24155
|
+
|
|
24156
|
+
function focusFooterModelPickerInitialOption({ retryAfterPointerRender = true } = {}) {
|
|
24157
|
+
const initialKey = footerModelPickerInitialKey();
|
|
24158
|
+
queueMicrotask(() => {
|
|
24159
|
+
if (!footerModelPickerOpen) return;
|
|
24160
|
+
const picker = elements.statusBar.querySelector(".footer-model-picker");
|
|
24161
|
+
if (!picker) {
|
|
24162
|
+
if (retryAfterPointerRender) setTimeout(() => focusFooterModelPickerInitialOption({ retryAfterPointerRender: false }), 0);
|
|
24163
|
+
return;
|
|
24164
|
+
}
|
|
24165
|
+
const escapedKey = initialKey ? CSS.escape(initialKey) : "";
|
|
24166
|
+
const target = (escapedKey && picker.querySelector(`[data-footer-model-key="${escapedKey}"]`))
|
|
24167
|
+
|| picker.querySelector(".footer-model-option[data-footer-model-key]");
|
|
24168
|
+
if (!target) return;
|
|
24169
|
+
if (footerScopedModelLayout === "advanced") {
|
|
24170
|
+
for (const button of picker.querySelectorAll(".footer-model-option[data-footer-model-key]")) button.tabIndex = button === target ? 0 : -1;
|
|
24171
|
+
}
|
|
24172
|
+
target.focus({ preventScroll: true });
|
|
24173
|
+
target.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
24174
|
+
});
|
|
24175
|
+
}
|
|
24176
|
+
|
|
24177
|
+
function syncAdvancedFooterModelRovingTabStop(picker = elements.statusBar.querySelector(".footer-model-picker-advanced")) {
|
|
24178
|
+
if (!picker) return;
|
|
24179
|
+
const options = [...picker.querySelectorAll(".footer-model-option[data-footer-model-key]")];
|
|
24180
|
+
const focused = picker.contains(document.activeElement) ? document.activeElement.closest?.(".footer-model-option[data-footer-model-key]") : null;
|
|
24181
|
+
const target = focused || options.find((option) => option.tabIndex === 0) || options[0];
|
|
24182
|
+
for (const option of options) option.tabIndex = option === target ? 0 : -1;
|
|
24183
|
+
}
|
|
24184
|
+
|
|
24185
|
+
function focusAdvancedFooterModelOption(picker, button) {
|
|
24186
|
+
if (!picker || !button) return;
|
|
24187
|
+
for (const option of picker.querySelectorAll(".footer-model-option[data-footer-model-key]")) option.tabIndex = option === button ? 0 : -1;
|
|
24188
|
+
button.focus({ preventScroll: true });
|
|
24189
|
+
button.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
24190
|
+
}
|
|
24191
|
+
|
|
24192
|
+
function advancedFooterModelColumnButtons(picker, providerIndex) {
|
|
24193
|
+
const column = picker.querySelector(`[data-footer-provider-index="${providerIndex}"]`);
|
|
24194
|
+
return column ? [...column.querySelectorAll(".footer-model-option[data-footer-model-key]")] : [];
|
|
24195
|
+
}
|
|
24196
|
+
|
|
24197
|
+
function handleAdvancedFooterModelKeydown(event, model) {
|
|
24198
|
+
const picker = event.currentTarget.closest(".footer-model-picker-advanced");
|
|
24199
|
+
if (!picker) return;
|
|
24200
|
+
const providerIndex = Number(event.currentTarget.dataset.footerProviderIndex);
|
|
24201
|
+
const modelIndex = Number(event.currentTarget.dataset.footerModelIndex);
|
|
24202
|
+
const columns = [...picker.querySelectorAll(".footer-model-provider-column[data-footer-provider-index]")];
|
|
24203
|
+
let target = null;
|
|
24204
|
+
|
|
24205
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
24206
|
+
event.preventDefault();
|
|
24207
|
+
if (!event.repeat) void applyFooterModel(model);
|
|
24208
|
+
return;
|
|
24209
|
+
}
|
|
24210
|
+
if (event.key === "Escape") {
|
|
24211
|
+
event.preventDefault();
|
|
24212
|
+
event.stopPropagation();
|
|
24213
|
+
setFooterModelPickerOpen(false, { restoreFocus: true });
|
|
24214
|
+
return;
|
|
24215
|
+
}
|
|
24216
|
+
if (event.altKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
24217
|
+
event.preventDefault();
|
|
24218
|
+
moveFooterScopedModelWithinProviderByOffset(footerScopedModelKey(model), event.key === "ArrowUp" ? -1 : 1);
|
|
24219
|
+
return;
|
|
24220
|
+
}
|
|
24221
|
+
if (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End") {
|
|
24222
|
+
const buttons = advancedFooterModelColumnButtons(picker, providerIndex);
|
|
24223
|
+
const lastIndex = Math.max(0, buttons.length - 1);
|
|
24224
|
+
const targetIndex = event.key === "Home"
|
|
24225
|
+
? 0
|
|
24226
|
+
: event.key === "End"
|
|
24227
|
+
? lastIndex
|
|
24228
|
+
: Math.min(lastIndex, Math.max(0, modelIndex + (event.key === "ArrowUp" ? -1 : 1)));
|
|
24229
|
+
target = buttons[targetIndex] || event.currentTarget;
|
|
24230
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
24231
|
+
const lastProviderIndex = Math.max(0, columns.length - 1);
|
|
24232
|
+
const targetProviderIndex = Math.min(lastProviderIndex, Math.max(0, providerIndex + (event.key === "ArrowLeft" ? -1 : 1)));
|
|
24233
|
+
const buttons = advancedFooterModelColumnButtons(picker, targetProviderIndex);
|
|
24234
|
+
target = buttons[Math.min(Math.max(0, modelIndex), Math.max(0, buttons.length - 1))] || event.currentTarget;
|
|
24235
|
+
} else {
|
|
24236
|
+
return;
|
|
24237
|
+
}
|
|
24238
|
+
|
|
24239
|
+
event.preventDefault();
|
|
24240
|
+
focusAdvancedFooterModelOption(picker, target);
|
|
24241
|
+
}
|
|
24242
|
+
|
|
24243
|
+
function renderFooterModelOption(model, { advanced = false, providerIndex = -1, modelIndex = -1, initialKey = "" } = {}) {
|
|
24244
|
+
const current = currentState?.model;
|
|
24245
|
+
const selected = current?.provider === model.provider && current?.id === model.id;
|
|
24246
|
+
const modelKey = footerScopedModelKey(model);
|
|
24247
|
+
const dragging = footerScopedModelDragKey === modelKey;
|
|
24248
|
+
const dragOver = footerScopedModelDragKey && footerScopedModelLastDragOverKey === modelKey;
|
|
24249
|
+
const button = make("button", `footer-model-option${selected ? " active" : ""}${dragging ? " dragging" : ""}${dragOver ? " drag-over" : ""}`);
|
|
24250
|
+
button.type = "button";
|
|
24251
|
+
button.draggable = false;
|
|
24252
|
+
button.dataset.footerModelKey = modelKey;
|
|
24253
|
+
button.setAttribute("role", "option");
|
|
24254
|
+
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
24255
|
+
button.title = `${model.provider}/${model.id}${model.name ? ` · ${model.name}` : ""}`;
|
|
24256
|
+
button.append(
|
|
24257
|
+
make("span", "footer-model-option-main", advanced ? model.id : `${model.provider}/${model.id}`),
|
|
24258
|
+
make("span", "footer-model-option-name", model.name || ""),
|
|
24259
|
+
);
|
|
24260
|
+
button.addEventListener("click", (event) => {
|
|
24261
|
+
if (Date.now() < footerScopedModelSuppressClickUntil) {
|
|
24262
|
+
event.preventDefault();
|
|
24263
|
+
return;
|
|
24264
|
+
}
|
|
24265
|
+
void applyFooterModel(model);
|
|
24266
|
+
});
|
|
24267
|
+
if (advanced) {
|
|
24268
|
+
button.dataset.footerProvider = model.provider;
|
|
24269
|
+
button.dataset.footerProviderIndex = String(providerIndex);
|
|
24270
|
+
button.dataset.footerModelIndex = String(modelIndex);
|
|
24271
|
+
button.tabIndex = modelKey === initialKey ? 0 : -1;
|
|
24272
|
+
button.addEventListener("keydown", (event) => handleAdvancedFooterModelKeydown(event, model));
|
|
24273
|
+
} else {
|
|
24274
|
+
button.addEventListener("keydown", (event) => {
|
|
24275
|
+
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
|
|
24276
|
+
event.preventDefault();
|
|
24277
|
+
moveFooterScopedModelByOffset(modelKey, event.key === "ArrowUp" ? -1 : 1);
|
|
24278
|
+
});
|
|
24279
|
+
}
|
|
24280
|
+
button.addEventListener("pointerdown", (event) => beginFooterScopedModelPointerDrag(event, modelKey));
|
|
24281
|
+
return button;
|
|
24282
|
+
}
|
|
24283
|
+
|
|
23970
24284
|
function renderFooterModelPicker() {
|
|
23971
|
-
const
|
|
24285
|
+
const advanced = footerScopedModelLayout === "advanced";
|
|
24286
|
+
const picker = make("div", `footer-model-picker${advanced ? " footer-model-picker-advanced" : ""}`);
|
|
23972
24287
|
picker.setAttribute("role", "listbox");
|
|
23973
|
-
picker.setAttribute("aria-label", "Scoped models");
|
|
23974
|
-
picker.append(make("div", "footer-model-picker-title", "Scoped models"));
|
|
23975
|
-
|
|
24288
|
+
picker.setAttribute("aria-label", advanced ? "Scoped models by provider" : "Scoped models");
|
|
24289
|
+
picker.append(make("div", "footer-model-picker-title", advanced ? "Scoped models by provider" : "Scoped models"));
|
|
24290
|
+
const help = make("div", "footer-model-picker-source", advanced
|
|
24291
|
+
? "Drag within provider · Alt+Up/Down reorders · Left/Right changes provider · Up/Down changes model · Home/End jumps within provider · Enter/Space selects · Escape closes"
|
|
24292
|
+
: "Drag models to reorder · Alt+Up/Down moves focused model");
|
|
24293
|
+
help.id = "footerModelPickerHelp";
|
|
24294
|
+
picker.setAttribute("aria-describedby", help.id);
|
|
24295
|
+
picker.append(help);
|
|
23976
24296
|
if (footerScopedModels.length === 0) {
|
|
23977
24297
|
const empty = make("div", "footer-model-picker-empty muted");
|
|
23978
24298
|
empty.append(
|
|
@@ -23982,39 +24302,29 @@ function renderFooterModelPicker() {
|
|
|
23982
24302
|
picker.append(empty);
|
|
23983
24303
|
return picker;
|
|
23984
24304
|
}
|
|
23985
|
-
const current = currentState?.model;
|
|
23986
24305
|
footerScopedModels = orderedFooterScopedModels();
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
const
|
|
23990
|
-
|
|
23991
|
-
const dragOver = footerScopedModelDragKey && footerScopedModelLastDragOverKey === modelKey;
|
|
23992
|
-
const button = make("button", `footer-model-option${selected ? " active" : ""}${dragging ? " dragging" : ""}${dragOver ? " drag-over" : ""}`);
|
|
23993
|
-
button.type = "button";
|
|
23994
|
-
button.draggable = false;
|
|
23995
|
-
button.dataset.footerModelKey = modelKey;
|
|
23996
|
-
button.setAttribute("role", "option");
|
|
23997
|
-
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
23998
|
-
button.title = `${model.provider}/${model.id}${model.name ? ` · ${model.name}` : ""}`;
|
|
23999
|
-
button.append(
|
|
24000
|
-
make("span", "footer-model-option-main", `${model.provider}/${model.id}`),
|
|
24001
|
-
make("span", "footer-model-option-name", model.name || ""),
|
|
24002
|
-
);
|
|
24003
|
-
button.addEventListener("click", (event) => {
|
|
24004
|
-
if (Date.now() < footerScopedModelSuppressClickUntil) {
|
|
24005
|
-
event.preventDefault();
|
|
24006
|
-
return;
|
|
24007
|
-
}
|
|
24008
|
-
applyFooterModel(model);
|
|
24009
|
-
});
|
|
24010
|
-
button.addEventListener("keydown", (event) => {
|
|
24011
|
-
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
|
|
24012
|
-
event.preventDefault();
|
|
24013
|
-
moveFooterScopedModelByOffset(modelKey, event.key === "ArrowUp" ? -1 : 1);
|
|
24014
|
-
});
|
|
24015
|
-
button.addEventListener("pointerdown", (event) => beginFooterScopedModelPointerDrag(event, modelKey));
|
|
24016
|
-
picker.append(button);
|
|
24306
|
+
const initialKey = footerModelPickerInitialKey();
|
|
24307
|
+
if (!advanced) {
|
|
24308
|
+
for (const model of footerScopedModels) picker.append(renderFooterModelOption(model));
|
|
24309
|
+
return picker;
|
|
24017
24310
|
}
|
|
24311
|
+
|
|
24312
|
+
const columns = make("div", "footer-model-provider-columns");
|
|
24313
|
+
for (const [providerIndex, group] of footerScopedModelProviderGroups(footerScopedModels).entries()) {
|
|
24314
|
+
const heading = make("div", "footer-model-provider-title", group.provider);
|
|
24315
|
+
heading.id = `footerModelProvider${providerIndex}`;
|
|
24316
|
+
const column = make("div", "footer-model-provider-column");
|
|
24317
|
+
column.dataset.footerProvider = group.provider;
|
|
24318
|
+
column.dataset.footerProviderIndex = String(providerIndex);
|
|
24319
|
+
column.setAttribute("role", "group");
|
|
24320
|
+
column.setAttribute("aria-labelledby", heading.id);
|
|
24321
|
+
column.append(heading);
|
|
24322
|
+
for (const [modelIndex, model] of group.models.entries()) {
|
|
24323
|
+
column.append(renderFooterModelOption(model, { advanced: true, providerIndex, modelIndex, initialKey }));
|
|
24324
|
+
}
|
|
24325
|
+
columns.append(column);
|
|
24326
|
+
}
|
|
24327
|
+
picker.append(columns);
|
|
24018
24328
|
return picker;
|
|
24019
24329
|
}
|
|
24020
24330
|
|
|
@@ -24082,6 +24392,22 @@ function setPathPickerError(message) {
|
|
|
24082
24392
|
elements.pathPickerError.hidden = !message;
|
|
24083
24393
|
}
|
|
24084
24394
|
|
|
24395
|
+
function pathPickerEnteredPath() {
|
|
24396
|
+
return elements.pathPickerPathInput.value.trim();
|
|
24397
|
+
}
|
|
24398
|
+
|
|
24399
|
+
function updatePathPickerPathControls() {
|
|
24400
|
+
const loading = !!pathPickerState?.loading;
|
|
24401
|
+
elements.pathPickerPathInput.disabled = !pathPickerState || loading;
|
|
24402
|
+
elements.pathPickerPathButton.disabled = !pathPickerState || loading || !pathPickerEnteredPath();
|
|
24403
|
+
}
|
|
24404
|
+
|
|
24405
|
+
async function openPathPickerEnteredPath() {
|
|
24406
|
+
const cwd = pathPickerEnteredPath();
|
|
24407
|
+
if (!cwd || pathPickerState?.loading) return;
|
|
24408
|
+
await loadPathPickerDirectory(cwd);
|
|
24409
|
+
}
|
|
24410
|
+
|
|
24085
24411
|
function pathPickerCreateName() {
|
|
24086
24412
|
return elements.pathPickerCreateNameInput.value.trim();
|
|
24087
24413
|
}
|
|
@@ -24097,8 +24423,9 @@ function pathPickerCreateValidationError(name = pathPickerCreateName()) {
|
|
|
24097
24423
|
function updateCreateDirectoryControls() {
|
|
24098
24424
|
const busy = !!pathPickerState?.creatingDirectory;
|
|
24099
24425
|
const loading = !!pathPickerState?.loading;
|
|
24100
|
-
const
|
|
24101
|
-
|
|
24426
|
+
const canEdit = !!pathPickerState?.cwd && pathPickerState.selectable !== false && !loading && !busy;
|
|
24427
|
+
const canCreate = canEdit && !!pathPickerCreateName();
|
|
24428
|
+
elements.pathPickerCreateNameInput.disabled = !canEdit;
|
|
24102
24429
|
elements.pathPickerCreateButton.disabled = !canCreate;
|
|
24103
24430
|
elements.pathPickerCreateButton.textContent = busy ? "Creating…" : "Create directory";
|
|
24104
24431
|
}
|
|
@@ -24109,9 +24436,9 @@ function pathPickerSearchQuery() {
|
|
|
24109
24436
|
|
|
24110
24437
|
function updatePathPickerSearchControls() {
|
|
24111
24438
|
const loading = !!pathPickerState?.loading;
|
|
24112
|
-
const
|
|
24439
|
+
const canSearch = !!pathPickerState && (pathPickerState.selectable === false || !!pathPickerState.cwd);
|
|
24113
24440
|
const hasQuery = !!pathPickerSearchQuery();
|
|
24114
|
-
elements.pathPickerSearchInput.disabled =
|
|
24441
|
+
elements.pathPickerSearchInput.disabled = loading || !canSearch;
|
|
24115
24442
|
elements.pathPickerClearSearchButton.hidden = !hasQuery;
|
|
24116
24443
|
elements.pathPickerClearSearchButton.disabled = loading || !hasQuery;
|
|
24117
24444
|
}
|
|
@@ -24145,7 +24472,8 @@ function renderPathPickerDirectoryList() {
|
|
|
24145
24472
|
}
|
|
24146
24473
|
|
|
24147
24474
|
for (const directory of matches) {
|
|
24148
|
-
const
|
|
24475
|
+
const label = /[\\/]$/.test(directory.name) ? directory.name : `${directory.name}/`;
|
|
24476
|
+
const button = pathPickerButton(label, directory.cwd, () => loadPathPickerDirectory(directory.cwd, { focusAfterLoad: true }), `path-picker-directory${directory.hidden ? " hidden-directory" : ""}`);
|
|
24149
24477
|
button.setAttribute("role", "option");
|
|
24150
24478
|
elements.pathPickerList.append(button);
|
|
24151
24479
|
}
|
|
@@ -24244,7 +24572,7 @@ function fastPickLabel(pick) {
|
|
|
24244
24572
|
}
|
|
24245
24573
|
|
|
24246
24574
|
function currentFastPick() {
|
|
24247
|
-
if (!pathPickerState?.cwd) return null;
|
|
24575
|
+
if (!pathPickerState?.cwd || pathPickerState.selectable === false) return null;
|
|
24248
24576
|
return { cwd: pathPickerState.cwd, displayCwd: elements.pathPickerCurrent.textContent || pathPickerState.cwd };
|
|
24249
24577
|
}
|
|
24250
24578
|
|
|
@@ -24276,7 +24604,7 @@ function renderFastPicks() {
|
|
|
24276
24604
|
|
|
24277
24605
|
for (const pick of picks) {
|
|
24278
24606
|
const item = make("span", "path-picker-fast-pick");
|
|
24279
|
-
const jump = pathPickerButton(fastPickLabel(pick), pick.cwd, () => loadPathPickerDirectory(pick.cwd), "path-picker-fast-pick-button");
|
|
24607
|
+
const jump = pathPickerButton(fastPickLabel(pick), pick.cwd, () => loadPathPickerDirectory(pick.cwd, { focusAfterLoad: true }), "path-picker-fast-pick-button");
|
|
24280
24608
|
const remove = pathPickerButton("×", `Unpin ${pick.cwd}`, async () => {
|
|
24281
24609
|
await saveFastPicks(loadFastPicks().filter((item) => item.cwd !== pick.cwd));
|
|
24282
24610
|
}, "path-picker-fast-pick-remove");
|
|
@@ -24296,32 +24624,36 @@ async function addCurrentFastPick() {
|
|
|
24296
24624
|
|
|
24297
24625
|
function renderPathPicker(data) {
|
|
24298
24626
|
if (!pathPickerState) return;
|
|
24299
|
-
pathPickerState.cwd = data.cwd;
|
|
24627
|
+
pathPickerState.cwd = data.cwd || "";
|
|
24628
|
+
pathPickerState.displayCwd = data.displayCwd || pathPickerState.cwd;
|
|
24629
|
+
pathPickerState.selectable = data.selectable !== false;
|
|
24300
24630
|
pathPickerState.loading = false;
|
|
24301
24631
|
pathPickerState.directories = Array.isArray(data.directories) ? data.directories : [];
|
|
24302
24632
|
pathPickerState.filteredDirectories = pathPickerState.directories;
|
|
24303
|
-
elements.pathPickerCurrent.textContent =
|
|
24304
|
-
elements.pathPickerCurrent.title =
|
|
24305
|
-
elements.pathPickerChooseButton.disabled =
|
|
24633
|
+
elements.pathPickerCurrent.textContent = pathPickerState.displayCwd;
|
|
24634
|
+
elements.pathPickerCurrent.title = pathPickerState.cwd || pathPickerState.displayCwd;
|
|
24635
|
+
elements.pathPickerChooseButton.disabled = !pathPickerState.selectable || !pathPickerState.cwd;
|
|
24306
24636
|
elements.pathPickerChooseButton.textContent = "Use this directory";
|
|
24637
|
+
elements.pathPickerPathInput.value = "";
|
|
24307
24638
|
elements.pathPickerCreateNameInput.value = "";
|
|
24308
24639
|
elements.pathPickerSearchInput.value = "";
|
|
24309
24640
|
setPathPickerError(data.truncated ? "Showing the first 500 directories." : "");
|
|
24641
|
+
updatePathPickerPathControls();
|
|
24310
24642
|
updateCreateDirectoryControls();
|
|
24311
24643
|
renderFastPicks();
|
|
24312
24644
|
|
|
24313
24645
|
elements.pathPickerRoots.replaceChildren();
|
|
24314
24646
|
if (data.parent) {
|
|
24315
|
-
elements.pathPickerRoots.append(pathPickerButton("↑ Parent", data.parent, () => loadPathPickerDirectory(data.parent), "path-picker-root-button"));
|
|
24647
|
+
elements.pathPickerRoots.append(pathPickerButton("↑ Parent", data.parent, () => loadPathPickerDirectory(data.parent, { focusAfterLoad: true }), "path-picker-root-button"));
|
|
24316
24648
|
}
|
|
24317
24649
|
for (const root of data.roots || []) {
|
|
24318
|
-
elements.pathPickerRoots.append(pathPickerButton(root.label, root.cwd, () => loadPathPickerDirectory(root.cwd), "path-picker-root-button"));
|
|
24650
|
+
elements.pathPickerRoots.append(pathPickerButton(root.label, root.cwd, () => loadPathPickerDirectory(root.cwd, { focusAfterLoad: true }), "path-picker-root-button"));
|
|
24319
24651
|
}
|
|
24320
24652
|
|
|
24321
24653
|
renderPathPickerDirectoryList();
|
|
24322
24654
|
}
|
|
24323
24655
|
|
|
24324
|
-
async function loadPathPickerDirectory(cwd) {
|
|
24656
|
+
async function loadPathPickerDirectory(cwd, { focusAfterLoad = false } = {}) {
|
|
24325
24657
|
if (!pathPickerState) return;
|
|
24326
24658
|
const requestId = ++pathPickerState.requestId;
|
|
24327
24659
|
pathPickerState.loading = true;
|
|
@@ -24329,6 +24661,7 @@ async function loadPathPickerDirectory(cwd) {
|
|
|
24329
24661
|
elements.pathPickerChooseButton.disabled = true;
|
|
24330
24662
|
elements.pathPickerCurrent.textContent = "Loading…";
|
|
24331
24663
|
elements.pathPickerSearchStatus.textContent = "";
|
|
24664
|
+
updatePathPickerPathControls();
|
|
24332
24665
|
updateCreateDirectoryControls();
|
|
24333
24666
|
updatePathPickerSearchControls();
|
|
24334
24667
|
setPathPickerError("");
|
|
@@ -24338,12 +24671,15 @@ async function loadPathPickerDirectory(cwd) {
|
|
|
24338
24671
|
const response = await api(`/api/directories${query}`);
|
|
24339
24672
|
if (!pathPickerState || pathPickerState.requestId !== requestId) return;
|
|
24340
24673
|
renderPathPicker(response.data || {});
|
|
24674
|
+
if (focusAfterLoad) elements.pathPickerSearchInput.focus({ preventScroll: true });
|
|
24341
24675
|
} catch (error) {
|
|
24342
24676
|
if (!pathPickerState || pathPickerState.requestId !== requestId) return;
|
|
24343
24677
|
pathPickerState.loading = false;
|
|
24344
|
-
elements.pathPickerChooseButton.disabled =
|
|
24345
|
-
elements.pathPickerCurrent.textContent = pathPickerState.cwd || "Unable to load directory";
|
|
24678
|
+
elements.pathPickerChooseButton.disabled = !pathPickerState.selectable || !pathPickerState.cwd;
|
|
24679
|
+
elements.pathPickerCurrent.textContent = pathPickerState.displayCwd || pathPickerState.cwd || "Unable to load directory";
|
|
24680
|
+
elements.pathPickerCurrent.title = pathPickerState.cwd || pathPickerState.displayCwd || "";
|
|
24346
24681
|
setPathPickerError(error.message);
|
|
24682
|
+
updatePathPickerPathControls();
|
|
24347
24683
|
updateCreateDirectoryControls();
|
|
24348
24684
|
updatePathPickerSearchControls();
|
|
24349
24685
|
updateAddFastPickButton();
|
|
@@ -24400,9 +24736,10 @@ function pickCwd(tab, initialCwd, { title } = {}) {
|
|
|
24400
24736
|
|
|
24401
24737
|
return new Promise((resolve) => {
|
|
24402
24738
|
const pickerTab = tab || { id: "path-picker", title: "tab" };
|
|
24403
|
-
pathPickerState = { tabId: pickerTab.id, cwd: initialCwd, requestId: 0, loading: false, creatingDirectory: false, directories: [], filteredDirectories: [], resolve };
|
|
24739
|
+
pathPickerState = { tabId: pickerTab.id, cwd: initialCwd, displayCwd: initialCwd, selectable: true, requestId: 0, loading: false, creatingDirectory: false, directories: [], filteredDirectories: [], resolve };
|
|
24404
24740
|
elements.pathPickerTitle.textContent = title || `Choose CWD for ${pickerTab.title}`;
|
|
24405
24741
|
elements.pathPickerCurrent.textContent = "Loading…";
|
|
24742
|
+
elements.pathPickerPathInput.value = "";
|
|
24406
24743
|
elements.pathPickerCreateNameInput.value = "";
|
|
24407
24744
|
elements.pathPickerSearchInput.value = "";
|
|
24408
24745
|
elements.pathPickerSearchStatus.textContent = "";
|
|
@@ -24412,6 +24749,7 @@ function pickCwd(tab, initialCwd, { title } = {}) {
|
|
|
24412
24749
|
setPathPickerError("");
|
|
24413
24750
|
elements.pathPickerAddFastPickButton.disabled = true;
|
|
24414
24751
|
elements.pathPickerChooseButton.disabled = true;
|
|
24752
|
+
updatePathPickerPathControls();
|
|
24415
24753
|
updateCreateDirectoryControls();
|
|
24416
24754
|
updatePathPickerSearchControls();
|
|
24417
24755
|
initializeFastPicks().catch((error) => addEvent(`failed to initialize path fast picks: ${error.message}`, "error"));
|
|
@@ -24497,6 +24835,7 @@ function renderFooter() {
|
|
|
24497
24835
|
else renderMinimalFooter();
|
|
24498
24836
|
if (!tooltipSnapshot && footerTooltipTarget && !footerTooltipTarget.isConnected) hideFooterTooltip();
|
|
24499
24837
|
restoreScopedControlContinuity(elements.statusBar, continuityContextKey, focusSnapshot, (key) => [...elements.statusBar.querySelectorAll("input, textarea, select, button")].find((node) => footerControlKey(node) === key));
|
|
24838
|
+
syncAdvancedFooterModelRovingTabStop();
|
|
24500
24839
|
restoreTooltipContinuity(elements.statusBar, tooltipSnapshot);
|
|
24501
24840
|
}
|
|
24502
24841
|
|
|
@@ -25594,7 +25933,18 @@ async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
|
25594
25933
|
renderSubagents();
|
|
25595
25934
|
scheduleRefreshSubagents();
|
|
25596
25935
|
}
|
|
25597
|
-
if (dismissed)
|
|
25936
|
+
if (dismissed) {
|
|
25937
|
+
if (automatic) {
|
|
25938
|
+
addEvent("auto-cleared", "info", {
|
|
25939
|
+
aggregateKey: "subagent-auto-clear",
|
|
25940
|
+
aggregateIncrement: dismissed,
|
|
25941
|
+
aggregateSingular: "finished subagent run",
|
|
25942
|
+
aggregatePlural: "finished subagent runs",
|
|
25943
|
+
});
|
|
25944
|
+
} else {
|
|
25945
|
+
addEvent(`cleared ${dismissed} finished subagent ${dismissed === 1 ? "run" : "runs"}`, "info");
|
|
25946
|
+
}
|
|
25947
|
+
}
|
|
25598
25948
|
if (failures.length) addEvent(`could not ${automatic ? "auto-clear" : "clear"} ${failures.length} finished subagent ${failures.length === 1 ? "run" : "runs"}`, "warn");
|
|
25599
25949
|
}
|
|
25600
25950
|
|
|
@@ -32937,10 +33287,10 @@ function renderGitWorkflow() {
|
|
|
32937
33287
|
addGitWorkflowAction("Creating PR…", () => {}, "primary", true);
|
|
32938
33288
|
} else if (gitWorkflow.step === "done") {
|
|
32939
33289
|
addGitWorkflowAction("Close", () => setGitWorkflow({ active: false }), "primary", false);
|
|
32940
|
-
addGitWorkflowAction("Start another", () =>
|
|
33290
|
+
addGitWorkflowAction("Start another", () => launchGuidedGitWorkflow(gitWorkflowActionTabId()), "", false);
|
|
32941
33291
|
} else if (["cancelled", "error"].includes(gitWorkflow.step)) {
|
|
32942
33292
|
addGitWorkflowAction("Close", () => setGitWorkflow({ active: false }), "primary", false);
|
|
32943
|
-
addGitWorkflowAction("Restart", () =>
|
|
33293
|
+
addGitWorkflowAction("Restart", () => launchGuidedGitWorkflow(gitWorkflowActionTabId()), "", false);
|
|
32944
33294
|
}
|
|
32945
33295
|
restoreGitWorkflowInputFocus(inputFocus);
|
|
32946
33296
|
}
|
|
@@ -33195,14 +33545,108 @@ function reconcileGuidedGitReviewWidgetRemoval(tabId) {
|
|
|
33195
33545
|
return true;
|
|
33196
33546
|
}
|
|
33197
33547
|
|
|
33198
|
-
|
|
33199
|
-
|
|
33200
|
-
|
|
33201
|
-
|
|
33202
|
-
|
|
33203
|
-
|
|
33204
|
-
|
|
33205
|
-
|
|
33548
|
+
function guidedGitPromptCommandUnavailable(commandName) {
|
|
33549
|
+
return `Guided Git browser generation requires /${commandName} from @firstpick/pi-prompts-git-pr in the originating tab.`;
|
|
33550
|
+
}
|
|
33551
|
+
|
|
33552
|
+
function guidedGitPromptCompanionAvailable(tabId) {
|
|
33553
|
+
return !isOptionalFeatureDisabled("gitWorkflow") && hasLoadedRpcCommand("git-staged-msg", { tabId });
|
|
33554
|
+
}
|
|
33555
|
+
|
|
33556
|
+
function reportGuidedGitPromptCompanionUnavailable(tabId) {
|
|
33557
|
+
const tabContext = activeTabContext(tabId);
|
|
33558
|
+
const message = isOptionalFeatureDisabled("gitWorkflow")
|
|
33559
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33560
|
+
: guidedGitPromptCommandUnavailable("git-staged-msg");
|
|
33561
|
+
addEvent(message, "warn");
|
|
33562
|
+
refreshCommands(tabContext).catch((error) => {
|
|
33563
|
+
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
33564
|
+
});
|
|
33565
|
+
}
|
|
33566
|
+
|
|
33567
|
+
function handleGuidedGitActivationRequest(request) {
|
|
33568
|
+
if (request?.method !== "setStatus" || request.statusKey !== GUIDED_GIT_START_STATUS_KEY) return false;
|
|
33569
|
+
const result = guidedGitActivationController.consume(request, async (tabId, activationIsCurrent) => {
|
|
33570
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33571
|
+
reportGuidedGitPromptCompanionUnavailable(tabId);
|
|
33572
|
+
return;
|
|
33573
|
+
}
|
|
33574
|
+
await startGitWorkflow(tabId, { activationIsCurrent });
|
|
33575
|
+
});
|
|
33576
|
+
result.promise?.catch((error) => addEvent(`Guided Git could not start: ${error?.message || String(error)}`, "error"));
|
|
33577
|
+
return true;
|
|
33578
|
+
}
|
|
33579
|
+
|
|
33580
|
+
function guidedGitLaunchStateForTab(tabId) {
|
|
33581
|
+
return tabId === activeTabId ? currentState : tabStateCache.get(tabId) || null;
|
|
33582
|
+
}
|
|
33583
|
+
|
|
33584
|
+
function guidedGitLaunchRefusalReason(tabId) {
|
|
33585
|
+
if (promptRoutingTabs.has(tabId)) return "pending";
|
|
33586
|
+
return guidedGitLaunchBlockedReason(guidedGitLaunchStateForTab(tabId), queueMessageCount(queuedSnapshotForTab(tabId)));
|
|
33587
|
+
}
|
|
33588
|
+
|
|
33589
|
+
function reportGuidedGitLaunchRefused(reason) {
|
|
33590
|
+
const detail = reason === "compacting"
|
|
33591
|
+
? "Pi is compacting context"
|
|
33592
|
+
: reason === "streaming"
|
|
33593
|
+
? "Pi is running"
|
|
33594
|
+
: reason === "pending"
|
|
33595
|
+
? "the tab has pending messages"
|
|
33596
|
+
: "the tab state is not ready";
|
|
33597
|
+
addEvent(`Guided Git was not started because ${detail}. Wait until the originating tab is idle with no pending messages, then start it again.`, "warn");
|
|
33598
|
+
}
|
|
33599
|
+
|
|
33600
|
+
function guidedGitLaunchAdmitted(tabId) {
|
|
33601
|
+
const reason = guidedGitLaunchRefusalReason(tabId);
|
|
33602
|
+
if (!reason) return true;
|
|
33603
|
+
reportGuidedGitLaunchRefused(reason);
|
|
33604
|
+
return false;
|
|
33605
|
+
}
|
|
33606
|
+
|
|
33607
|
+
async function startLegacyGuidedGitWorkflowFallback(tabId) {
|
|
33608
|
+
if (!guidedGitLaunchAdmitted(tabId)) return;
|
|
33609
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33610
|
+
addEvent(isOptionalFeatureDisabled("gitWorkflow")
|
|
33611
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33612
|
+
: "Guided Git is unavailable: install @firstpick/pi-extension-git-guided-workflow. Browser generation also requires @firstpick/pi-prompts-git-pr.", "warn");
|
|
33613
|
+
return;
|
|
33614
|
+
}
|
|
33615
|
+
try {
|
|
33616
|
+
await api("/api/git-workflow/launch-admission", { method: "POST", body: {}, tabId });
|
|
33617
|
+
} catch (error) {
|
|
33618
|
+
reportGuidedGitLaunchRefused("pending");
|
|
33619
|
+
return;
|
|
33620
|
+
}
|
|
33621
|
+
addEvent("Using the temporary prompt-only Guided Git compatibility launcher. Install @firstpick/pi-extension-git-guided-workflow to route future starts through /git-guided-workflow.", "info");
|
|
33622
|
+
await guidedGitActivationController.run(tabId, (_tabId, activationIsCurrent) => startGitWorkflow(tabId, { activationIsCurrent }));
|
|
33623
|
+
}
|
|
33624
|
+
|
|
33625
|
+
async function launchGuidedGitWorkflow(tabId = activeTabId) {
|
|
33626
|
+
if (!tabId || !guidedGitLaunchAdmitted(tabId)) return;
|
|
33627
|
+
const launchMode = guidedGitLaunchModeForTabCatalog(commandCatalogForTab(tabId), { disabled: isOptionalFeatureDisabled("gitWorkflow") });
|
|
33628
|
+
if (launchMode === "fallback") {
|
|
33629
|
+
await startLegacyGuidedGitWorkflowFallback(tabId);
|
|
33630
|
+
return;
|
|
33631
|
+
}
|
|
33632
|
+
if (launchMode !== "extension") {
|
|
33633
|
+
addEvent(launchMode === "disabled"
|
|
33634
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33635
|
+
: "Guided Git is unavailable: install @firstpick/pi-extension-git-guided-workflow. Browser generation also requires @firstpick/pi-prompts-git-pr.", "warn");
|
|
33636
|
+
return;
|
|
33637
|
+
}
|
|
33638
|
+
const commandName = resolveAvailableCommandName("git-guided-workflow", { tabId, rpcOnly: true });
|
|
33639
|
+
try {
|
|
33640
|
+
await sendPrompt("prompt", `/${commandName}`, { targetTabId: tabId, throwOnError: true });
|
|
33641
|
+
} catch (error) {
|
|
33642
|
+
addEvent(`Guided Git activation request failed: ${error?.message || String(error)}`, "error");
|
|
33643
|
+
}
|
|
33644
|
+
}
|
|
33645
|
+
|
|
33646
|
+
async function startGitWorkflow(tabId = activeTabId, { skipSetup = false, activationIsCurrent = () => true } = {}) {
|
|
33647
|
+
if (!tabId || !activationIsCurrent()) return;
|
|
33648
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33649
|
+
reportGuidedGitPromptCompanionUnavailable(tabId);
|
|
33206
33650
|
return;
|
|
33207
33651
|
}
|
|
33208
33652
|
|
|
@@ -33210,6 +33654,7 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
33210
33654
|
try {
|
|
33211
33655
|
const response = await api("/api/git-workflow/preferences", { tabId });
|
|
33212
33656
|
setupData = response.data || {};
|
|
33657
|
+
if (!activationIsCurrent()) return;
|
|
33213
33658
|
gitWorkflowPreferences = setupData.preferences || null;
|
|
33214
33659
|
} catch (error) {
|
|
33215
33660
|
addEvent(`guided Git setup could not be loaded: ${error.message || String(error)}`, "error");
|
|
@@ -33221,12 +33666,17 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
33221
33666
|
return;
|
|
33222
33667
|
}
|
|
33223
33668
|
addEvent("Complete Guided Git Setup before starting the workflow.", "info");
|
|
33224
|
-
await openNativeGitWorkflowSetupDialog({
|
|
33669
|
+
await openNativeGitWorkflowSetupDialog({
|
|
33670
|
+
tabId,
|
|
33671
|
+
activationIsCurrent,
|
|
33672
|
+
onSaved: () => startGitWorkflow(tabId, { skipSetup: true, activationIsCurrent }),
|
|
33673
|
+
});
|
|
33225
33674
|
return;
|
|
33226
33675
|
}
|
|
33227
33676
|
|
|
33228
33677
|
const workflow = gitWorkflowForTab(tabId);
|
|
33229
33678
|
if (workflow.active && !["done", "cancelled", "error"].includes(workflow.step) && !(await appConfirmText("Restart the active git workflow?", { affected: "The active guided Git workflow", confirmLabel: "Restart workflow" }))) return;
|
|
33679
|
+
if (!activationIsCurrent()) return;
|
|
33230
33680
|
const preferences = setupData.preferences;
|
|
33231
33681
|
workflow.runId += 1;
|
|
33232
33682
|
setGitWorkflow({
|
|
@@ -33672,6 +34122,10 @@ async function loadGitWorkflowDefaultCommitMessage({ runId, tabId = activeTabId
|
|
|
33672
34122
|
|
|
33673
34123
|
async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
33674
34124
|
const tabContext = activeTabContext(tabId);
|
|
34125
|
+
if (!hasLoadedRpcCommand("git-staged-msg", { tabId })) {
|
|
34126
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("git-staged-msg")), "generate", { tabId });
|
|
34127
|
+
return;
|
|
34128
|
+
}
|
|
33675
34129
|
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
33676
34130
|
const targetBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
33677
34131
|
if (targetBusy) {
|
|
@@ -33762,7 +34216,7 @@ async function loadGitWorkflowMessage({ requireFresh = false, generationId, runI
|
|
|
33762
34216
|
if (existing?.key === loadKey) return existing.promise;
|
|
33763
34217
|
|
|
33764
34218
|
const promise = (async () => {
|
|
33765
|
-
|
|
34219
|
+
let deadline = Date.now() + (requireFresh ? GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS : 0);
|
|
33766
34220
|
const baseOutput = workflow.output || "Waiting for generated commit message files…";
|
|
33767
34221
|
let attempt = 0;
|
|
33768
34222
|
while (gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) {
|
|
@@ -33772,6 +34226,7 @@ async function loadGitWorkflowMessage({ requireFresh = false, generationId, runI
|
|
|
33772
34226
|
if (!message || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
33773
34227
|
if (message.ready === false) {
|
|
33774
34228
|
if (message.expired) throw new Error(message.reason || "This commit-message generation has expired. Regenerate the message files.");
|
|
34229
|
+
if (message.running === true) deadline = Date.now() + GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS;
|
|
33775
34230
|
if (!requireFresh || Date.now() >= deadline) {
|
|
33776
34231
|
throw new Error(`${message.reason || "Generated commit message files are not ready."} Regenerate, or use Preview current message files after verifying both files.`);
|
|
33777
34232
|
}
|
|
@@ -33844,6 +34299,10 @@ async function createGitPrBranchManually(tabId = gitWorkflowActionTabId()) {
|
|
|
33844
34299
|
|
|
33845
34300
|
async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
33846
34301
|
const tabContext = activeTabContext(tabId);
|
|
34302
|
+
if (!hasLoadedRpcCommand("git-branch-name", { tabId })) {
|
|
34303
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("git-branch-name")), "message", { tabId });
|
|
34304
|
+
return;
|
|
34305
|
+
}
|
|
33847
34306
|
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
33848
34307
|
const targetBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
33849
34308
|
if (targetBusy) {
|
|
@@ -34207,8 +34666,8 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
34207
34666
|
failGitWorkflow(new Error("Pi is currently running. Wait for it to finish or abort before generating a PR description."), "push", { tabId });
|
|
34208
34667
|
return;
|
|
34209
34668
|
}
|
|
34210
|
-
if (!
|
|
34211
|
-
failGitWorkflow(new Error(
|
|
34669
|
+
if (!hasLoadedRpcCommand("pr", { tabId })) {
|
|
34670
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("pr")), "push", { tabId });
|
|
34212
34671
|
return;
|
|
34213
34672
|
}
|
|
34214
34673
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -36659,11 +37118,8 @@ function assistantFailureDisplayMessage(message, base) {
|
|
|
36659
37118
|
function assistantDisplayMessages(message) {
|
|
36660
37119
|
if (message?.role !== "assistant") return [message];
|
|
36661
37120
|
const failure = assistantFailureDisplayMessage(message, { timestamp: message.timestamp });
|
|
36662
|
-
|
|
36663
|
-
|
|
36664
|
-
return [...rest, failure];
|
|
36665
|
-
}
|
|
36666
|
-
return assistantDisplayMessagesWithoutFailure(message);
|
|
37121
|
+
const displayMessages = assistantDisplayMessagesWithoutFailure(failure ? { ...message, stopReason: undefined } : message);
|
|
37122
|
+
return groupConsecutiveThinkingMessages(failure ? [...displayMessages, failure] : displayMessages);
|
|
36667
37123
|
}
|
|
36668
37124
|
|
|
36669
37125
|
function assistantDisplayMessagesWithoutFailure(message) {
|
|
@@ -38729,6 +39185,24 @@ function groupWorkflowStatusTranscriptItems(items, toolResults) {
|
|
|
38729
39185
|
return groupConsecutiveWorkflowStatusItems(projected);
|
|
38730
39186
|
}
|
|
38731
39187
|
|
|
39188
|
+
function transcriptItemThinkingMessage(item) {
|
|
39189
|
+
if (!thinkingOutputVisible) return null;
|
|
39190
|
+
const message = item?.message;
|
|
39191
|
+
const displayMessages = message?.role === "assistant" ? assistantDisplayMessages(message) : [message];
|
|
39192
|
+
if (displayMessages.length !== 1 || displayMessages[0]?.role !== "thinking") return null;
|
|
39193
|
+
const candidate = displayMessages[0];
|
|
39194
|
+
const thinking = visibleThinkingText(candidate.thinking || textFromContent(candidate.content));
|
|
39195
|
+
return thinking ? { ...candidate, content: thinking, thinking } : null;
|
|
39196
|
+
}
|
|
39197
|
+
|
|
39198
|
+
function groupConsecutiveThinkingTranscriptItems(items) {
|
|
39199
|
+
return groupConsecutiveThinkingItems(items, transcriptItemThinkingMessage).map((item) => {
|
|
39200
|
+
if (!(item.thinkingGroupSourceCount > 1)) return item;
|
|
39201
|
+
const sourceKey = item.transcriptKey || `${item.transient ? "t" : "m"}:${item.messageIndex}:${item.order}`;
|
|
39202
|
+
return { ...item, messageIndex: -1, transcriptKey: `thinking-group:${sourceKey}` };
|
|
39203
|
+
});
|
|
39204
|
+
}
|
|
39205
|
+
|
|
38732
39206
|
function orderedTranscriptItems() {
|
|
38733
39207
|
const items = compactOutputActive() ? compactStoredTranscriptItems() : [];
|
|
38734
39208
|
const assistantToolCallIds = buildAssistantToolCallIdSet(latestMessages);
|
|
@@ -38754,7 +39228,8 @@ function orderedTranscriptItems() {
|
|
|
38754
39228
|
}
|
|
38755
39229
|
}
|
|
38756
39230
|
const ordered = items.sort((a, b) => a.timestampMs - b.timestampMs || a.order - b.order);
|
|
38757
|
-
|
|
39231
|
+
const groupedThinking = compactOutputActive() ? ordered : groupConsecutiveThinkingTranscriptItems(ordered);
|
|
39232
|
+
return groupWorkflowStatusTranscriptItems(groupedThinking, toolResults);
|
|
38758
39233
|
}
|
|
38759
39234
|
|
|
38760
39235
|
/**
|
|
@@ -40781,7 +41256,7 @@ function updateOptionalFeatureAvailability() {
|
|
|
40781
41256
|
optionalFeatureAvailability.bangCommandAutocomplete = hasAvailableCommand("bang-status") || hasAvailableCommand("bang-refresh");
|
|
40782
41257
|
optionalFeatureAvailability.fishUserBash = hasAvailableCommand("user-bash-shell");
|
|
40783
41258
|
optionalFeatureAvailability.btwCommand = hasAvailableCommand("btw") || optionalFeatureAvailability.btwCommand || statusEntries.has(BTW_WEBUI_STATUS_KEY) || widgets.has(BTW_OUTPUT_WIDGET_KEY);
|
|
40784
|
-
optionalFeatureAvailability.gitWorkflow = hasAvailableCommand("git-staged-msg");
|
|
41259
|
+
optionalFeatureAvailability.gitWorkflow = hasAvailableCommand("git-guided-workflow") || hasAvailableCommand("git-staged-msg");
|
|
40785
41260
|
optionalFeatureAvailability.releaseNpm = hasAvailableCommand("release-npm");
|
|
40786
41261
|
optionalFeatureAvailability.releaseAur = hasAvailableCommand("release-aur");
|
|
40787
41262
|
optionalFeatureAvailability.aurReview = hasAvailableCommand("aur-review") || optionalFeatureAvailability.aurReview || widgets.has(AUR_REVIEW_RPC_WIDGET_KEY);
|
|
@@ -41008,7 +41483,7 @@ function renderOptionalFeatureSection(section, features) {
|
|
|
41008
41483
|
|
|
41009
41484
|
function optionalFeatureSetupAvailable(feature) {
|
|
41010
41485
|
switch (feature?.setup) {
|
|
41011
|
-
case "git-workflow": return
|
|
41486
|
+
case "git-workflow": return true;
|
|
41012
41487
|
case "workflows": return hasLoadedRpcCommand("workflow-setup");
|
|
41013
41488
|
case "safety-guard": return hasAvailableCommand("safety-guard-setup");
|
|
41014
41489
|
case "skills": return hasLoadedRpcCommand("skills");
|
|
@@ -43108,21 +43583,50 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
43108
43583
|
}, "primary");
|
|
43109
43584
|
}
|
|
43110
43585
|
|
|
43111
|
-
async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
43586
|
+
async function openNativeGitWorkflowSetupDialog({ onSaved, tabId = activeTabId, activationIsCurrent = () => true } = {}) {
|
|
43587
|
+
if (!tabId || !activationIsCurrent()) return "stale";
|
|
43588
|
+
nativeCommandTabId = tabId;
|
|
43112
43589
|
openNativeCommandDialog({
|
|
43113
43590
|
title: "/git-workflow-setup",
|
|
43114
43591
|
message: "Configure the dedicated model and safe defaults used by Guided Git. The selected generation profile is applied only while commit, branch, or PR text is generated.",
|
|
43115
43592
|
});
|
|
43116
43593
|
renderNativeLoading("Loading guided Git preferences and available models…");
|
|
43117
43594
|
|
|
43595
|
+
const setupOwner = Symbol(tabId);
|
|
43596
|
+
guidedGitSetupDialogOwner = setupOwner;
|
|
43597
|
+
const setupOwnsDialog = () => guidedGitSetupDialogOwner === setupOwner;
|
|
43598
|
+
const closeOwnedSetupDialog = () => {
|
|
43599
|
+
if (setupOwnsDialog()) closeNativeCommandDialog({ force: true });
|
|
43600
|
+
};
|
|
43601
|
+
let setupSettled = false;
|
|
43602
|
+
let saveInFlight = false;
|
|
43603
|
+
let resolveSetup;
|
|
43604
|
+
const setupSettlement = new Promise((resolve) => { resolveSetup = resolve; });
|
|
43605
|
+
const settleSetup = (status) => {
|
|
43606
|
+
if (setupSettled) return;
|
|
43607
|
+
setupSettled = true;
|
|
43608
|
+
if (setupOwnsDialog()) guidedGitSetupDialogOwner = null;
|
|
43609
|
+
elements.nativeCommandDialog.removeEventListener("close", handleSetupClose);
|
|
43610
|
+
resolveSetup(status);
|
|
43611
|
+
};
|
|
43612
|
+
const handleSetupClose = () => {
|
|
43613
|
+
if (!saveInFlight) settleSetup("cancelled");
|
|
43614
|
+
};
|
|
43615
|
+
elements.nativeCommandDialog.addEventListener("close", handleSetupClose);
|
|
43616
|
+
|
|
43118
43617
|
let data;
|
|
43119
43618
|
try {
|
|
43120
|
-
const response = await nativeCommandApi("/api/git-workflow/preferences");
|
|
43619
|
+
const response = await nativeCommandApi("/api/git-workflow/preferences", { tabId });
|
|
43121
43620
|
data = response.data || {};
|
|
43122
43621
|
} catch (error) {
|
|
43123
43622
|
setNativeCommandError(error.message || String(error));
|
|
43124
43623
|
elements.nativeCommandBody.replaceChildren();
|
|
43125
|
-
return;
|
|
43624
|
+
return setupSettlement;
|
|
43625
|
+
}
|
|
43626
|
+
if (!activationIsCurrent()) {
|
|
43627
|
+
closeOwnedSetupDialog();
|
|
43628
|
+
settleSetup("stale");
|
|
43629
|
+
return setupSettlement;
|
|
43126
43630
|
}
|
|
43127
43631
|
|
|
43128
43632
|
const preferences = data.preferences || {};
|
|
@@ -43130,12 +43634,13 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
43130
43634
|
if (!models.length) {
|
|
43131
43635
|
setNativeCommandError("No authenticated Pi models are available. Run /login or configure a provider first.");
|
|
43132
43636
|
elements.nativeCommandBody.replaceChildren();
|
|
43133
|
-
return;
|
|
43637
|
+
return setupSettlement;
|
|
43134
43638
|
}
|
|
43135
43639
|
|
|
43136
43640
|
const configuredModelKey = `${preferences.generation?.provider || ""}/${preferences.generation?.modelId || ""}`;
|
|
43137
43641
|
const configuredFallbackKey = `${preferences.generation?.fallback?.provider || ""}/${preferences.generation?.fallback?.modelId || ""}`;
|
|
43138
|
-
const
|
|
43642
|
+
const targetState = tabId === activeTabId ? currentState : tabStateCache.get(tabId);
|
|
43643
|
+
const activeModelKey = gitWorkflowSetupModelKey(targetState?.model);
|
|
43139
43644
|
const modelKeys = new Set(models.map(gitWorkflowSetupModelKey));
|
|
43140
43645
|
const initialModelKey = modelKeys.has(configuredModelKey)
|
|
43141
43646
|
? configuredModelKey
|
|
@@ -43231,9 +43736,15 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
43231
43736
|
addNativeCommandAction("Cancel", closeNativeCommandDialog);
|
|
43232
43737
|
|
|
43233
43738
|
const save = addNativeCommandAction("Save setup", async () => {
|
|
43739
|
+
saveInFlight = true;
|
|
43234
43740
|
setNativeActionBusy(save, true, "Saving…");
|
|
43235
43741
|
setNativeCommandError("");
|
|
43236
43742
|
try {
|
|
43743
|
+
if (!activationIsCurrent()) {
|
|
43744
|
+
closeOwnedSetupDialog();
|
|
43745
|
+
settleSetup("stale");
|
|
43746
|
+
return;
|
|
43747
|
+
}
|
|
43237
43748
|
const selectedModel = models.find((model) => gitWorkflowSetupModelKey(model) === controls.model.select.value);
|
|
43238
43749
|
if (!selectedModel) throw new Error("Select an available primary Git-writing model.");
|
|
43239
43750
|
const selectedFallback = models.find((model) => gitWorkflowSetupModelKey(model) === controls.fallbackModel.select.value) || null;
|
|
@@ -43242,6 +43753,7 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
43242
43753
|
}
|
|
43243
43754
|
const response = await nativeCommandApi("/api/git-workflow/preferences", {
|
|
43244
43755
|
method: "POST",
|
|
43756
|
+
tabId,
|
|
43245
43757
|
body: {
|
|
43246
43758
|
preferences: {
|
|
43247
43759
|
generation: {
|
|
@@ -43267,6 +43779,11 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
43267
43779
|
},
|
|
43268
43780
|
},
|
|
43269
43781
|
});
|
|
43782
|
+
if (!activationIsCurrent()) {
|
|
43783
|
+
closeOwnedSetupDialog();
|
|
43784
|
+
settleSetup("stale");
|
|
43785
|
+
return;
|
|
43786
|
+
}
|
|
43270
43787
|
gitWorkflowPreferences = response.data?.preferences || null;
|
|
43271
43788
|
addTransientMessage({
|
|
43272
43789
|
role: "native",
|
|
@@ -43274,14 +43791,25 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
43274
43791
|
content: `Guided Git setup saved. Primary: ${gitWorkflowSetupModelKey(selectedModel)} at ${controls.thinking.select.value} effort. ${selectedFallback ? `Fallback: ${gitWorkflowSetupModelKey(selectedFallback)} at ${controls.fallbackThinking.select.value} effort (one attempt after a final primary generation failure).` : "Fallback: none."}`,
|
|
43275
43792
|
level: "info",
|
|
43276
43793
|
});
|
|
43277
|
-
|
|
43278
|
-
|
|
43794
|
+
nativeSettingsDirty = false;
|
|
43795
|
+
closeOwnedSetupDialog();
|
|
43796
|
+
if (typeof onSaved === "function" && activationIsCurrent()) {
|
|
43797
|
+
try {
|
|
43798
|
+
await onSaved(gitWorkflowPreferences);
|
|
43799
|
+
} catch (error) {
|
|
43800
|
+
addEvent(`Guided Git could not continue after setup: ${error?.message || String(error)}`, "error");
|
|
43801
|
+
}
|
|
43802
|
+
}
|
|
43803
|
+
settleSetup(activationIsCurrent() ? "saved" : "stale");
|
|
43279
43804
|
} catch (error) {
|
|
43280
43805
|
setNativeCommandError(error.message || String(error));
|
|
43281
43806
|
} finally {
|
|
43807
|
+
saveInFlight = false;
|
|
43282
43808
|
setNativeActionBusy(save, false);
|
|
43809
|
+
if (!elements.nativeCommandDialog.open) settleSetup("cancelled");
|
|
43283
43810
|
}
|
|
43284
43811
|
}, "primary");
|
|
43812
|
+
return setupSettlement;
|
|
43285
43813
|
}
|
|
43286
43814
|
|
|
43287
43815
|
function normalizedWorkflowPolicyList(value) {
|
|
@@ -46451,7 +46979,7 @@ function commandPaletteCoreItems() {
|
|
|
46451
46979
|
{ kind: "Pi", label: "/tools", description: "Manage active tools", keywords: "capabilities", run: () => runNativeCommandMenu("/tools") },
|
|
46452
46980
|
{ kind: "Pi", label: "/skills", description: "Manage active skills", keywords: "system prompt", run: () => runNativeCommandMenu("/skills") },
|
|
46453
46981
|
{ kind: "Pi", label: "/theme", description: "Choose the Web UI theme", keywords: "dark light colors appearance", run: () => openNativeThemeSelector() },
|
|
46454
|
-
{ kind: "Git", label: "Guided Git workflow", description: "Stage, commit, push, or open a pull request step by step", keywords: "git commit push pr publish", run: () =>
|
|
46982
|
+
{ kind: "Git", label: "Guided Git workflow", description: "Stage, commit, push, or open a pull request step by step", keywords: "git commit push pr publish", run: () => launchGuidedGitWorkflow() },
|
|
46455
46983
|
{ kind: "Git", label: "Git changes", description: "Review and stage local changes with diffs", keywords: "git diff stage unstage discard status", run: () => openGitChangesDialog() },
|
|
46456
46984
|
{ kind: "Action", label: "Files panel", description: "Open the Files section of the Control Deck", keywords: "tree browse project explorer", run: () => revealSidePanelSectionById("files") },
|
|
46457
46985
|
{ kind: "Action", label: "Git panel", description: "Open the Git section of the Control Deck", keywords: "repository status history", run: () => revealSidePanelSectionById("git") },
|
|
@@ -47197,6 +47725,17 @@ function createBrowserPromptRequestId() {
|
|
|
47197
47725
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
47198
47726
|
}
|
|
47199
47727
|
|
|
47728
|
+
function createBrowserGuidedGitLaunchId() {
|
|
47729
|
+
const generated = globalThis.crypto?.randomUUID?.();
|
|
47730
|
+
if (generated) return generated;
|
|
47731
|
+
const bytes = new Uint8Array(16);
|
|
47732
|
+
globalThis.crypto?.getRandomValues?.(bytes);
|
|
47733
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
47734
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
47735
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
47736
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
47737
|
+
}
|
|
47738
|
+
|
|
47200
47739
|
async function retryMobileFailedSend() {
|
|
47201
47740
|
const pending = mobileFailedSend;
|
|
47202
47741
|
if (!pending || pending.retrying) return;
|
|
@@ -47257,8 +47796,24 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
47257
47796
|
return;
|
|
47258
47797
|
}
|
|
47259
47798
|
|
|
47260
|
-
const
|
|
47261
|
-
|
|
47799
|
+
const guidedGitExtensionLaunch = kind === "prompt"
|
|
47800
|
+
&& attachments.length === 0
|
|
47801
|
+
&& guidedGitWorkflowCommandForTabCatalog(commandCatalogForTab(targetTabId), originalMessage);
|
|
47802
|
+
let guidedGitPermitGranted = false;
|
|
47803
|
+
let guidedGitLaunchId = "";
|
|
47804
|
+
if (guidedGitExtensionLaunch) {
|
|
47805
|
+
if (!guidedGitLaunchAdmitted(targetTabId)) return;
|
|
47806
|
+
guidedGitLaunchId = createBrowserGuidedGitLaunchId();
|
|
47807
|
+
if (!guidedGitLaunchPermits.grant(targetTabId, guidedGitLaunchId)) {
|
|
47808
|
+
addEvent("Guided Git activation is already pending for this tab.", "warn");
|
|
47809
|
+
return;
|
|
47810
|
+
}
|
|
47811
|
+
guidedGitPermitGranted = true;
|
|
47812
|
+
}
|
|
47813
|
+
|
|
47814
|
+
const targetState = targetTabId === activeTabId ? currentState : tabStateCache.get(targetTabId);
|
|
47815
|
+
const targetWasStreaming = !!targetState?.isStreaming;
|
|
47816
|
+
const targetWasCompacting = !!targetState?.isCompacting;
|
|
47262
47817
|
const targetWasBusy = targetWasStreaming || targetWasCompacting;
|
|
47263
47818
|
const busyBehavior = normalizeBusyPromptBehavior(busyPromptBehavior);
|
|
47264
47819
|
const startsRun = kind === "prompt" && !targetWasBusy;
|
|
@@ -47289,6 +47844,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
47289
47844
|
// targetTabId. This implementation intentionally never retries an
|
|
47290
47845
|
// ambiguous mutation automatically.
|
|
47291
47846
|
if (kind === "prompt") bodyBase.requestId = createBrowserPromptRequestId();
|
|
47847
|
+
if (guidedGitLaunchId) bodyBase.guidedGitLaunchId = guidedGitLaunchId;
|
|
47292
47848
|
if (prepared.images.length) bodyBase.images = prepared.images;
|
|
47293
47849
|
if (!message.startsWith("/")) {
|
|
47294
47850
|
rememberPromptHistory(message, { tabId: targetTabId });
|
|
@@ -47338,6 +47894,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
47338
47894
|
scheduleRefreshTabs(300);
|
|
47339
47895
|
}
|
|
47340
47896
|
} catch (error) {
|
|
47897
|
+
if (guidedGitPermitGranted) guidedGitLaunchPermits.clearTab(targetTabId);
|
|
47341
47898
|
restorePromptInputAfterRoutingError(inputMessage, { usesPromptInput, targetTabId, tabContext });
|
|
47342
47899
|
if (dispatchedRequest?.kind === "prompt" && dispatchedRequest.body?.requestId && error?.backendOffline === true && isMobileShellV2Active()) {
|
|
47343
47900
|
mobileFailedSend = { ...dispatchedRequest, retrying: false };
|
|
@@ -47382,6 +47939,7 @@ function removeQueuedDialogRequests(ids = []) {
|
|
|
47382
47939
|
}
|
|
47383
47940
|
|
|
47384
47941
|
function handleExtensionUiRequest(request) {
|
|
47942
|
+
if (handleGuidedGitActivationRequest(request)) return;
|
|
47385
47943
|
request.tabId ||= activeTabId;
|
|
47386
47944
|
switch (request.method) {
|
|
47387
47945
|
case "notify": {
|
|
@@ -47945,6 +48503,7 @@ function scheduleSupervisorContinuityRefresh(event, { gap = false } = {}) {
|
|
|
47945
48503
|
}
|
|
47946
48504
|
|
|
47947
48505
|
function handleInactiveTabEvent(event) {
|
|
48506
|
+
if (handleGuidedGitActivationRequest(event)) return;
|
|
47948
48507
|
if (event.type === "extension_ui_request" && EXTENSION_UI_BLOCKING_METHODS.has(event.method)) {
|
|
47949
48508
|
if (!event.replayed) notifyBlockedTab(event.tabId, { request: event, count: event.pendingExtensionUiRequestCount });
|
|
47950
48509
|
renderTabs();
|
|
@@ -48698,7 +49257,7 @@ elements.commandPaletteButton?.addEventListener("click", () => openCommandPalett
|
|
|
48698
49257
|
elements.workspaceDashboardToggleButton?.addEventListener("click", () => setWorkspaceDashboardCollapsed(!workspaceDashboardCollapsed));
|
|
48699
49258
|
elements.gitWorkflowButton.addEventListener("click", () => {
|
|
48700
49259
|
setComposerActionsOpen(false);
|
|
48701
|
-
|
|
49260
|
+
launchGuidedGitWorkflow();
|
|
48702
49261
|
});
|
|
48703
49262
|
const publishMenuContainer = elements.publishButton.parentElement;
|
|
48704
49263
|
elements.publishButton.addEventListener("click", () => {
|
|
@@ -50055,6 +50614,7 @@ window.addEventListener("storage", (event) => {
|
|
|
50055
50614
|
footerScopedModels = orderedFooterScopedModels();
|
|
50056
50615
|
renderFooter();
|
|
50057
50616
|
}
|
|
50617
|
+
if (event.key === FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY) setFooterScopedModelLayout(event.newValue, { persist: false });
|
|
50058
50618
|
if (event.key === FILE_VIEWER_WIDTH_STORAGE_KEY) restoreFileViewerWidthPreference();
|
|
50059
50619
|
});
|
|
50060
50620
|
// Durable layout reconciliation runs on its own foreground/online lifecycle
|
|
@@ -50122,7 +50682,7 @@ window.addEventListener("keydown", (event) => {
|
|
|
50122
50682
|
return;
|
|
50123
50683
|
}
|
|
50124
50684
|
if (isFooterPickerOpen()) {
|
|
50125
|
-
setFooterModelPickerOpen(false);
|
|
50685
|
+
setFooterModelPickerOpen(false, { restoreFocus: footerModelPickerOpen });
|
|
50126
50686
|
setFooterThinkingPickerOpen(false);
|
|
50127
50687
|
setFooterBranchPickerOpen(false);
|
|
50128
50688
|
return;
|
|
@@ -50401,7 +50961,7 @@ elements.controlVisibilitySetupCloseButton?.addEventListener("click", () => elem
|
|
|
50401
50961
|
elements.controlVisibilitySetupDialog?.querySelector("form")?.addEventListener("submit", (event) => event.preventDefault());
|
|
50402
50962
|
elements.controlVisibilitySetupDialog?.addEventListener("close", restoreControlVisibilitySetupFocus);
|
|
50403
50963
|
elements.gitFooterContextMenu?.addEventListener("keydown", (event) => {
|
|
50404
|
-
const items = [...elements.gitFooterContextMenu.querySelectorAll('[role="menuitem"]:not([disabled])')];
|
|
50964
|
+
const items = [...elements.gitFooterContextMenu.querySelectorAll('[role="menuitem"]:not([disabled]):not([hidden]), [role="menuitemcheckbox"]:not([disabled]):not([hidden])')];
|
|
50405
50965
|
const index = items.indexOf(document.activeElement);
|
|
50406
50966
|
if (event.key === "Escape") {
|
|
50407
50967
|
event.preventDefault();
|
|
@@ -50422,6 +50982,7 @@ elements.gitFooterContextMenu?.addEventListener("click", (event) => {
|
|
|
50422
50982
|
const action = button.dataset.gitFooterMenuAction;
|
|
50423
50983
|
closeGitFooterContextMenu({ returnFocus: action !== "visibility" });
|
|
50424
50984
|
if (action === "disable") void disableGitFooterContextChip(state.key, state.label);
|
|
50985
|
+
else if (action === "toggle-advanced" && state.key === "model") toggleFooterScopedModelLayout();
|
|
50425
50986
|
else if (action === "visibility") openGitFooterVisibilityDialog();
|
|
50426
50987
|
});
|
|
50427
50988
|
elements.fileTreeNewFileButton?.addEventListener("click", () => createFileTreeEntry(null, "file").catch((error) => addEvent(error.message || String(error), "error")));
|
|
@@ -50515,6 +51076,13 @@ elements.fileSelectionCommentInput?.addEventListener("keydown", (event) => {
|
|
|
50515
51076
|
event.preventDefault();
|
|
50516
51077
|
sendFileSelectionToSession();
|
|
50517
51078
|
});
|
|
51079
|
+
elements.pathPickerPathInput.addEventListener("input", updatePathPickerPathControls);
|
|
51080
|
+
elements.pathPickerPathInput.addEventListener("keydown", (event) => {
|
|
51081
|
+
if (event.key !== "Enter") return;
|
|
51082
|
+
event.preventDefault();
|
|
51083
|
+
openPathPickerEnteredPath().catch((error) => addEvent(error.message, "error"));
|
|
51084
|
+
});
|
|
51085
|
+
elements.pathPickerPathButton.addEventListener("click", () => openPathPickerEnteredPath().catch((error) => addEvent(error.message, "error")));
|
|
50518
51086
|
elements.pathPickerCreateNameInput.addEventListener("input", updateCreateDirectoryControls);
|
|
50519
51087
|
elements.pathPickerCreateNameInput.addEventListener("keydown", (event) => {
|
|
50520
51088
|
if (event.key !== "Enter") return;
|