@firstpick/pi-package-webui 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/bin/pi-webui.mjs +480 -96
- package/index.ts +2 -1
- package/lib/git-workflow-preferences.mjs +21 -1
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-tree-event-targets.mjs +70 -0
- package/lib/subagent-launch-policy.mjs +375 -0
- package/lib/subagent-launch-slots.mjs +2 -1
- package/package.json +1 -1
- package/public/app.js +1348 -131
- package/public/guided-git-command-state.mjs +175 -1
- package/public/index.html +48 -9
- package/public/service-worker.js +1 -1
- package/public/styles.css +387 -34
- package/public/transcript-renderer.mjs +62 -0
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/control-visibility.spec.mjs +141 -2
- package/tests/browser/events-tree-context-menu.spec.mjs +240 -0
- 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 +218 -0
- package/tests/browser/interaction-continuity.spec.mjs +33 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/compact-sections-static.test.mjs +4 -0
- 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 +66 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/events-tree-context-menu-static.test.mjs +131 -0
- package/tests/fast-mode-client-static.test.mjs +5 -2
- 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/git-workflow-preferences.test.mjs +30 -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 +419 -0
- package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
- package/tests/guided-git-message-reliability-static.test.mjs +9 -7
- 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 +92 -9
- 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/remote-auth-settings-harness.test.mjs +23 -0
- package/tests/resource-defaults-helper.test.mjs +12 -0
- package/tests/session-sampling-helper.test.mjs +1 -0
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/session-tree-event-targets.test.mjs +106 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/subagent-launch-policy.test.mjs +532 -0
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagents-helper.test.mjs +211 -1
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +25 -0
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-block-grouping.test.mjs +79 -0
- package/webui-rpc-helper.mjs +220 -3
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";
|
|
@@ -358,6 +358,14 @@ const elements = {
|
|
|
358
358
|
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
359
359
|
visibilityContextMenu: $("#visibilityContextMenu"),
|
|
360
360
|
gitFooterContextMenu: $("#gitFooterContextMenu"),
|
|
361
|
+
eventTreeContextMenu: $("#eventTreeContextMenu"),
|
|
362
|
+
eventFilterSelect: $("#eventFilterSelect"),
|
|
363
|
+
eventFilterStatus: $("#eventFilterStatus"),
|
|
364
|
+
eventFilterEmpty: $("#eventFilterEmpty"),
|
|
365
|
+
eventDisplayDetailedAction: $("#eventDisplayDetailedAction"),
|
|
366
|
+
eventDisplayCompactAction: $("#eventDisplayCompactAction"),
|
|
367
|
+
eventTreeContextMenuAction: $("#eventTreeContextMenuAction"),
|
|
368
|
+
eventTreeContextMenuStatus: $("#eventTreeContextMenuStatus"),
|
|
361
369
|
sidePanelResizeHandle: $("#sidePanelResizeHandle"),
|
|
362
370
|
sidePanelResizeHandleLeft: $("#sidePanelLeftResizeHandle"),
|
|
363
371
|
sidePanelLeftExpandButton: $("#sidePanelLeftExpandButton"),
|
|
@@ -566,6 +574,12 @@ const elements = {
|
|
|
566
574
|
appRunnerInfoDialog: $("#appRunnerInfoDialog"),
|
|
567
575
|
appRunnerInfoBody: $("#appRunnerInfoBody"),
|
|
568
576
|
appRunnerInfoCloseButton: $("#appRunnerInfoCloseButton"),
|
|
577
|
+
controlVisibilitySetupDialog: $("#controlVisibilitySetupDialog"),
|
|
578
|
+
controlVisibilitySetupBody: $("#controlVisibilitySetupBody"),
|
|
579
|
+
controlVisibilitySetupStatus: $("#controlVisibilitySetupStatus"),
|
|
580
|
+
controlVisibilitySetupShowAllButton: $("#controlVisibilitySetupShowAllButton"),
|
|
581
|
+
controlVisibilitySetupResetButton: $("#controlVisibilitySetupResetButton"),
|
|
582
|
+
controlVisibilitySetupCloseButton: $("#controlVisibilitySetupCloseButton"),
|
|
569
583
|
gitFooterVisibilityDialog: $("#gitFooterVisibilityDialog"),
|
|
570
584
|
gitFooterVisibilityBody: $("#gitFooterVisibilityBody"),
|
|
571
585
|
gitFooterVisibilityStatus: $("#gitFooterVisibilityStatus"),
|
|
@@ -593,6 +607,9 @@ const transcriptRenderer = createTranscriptRenderer({
|
|
|
593
607
|
});
|
|
594
608
|
|
|
595
609
|
const PI_WEBUI_NPM_URL = "https://www.npmjs.com/package/@firstpick/pi-package-webui";
|
|
610
|
+
const EVENT_DISPLAY_MODE_STORAGE_KEY = "pi-webui-event-display-mode-v1";
|
|
611
|
+
const EVENT_FILTER_STORAGE_KEY = "pi-webui-event-filter-v1";
|
|
612
|
+
const EVENT_FILTER_VALUES = new Set(["all", "errors", "warnings", "tools", "tree"]);
|
|
596
613
|
|
|
597
614
|
let currentState = null;
|
|
598
615
|
let tabStateCache = new Map();
|
|
@@ -626,6 +643,10 @@ let fileViewerSearchTimer = null;
|
|
|
626
643
|
let fileContextMenuState = null;
|
|
627
644
|
let sidePanelContextMenuState = null;
|
|
628
645
|
let gitFooterContextMenuState = null;
|
|
646
|
+
let eventTreeContextMenuState = null;
|
|
647
|
+
let eventDisplayMode = readStoredEventDisplayMode();
|
|
648
|
+
let eventFilter = readStoredEventFilter();
|
|
649
|
+
const toolEventStartedAt = new Map();
|
|
629
650
|
let sidePanelSectionEditMode = false;
|
|
630
651
|
let sidePanelSectionPointerDrag = null;
|
|
631
652
|
let sidePanelSectionLastDragOverKey = "";
|
|
@@ -1034,6 +1055,7 @@ const supervisorEventCursors = new Map();
|
|
|
1034
1055
|
const supervisorRetiredEpochs = new Map();
|
|
1035
1056
|
const supervisorGapWarnings = new Set();
|
|
1036
1057
|
const supervisorContinuityRefreshes = new Map();
|
|
1058
|
+
const closingTerminalTabIds = new Set();
|
|
1037
1059
|
const supervisorEnvelopeWarnings = new Set();
|
|
1038
1060
|
let activeDialog = null;
|
|
1039
1061
|
let activeDialogCancel = null;
|
|
@@ -1064,6 +1086,7 @@ let gitChangesRequestSerial = 0;
|
|
|
1064
1086
|
const gitChangesUntrackedContentRequests = new Set();
|
|
1065
1087
|
let nativeCommandTabId = null;
|
|
1066
1088
|
let nativeSettingsDirty = false;
|
|
1089
|
+
let guidedGitSetupDialogOwner = null;
|
|
1067
1090
|
let sessionSummaryOverlayTabId = null;
|
|
1068
1091
|
let sessionSummaryOverlayFocusReturn = null;
|
|
1069
1092
|
let sessionSummaryOverlayFocusReturnKey = "";
|
|
@@ -1256,6 +1279,7 @@ let customBackgroundLoading = false;
|
|
|
1256
1279
|
let footerScopedModels = [];
|
|
1257
1280
|
let footerScopedModelPatterns = [];
|
|
1258
1281
|
let footerScopedModelSource = "none";
|
|
1282
|
+
let footerScopedModelLayout = "flat";
|
|
1259
1283
|
const contextUsageUnknownAfterCompactionByTab = new Map();
|
|
1260
1284
|
let autoFollowChat = true;
|
|
1261
1285
|
let chatFollowFrame = null;
|
|
@@ -1269,6 +1293,7 @@ let chatPausedScrollRestoreUntil = 0;
|
|
|
1269
1293
|
let chatLastTouchClientY = null;
|
|
1270
1294
|
let mobileFooterExpanded = false;
|
|
1271
1295
|
let footerModelPickerOpen = false;
|
|
1296
|
+
let footerModelApplyInFlight = false;
|
|
1272
1297
|
let footerThinkingPickerOpen = false;
|
|
1273
1298
|
let footerAutoCompactionToggleInFlight = false;
|
|
1274
1299
|
let footerBranchPickerOpen = false;
|
|
@@ -1347,6 +1372,8 @@ const SUBAGENT_AUTO_CLEAR_STORAGE_KEY = "pi-webui-subagent-auto-clear";
|
|
|
1347
1372
|
const TERMINAL_CUSTOM_GROUPS_STORAGE_KEY = "pi-webui-terminal-custom-groups-v1";
|
|
1348
1373
|
const TERMINAL_TAB_DRAG_MIME = "application/x-pi-terminal-tab-id";
|
|
1349
1374
|
const FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY = "pi-webui-footer-scoped-model-order-v1";
|
|
1375
|
+
const FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY = "pi-webui-footer-scoped-model-layout-v1";
|
|
1376
|
+
footerScopedModelLayout = readStoredFooterScopedModelLayout();
|
|
1350
1377
|
const FOOTER_SCOPED_MODEL_POINTER_DRAG_THRESHOLD_PX = 6;
|
|
1351
1378
|
const TOOL_OUTPUT_EXPANDED_STORAGE_KEY = "pi-webui-tool-output-expanded";
|
|
1352
1379
|
const THEME_STORAGE_KEY = "pi-webui-theme";
|
|
@@ -2797,9 +2824,9 @@ const OPTIONAL_FEATURES = [
|
|
|
2797
2824
|
{
|
|
2798
2825
|
id: "gitWorkflow",
|
|
2799
2826
|
label: "Guided Git workflow",
|
|
2800
|
-
packageName: "@firstpick/pi-
|
|
2801
|
-
capabilityLabel: "/git-
|
|
2802
|
-
description: "
|
|
2827
|
+
packageName: "@firstpick/pi-extension-git-guided-workflow",
|
|
2828
|
+
capabilityLabel: "/git-guided-workflow",
|
|
2829
|
+
description: "Cross-surface launcher with bundled commit, branch, and pull-request prompt templates.",
|
|
2803
2830
|
setup: "git-workflow",
|
|
2804
2831
|
},
|
|
2805
2832
|
{
|
|
@@ -3348,6 +3375,7 @@ const OPTIONAL_COMMAND_FEATURES = new Map([
|
|
|
3348
3375
|
["btw", "btwCommand"],
|
|
3349
3376
|
["btw-transfer", "btwCommand"],
|
|
3350
3377
|
["btw-status", "btwCommand"],
|
|
3378
|
+
["git-guided-workflow", "gitWorkflow"],
|
|
3351
3379
|
["git-staged-msg", "gitWorkflow"],
|
|
3352
3380
|
["git-branch-name", "gitWorkflow"],
|
|
3353
3381
|
["pr", "gitWorkflow"],
|
|
@@ -3516,6 +3544,12 @@ function createGitWorkflowState() {
|
|
|
3516
3544
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
3517
3545
|
messageRequestedAt: 0,
|
|
3518
3546
|
messageGenerationId: "",
|
|
3547
|
+
generationId: "",
|
|
3548
|
+
generationKind: "",
|
|
3549
|
+
generationAccepted: false,
|
|
3550
|
+
fallbackStarted: false,
|
|
3551
|
+
fallbackLifecycleKeys: new Set(),
|
|
3552
|
+
pendingFallbackLifecycleEvents: [],
|
|
3519
3553
|
branchName: "",
|
|
3520
3554
|
branchNameRequestedAt: 0,
|
|
3521
3555
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -3532,6 +3566,10 @@ function createGitWorkflowState() {
|
|
|
3532
3566
|
|
|
3533
3567
|
const gitWorkflowsByTab = new Map();
|
|
3534
3568
|
const gitWorkflowMessageLoadsByTab = new Map();
|
|
3569
|
+
const guidedGitLaunchPermits = createGuidedGitLaunchPermitController();
|
|
3570
|
+
const guidedGitActivationController = createGuidedGitActivationController({
|
|
3571
|
+
claimStart: (tabId, _payload, request, now) => guidedGitLaunchPermits.consume(tabId, request?.guidedGitLaunchId, now),
|
|
3572
|
+
});
|
|
3535
3573
|
let gitWorkflow = createGitWorkflowState();
|
|
3536
3574
|
let gitWorkflowPreferences = null;
|
|
3537
3575
|
|
|
@@ -3556,6 +3594,8 @@ function gitWorkflowActionTabId() {
|
|
|
3556
3594
|
|
|
3557
3595
|
function resetGitWorkflowForTab(tabId = activeTabId) {
|
|
3558
3596
|
if (!tabId) return;
|
|
3597
|
+
guidedGitLaunchPermits.clearTab(tabId);
|
|
3598
|
+
guidedGitActivationController.clearTab(tabId);
|
|
3559
3599
|
gitWorkflowsByTab.set(tabId, createGitWorkflowState());
|
|
3560
3600
|
if (tabId === activeTabId) {
|
|
3561
3601
|
bindGitWorkflowToActiveTab();
|
|
@@ -3565,6 +3605,8 @@ function resetGitWorkflowForTab(tabId = activeTabId) {
|
|
|
3565
3605
|
|
|
3566
3606
|
function clearGitWorkflowForTab(tabId) {
|
|
3567
3607
|
if (!tabId) return;
|
|
3608
|
+
guidedGitLaunchPermits.clearTab(tabId);
|
|
3609
|
+
guidedGitActivationController.clearTab(tabId);
|
|
3568
3610
|
gitWorkflowsByTab.delete(tabId);
|
|
3569
3611
|
if (tabId === activeTabId) {
|
|
3570
3612
|
bindGitWorkflowToActiveTab();
|
|
@@ -4553,6 +4595,7 @@ function showSidePanelContextMenu(event) {
|
|
|
4553
4595
|
closeFileContextMenu({ returnFocus: false });
|
|
4554
4596
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
4555
4597
|
closeSidePanelContextMenu({ returnFocus: false });
|
|
4598
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
4556
4599
|
|
|
4557
4600
|
const menu = elements.sidePanelContextMenu;
|
|
4558
4601
|
const eventTrigger = event.currentTarget;
|
|
@@ -7420,10 +7463,13 @@ function isAbortAvailable() {
|
|
|
7420
7463
|
function resizePromptInput() {
|
|
7421
7464
|
const input = elements.promptInput;
|
|
7422
7465
|
input.style.height = "auto";
|
|
7423
|
-
const
|
|
7424
|
-
const
|
|
7425
|
-
|
|
7426
|
-
input.
|
|
7466
|
+
const style = getComputedStyle(input);
|
|
7467
|
+
const maxHeight = Number.parseFloat(style.maxHeight);
|
|
7468
|
+
const borderBlock = Number.parseFloat(style.borderTopWidth) + Number.parseFloat(style.borderBottomWidth);
|
|
7469
|
+
const naturalHeight = input.scrollHeight + borderBlock;
|
|
7470
|
+
const isCapped = Number.isFinite(maxHeight) && naturalHeight > Math.ceil(maxHeight);
|
|
7471
|
+
input.style.height = `${Math.ceil(isCapped ? maxHeight : naturalHeight)}px`;
|
|
7472
|
+
input.style.overflowY = isCapped ? "auto" : "hidden";
|
|
7427
7473
|
}
|
|
7428
7474
|
|
|
7429
7475
|
function updateComposerModeButtons() {
|
|
@@ -12777,6 +12823,7 @@ function showFileContextMenu(event, entry) {
|
|
|
12777
12823
|
event.stopPropagation();
|
|
12778
12824
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
12779
12825
|
closeSidePanelContextMenu({ returnFocus: false });
|
|
12826
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
12780
12827
|
const path = normalizeFileTreePath(entry?.path || "");
|
|
12781
12828
|
fileContextMenuState = { entry: { ...entry, path }, trigger: event.currentTarget || document.activeElement };
|
|
12782
12829
|
const menu = elements.fileContextMenu;
|
|
@@ -13550,6 +13597,7 @@ function applyControlVisibility(hiddenIdsOverride) {
|
|
|
13550
13597
|
}
|
|
13551
13598
|
// Hiding composer actions leaves grid holes; repack/restore the saved layout.
|
|
13552
13599
|
if (composerChanged) scheduleComposerActionSlotLayoutRestore();
|
|
13600
|
+
refreshControlVisibilitySetupDialog();
|
|
13553
13601
|
}
|
|
13554
13602
|
|
|
13555
13603
|
function persistControlVisibilityHiddenIds(hiddenIds) {
|
|
@@ -13574,6 +13622,71 @@ function resetControlVisibilityDefaults() {
|
|
|
13574
13622
|
}
|
|
13575
13623
|
|
|
13576
13624
|
let visibilityContextMenuState = null;
|
|
13625
|
+
let controlVisibilitySetupFocusReturn = null;
|
|
13626
|
+
|
|
13627
|
+
function setControlVisibilitySetupStatus(message = "") {
|
|
13628
|
+
if (elements.controlVisibilitySetupStatus) elements.controlVisibilitySetupStatus.textContent = message;
|
|
13629
|
+
}
|
|
13630
|
+
|
|
13631
|
+
function renderControlVisibilitySetupDialog() {
|
|
13632
|
+
const body = elements.controlVisibilitySetupBody;
|
|
13633
|
+
if (!body) return;
|
|
13634
|
+
const groups = CONTROL_VISIBILITY_GROUP_LABELS.map(([groupId, groupLabel], groupIndex) => {
|
|
13635
|
+
const fieldset = make("fieldset", "control-visibility-setup-group");
|
|
13636
|
+
fieldset.append(make("legend", "control-visibility-setup-group-label", groupLabel));
|
|
13637
|
+
const grid = make("div", "control-visibility-setup-grid");
|
|
13638
|
+
for (const [entryIndex, entry] of CONTROL_VISIBILITY_CATALOG.filter((item) => item.group === groupId).entries()) {
|
|
13639
|
+
const label = make("label", "control-visibility-setup-toggle");
|
|
13640
|
+
const checkbox = document.createElement("input");
|
|
13641
|
+
checkbox.type = "checkbox";
|
|
13642
|
+
checkbox.id = `controlVisibilitySetupToggle-${groupIndex}-${entryIndex}`;
|
|
13643
|
+
checkbox.dataset.visibilitySetupId = entry.id;
|
|
13644
|
+
checkbox.setAttribute("aria-label", `Show ${entry.label}`);
|
|
13645
|
+
label.htmlFor = checkbox.id;
|
|
13646
|
+
label.append(checkbox, make("span", "control-visibility-setup-toggle-label", entry.label));
|
|
13647
|
+
grid.append(label);
|
|
13648
|
+
}
|
|
13649
|
+
fieldset.append(grid);
|
|
13650
|
+
return fieldset;
|
|
13651
|
+
});
|
|
13652
|
+
body.replaceChildren(...groups);
|
|
13653
|
+
}
|
|
13654
|
+
|
|
13655
|
+
function refreshControlVisibilitySetupDialog() {
|
|
13656
|
+
const dialog = elements.controlVisibilitySetupDialog;
|
|
13657
|
+
const body = elements.controlVisibilitySetupBody;
|
|
13658
|
+
if (!dialog?.open || !body) return;
|
|
13659
|
+
const hiddenSet = new Set(userControlHiddenIds());
|
|
13660
|
+
for (const checkbox of body.querySelectorAll("[data-visibility-setup-id]")) {
|
|
13661
|
+
checkbox.checked = !hiddenSet.has(checkbox.dataset.visibilitySetupId);
|
|
13662
|
+
}
|
|
13663
|
+
const visibleCount = CONTROL_VISIBILITY_CATALOG.filter((entry) => !hiddenSet.has(entry.id)).length;
|
|
13664
|
+
setControlVisibilitySetupStatus(`${visibleCount} of ${CONTROL_VISIBILITY_CATALOG.length} optional controls shown by preference.`);
|
|
13665
|
+
}
|
|
13666
|
+
|
|
13667
|
+
function openControlVisibilitySetupDialog(trigger = null) {
|
|
13668
|
+
const dialog = elements.controlVisibilitySetupDialog;
|
|
13669
|
+
if (!dialog) return;
|
|
13670
|
+
controlVisibilitySetupFocusReturn = trigger instanceof HTMLElement ? trigger : elements.promptInput;
|
|
13671
|
+
if (!elements.controlVisibilitySetupBody?.childElementCount) renderControlVisibilitySetupDialog();
|
|
13672
|
+
if (!dialog.open) dialog.showModal();
|
|
13673
|
+
refreshControlVisibilitySetupDialog();
|
|
13674
|
+
queueMicrotask(() => elements.controlVisibilitySetupBody?.querySelector("input")?.focus({ preventScroll: true }));
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13677
|
+
function restoreControlVisibilitySetupFocus() {
|
|
13678
|
+
const trigger = controlVisibilitySetupFocusReturn;
|
|
13679
|
+
controlVisibilitySetupFocusReturn = null;
|
|
13680
|
+
const triggerSurvives = trigger
|
|
13681
|
+
&& trigger.isConnected
|
|
13682
|
+
&& !trigger.closest?.("[hidden], .webui-user-hidden")
|
|
13683
|
+
&& typeof trigger.focus === "function";
|
|
13684
|
+
requestAnimationFrame(() => {
|
|
13685
|
+
if (triggerSurvives) trigger.focus({ preventScroll: true });
|
|
13686
|
+
else elements.promptInput?.focus({ preventScroll: true });
|
|
13687
|
+
});
|
|
13688
|
+
}
|
|
13689
|
+
|
|
13577
13690
|
|
|
13578
13691
|
function closeVisibilityContextMenu({ returnFocus = true } = {}) {
|
|
13579
13692
|
const trigger = visibilityContextMenuState?.trigger;
|
|
@@ -13620,6 +13733,7 @@ function prepareControlVisibilityMenu(trigger, entryId = null) {
|
|
|
13620
13733
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
13621
13734
|
closeSidePanelContextMenu({ returnFocus: false });
|
|
13622
13735
|
closeGitFooterContextMenu({ returnFocus: false });
|
|
13736
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
13623
13737
|
closeVisibilityContextMenu({ returnFocus: false });
|
|
13624
13738
|
// Region hosts are plain non-focusable containers; storing one as the
|
|
13625
13739
|
// trigger would let Escape focus fall through to <body>. Fall back to the
|
|
@@ -13639,12 +13753,13 @@ function prepareControlVisibilityMenu(trigger, entryId = null) {
|
|
|
13639
13753
|
|
|
13640
13754
|
// Right-clicking a visible registered control offers Hide <label> plus the
|
|
13641
13755
|
// recovery actions; empty marked regions open the grouped full catalog.
|
|
13642
|
-
function showControlVisibilityDirectMenu(entry,
|
|
13643
|
-
const menu = prepareControlVisibilityMenu(
|
|
13756
|
+
function showControlVisibilityDirectMenu(entry, focusTrigger, { clientX, clientY }) {
|
|
13757
|
+
const menu = prepareControlVisibilityMenu(focusTrigger, entry.id);
|
|
13644
13758
|
if (!menu) return;
|
|
13645
13759
|
const items = [
|
|
13646
13760
|
controlVisibilityMenuLabel("Hide or restore controls"),
|
|
13647
13761
|
controlVisibilityMenuAction("hide", `Hide ${entry.label}`),
|
|
13762
|
+
controlVisibilityMenuAction("open-setup", "Open setup"),
|
|
13648
13763
|
controlVisibilityMenuAction("show-all", "Show all"),
|
|
13649
13764
|
controlVisibilityMenuAction("reset-defaults", "Reset defaults"),
|
|
13650
13765
|
];
|
|
@@ -13669,6 +13784,7 @@ function showControlVisibilityRegionMenu(trigger, { clientX, clientY }) {
|
|
|
13669
13784
|
children.push(button);
|
|
13670
13785
|
}
|
|
13671
13786
|
}
|
|
13787
|
+
children.push(controlVisibilityMenuAction("open-setup", "Open setup"));
|
|
13672
13788
|
children.push(controlVisibilityMenuAction("show-all", "Show all"));
|
|
13673
13789
|
children.push(controlVisibilityMenuAction("reset-defaults", "Reset defaults"));
|
|
13674
13790
|
menu.replaceChildren(...children);
|
|
@@ -13687,7 +13803,8 @@ function handleControlVisibilityContextMenu(event) {
|
|
|
13687
13803
|
if (entry) {
|
|
13688
13804
|
event.preventDefault();
|
|
13689
13805
|
event.stopPropagation();
|
|
13690
|
-
|
|
13806
|
+
const focusTrigger = target.closest?.("button, a, input, select, textarea, [tabindex]");
|
|
13807
|
+
showControlVisibilityDirectMenu(entry, focusTrigger, { clientX: event.clientX, clientY: event.clientY });
|
|
13691
13808
|
return;
|
|
13692
13809
|
}
|
|
13693
13810
|
if (target.closest?.("button, input, textarea, select, [contenteditable='true'], a")) return;
|
|
@@ -13716,8 +13833,10 @@ function handleControlVisibilityKeydown(event) {
|
|
|
13716
13833
|
const position = { clientX: rect.left + Math.min(rect.width, 24), clientY: rect.bottom };
|
|
13717
13834
|
event.preventDefault();
|
|
13718
13835
|
event.stopPropagation();
|
|
13719
|
-
if (entry)
|
|
13720
|
-
|
|
13836
|
+
if (entry) {
|
|
13837
|
+
const focusTrigger = target.closest?.("button, a, input, select, textarea, [tabindex]");
|
|
13838
|
+
showControlVisibilityDirectMenu(entry, focusTrigger, position);
|
|
13839
|
+
} else showControlVisibilityRegionMenu(anchor, position);
|
|
13721
13840
|
}
|
|
13722
13841
|
|
|
13723
13842
|
function initializeControlVisibility() {
|
|
@@ -15962,6 +16081,8 @@ function resetActiveTabUi() {
|
|
|
15962
16081
|
bindGitWorkflowToActiveTab();
|
|
15963
16082
|
resetChatOutput();
|
|
15964
16083
|
elements.stateDetails.replaceChildren();
|
|
16084
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
16085
|
+
toolEventStartedAt.clear();
|
|
15965
16086
|
elements.eventLog.replaceChildren();
|
|
15966
16087
|
const queuedSnapshot = activeTabId ? latestQueuedMessagesByTab.get(activeTabId) : null;
|
|
15967
16088
|
if (queuedSnapshot) renderQueue({ tabId: activeTabId, ...queuedSnapshot });
|
|
@@ -16335,6 +16456,7 @@ function showGitPanelContextMenu(event, context) {
|
|
|
16335
16456
|
closeFileContextMenu({ returnFocus: false });
|
|
16336
16457
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
16337
16458
|
closeSidePanelContextMenu({ returnFocus: false });
|
|
16459
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
16338
16460
|
const menu = elements.gitPanelContextMenu;
|
|
16339
16461
|
const items = gitPanelContextMenuItems(context);
|
|
16340
16462
|
if (!items.length) return;
|
|
@@ -17652,7 +17774,9 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", all
|
|
|
17652
17774
|
if (!quickClose && !(await confirmCloseTerminalTabs(targetTabs, label))) return;
|
|
17653
17775
|
|
|
17654
17776
|
const closedActiveTab = targetTabs.some((tab) => tab.id === activeTabId);
|
|
17777
|
+
const closedActiveCwd = closedActiveTab ? tabs.find((tab) => tab.id === activeTabId)?.cwd || "" : "";
|
|
17655
17778
|
const fallbackTabId = tabs.find((item) => !targetIds.includes(item.id))?.id || null;
|
|
17779
|
+
for (const id of targetIds) closingTerminalTabIds.add(id);
|
|
17656
17780
|
try {
|
|
17657
17781
|
if (closedActiveTab) eventSource?.close();
|
|
17658
17782
|
const response = await api("/api/tabs/close", { method: "POST", body: { ids: targetIds, allowEmpty }, scoped: false });
|
|
@@ -17686,9 +17810,14 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", all
|
|
|
17686
17810
|
|
|
17687
17811
|
const activeTabNeedsFallback = closedIds.includes(activeTabId) || !tabs.some((item) => item.id === activeTabId);
|
|
17688
17812
|
if (activeTabNeedsFallback) {
|
|
17689
|
-
const
|
|
17690
|
-
?
|
|
17691
|
-
:
|
|
17813
|
+
const sameCwdFallbackTabId = closedActiveCwd
|
|
17814
|
+
? tabs.find((item) => !closedIds.includes(item.id) && item.cwd === closedActiveCwd)?.id || null
|
|
17815
|
+
: null;
|
|
17816
|
+
const tabContext = setActiveTabId((sameCwdFallbackTabId && tabs.some((item) => item.id === sameCwdFallbackTabId)
|
|
17817
|
+
? sameCwdFallbackTabId
|
|
17818
|
+
: response.data?.activeTabId && tabs.some((item) => item.id === response.data.activeTabId)
|
|
17819
|
+
? response.data.activeTabId
|
|
17820
|
+
: (fallbackTabId && tabs.some((item) => item.id === fallbackTabId) ? fallbackTabId : tabs[0]?.id)) || null, { remember: true });
|
|
17692
17821
|
resetActiveTabUi();
|
|
17693
17822
|
renderTabs();
|
|
17694
17823
|
restoreActiveDraft();
|
|
@@ -17701,9 +17830,11 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", all
|
|
|
17701
17830
|
} else {
|
|
17702
17831
|
renderTabs();
|
|
17703
17832
|
}
|
|
17704
|
-
addEvent(`closed ${closedIds.length || targetTabs.length} terminal ${closedIds.length === 1 ? "tab" : "tabs"}`, "
|
|
17833
|
+
addEvent(`closed ${closedIds.length || targetTabs.length} terminal ${closedIds.length === 1 ? "tab" : "tabs"}`, "info");
|
|
17705
17834
|
} catch (error) {
|
|
17706
17835
|
addEvent(error.message, "error");
|
|
17836
|
+
} finally {
|
|
17837
|
+
for (const id of targetIds) closingTerminalTabIds.delete(id);
|
|
17707
17838
|
}
|
|
17708
17839
|
}
|
|
17709
17840
|
|
|
@@ -17809,24 +17940,349 @@ function jumpToChatEvent(line) {
|
|
|
17809
17940
|
}
|
|
17810
17941
|
}
|
|
17811
17942
|
|
|
17812
|
-
|
|
17943
|
+
const TOOL_EVENT_TARGET_FIELDS = new Map([
|
|
17944
|
+
["read", "path"],
|
|
17945
|
+
["write", "path"],
|
|
17946
|
+
["edit", "path"],
|
|
17947
|
+
["grep", "path"],
|
|
17948
|
+
["find", "path"],
|
|
17949
|
+
["ls", "path"],
|
|
17950
|
+
]);
|
|
17951
|
+
|
|
17952
|
+
function boundedToolEventTarget(event) {
|
|
17953
|
+
const toolName = String(event?.toolName || "").trim().toLowerCase();
|
|
17954
|
+
const field = TOOL_EVENT_TARGET_FIELDS.get(toolName);
|
|
17955
|
+
if (!field) return "";
|
|
17956
|
+
const args = event?.args ?? event?.arguments ?? event?.invocation?.args;
|
|
17957
|
+
const value = args && typeof args === "object" && !Array.isArray(args) ? args[field] : "";
|
|
17958
|
+
if (typeof value !== "string") return "";
|
|
17959
|
+
const singleLine = value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
|
|
17960
|
+
return singleLine.length > 96 ? `${singleLine.slice(0, 93)}…` : singleLine;
|
|
17961
|
+
}
|
|
17962
|
+
|
|
17963
|
+
function shortenedToolCallId(value) {
|
|
17964
|
+
const id = String(value || "").trim();
|
|
17965
|
+
if (!id) return "";
|
|
17966
|
+
return id.length <= 14 ? id : `${id.slice(0, 7)}…${id.slice(-5)}`;
|
|
17967
|
+
}
|
|
17968
|
+
|
|
17969
|
+
function toolEventTimerKey(event) {
|
|
17970
|
+
const toolCallId = String(event?.toolCallId || "").trim();
|
|
17971
|
+
return toolCallId ? `${event?.tabId || activeTabId || "tab"}:${toolCallId}` : "";
|
|
17972
|
+
}
|
|
17973
|
+
|
|
17974
|
+
function toolEventDurationMs(event, phase, occurredAt) {
|
|
17975
|
+
if (phase !== "finish") return null;
|
|
17976
|
+
const reportedDurationMs = Number(event?.durationMs);
|
|
17977
|
+
if (Number.isFinite(reportedDurationMs) && reportedDurationMs >= 0) return reportedDurationMs;
|
|
17978
|
+
const startedAt = toolEventStartedAt.get(toolEventTimerKey(event))?.startedAt;
|
|
17979
|
+
return Number.isFinite(startedAt) ? Math.max(0, occurredAt - startedAt) : null;
|
|
17980
|
+
}
|
|
17981
|
+
|
|
17982
|
+
function formatToolEventDuration(durationMs) {
|
|
17983
|
+
if (!Number.isFinite(durationMs)) return "";
|
|
17984
|
+
if (durationMs < 1000) return `${Math.round(durationMs)} ms`;
|
|
17985
|
+
if (durationMs < 10_000) return `${(durationMs / 1000).toFixed(1)} s`;
|
|
17986
|
+
return `${Math.round(durationMs / 1000)} s`;
|
|
17987
|
+
}
|
|
17988
|
+
|
|
17989
|
+
function toolLifecycleEventDetails(event, phase, occurredAt) {
|
|
17990
|
+
const status = phase === "start" ? "started" : event?.isError ? "failed" : "finished";
|
|
17991
|
+
const startRecord = phase === "finish" ? toolEventStartedAt.get(toolEventTimerKey(event)) : null;
|
|
17992
|
+
const target = boundedToolEventTarget(event) || startRecord?.target || "";
|
|
17993
|
+
const duration = formatToolEventDuration(toolEventDurationMs(event, phase, occurredAt));
|
|
17994
|
+
const callId = shortenedToolCallId(event?.toolCallId);
|
|
17995
|
+
return [
|
|
17996
|
+
target ? { label: "target", value: target } : null,
|
|
17997
|
+
{ label: "status", value: status, tone: event?.isError ? "error" : phase === "finish" ? "success" : "info" },
|
|
17998
|
+
duration ? { label: "duration", value: duration } : null,
|
|
17999
|
+
callId ? { label: "call", value: callId } : null,
|
|
18000
|
+
].filter(Boolean);
|
|
18001
|
+
}
|
|
18002
|
+
|
|
18003
|
+
function toolLifecycleEventArguments(event, phase) {
|
|
17813
18004
|
const occurredAt = Date.now();
|
|
18005
|
+
const timerKey = toolEventTimerKey(event);
|
|
18006
|
+
if (phase === "start" && timerKey) {
|
|
18007
|
+
toolEventStartedAt.set(timerKey, { startedAt: occurredAt, target: boundedToolEventTarget(event) });
|
|
18008
|
+
while (toolEventStartedAt.size > 240) toolEventStartedAt.delete(toolEventStartedAt.keys().next().value);
|
|
18009
|
+
}
|
|
18010
|
+
const toolName = runIndicatorToolName(event?.toolName || "tool");
|
|
18011
|
+
const status = phase === "start" ? "started" : event?.isError ? "failed" : "finished";
|
|
18012
|
+
const args = [`tool ${toolName} ${status}`, event?.isError ? "error" : "info", {
|
|
18013
|
+
toolCallId: event?.toolCallId,
|
|
18014
|
+
toolEventPhase: phase,
|
|
18015
|
+
details: toolLifecycleEventDetails(event, phase, occurredAt),
|
|
18016
|
+
occurredAt,
|
|
18017
|
+
}];
|
|
18018
|
+
if (phase === "finish" && timerKey) toolEventStartedAt.delete(timerKey);
|
|
18019
|
+
return args;
|
|
18020
|
+
}
|
|
18021
|
+
|
|
18022
|
+
function normalizeEventDisplayMode(value) {
|
|
18023
|
+
return value === "compact" ? "compact" : "detailed";
|
|
18024
|
+
}
|
|
18025
|
+
|
|
18026
|
+
function readStoredEventDisplayMode() {
|
|
18027
|
+
try {
|
|
18028
|
+
return normalizeEventDisplayMode(localStorage.getItem(EVENT_DISPLAY_MODE_STORAGE_KEY));
|
|
18029
|
+
} catch {
|
|
18030
|
+
return "detailed";
|
|
18031
|
+
}
|
|
18032
|
+
}
|
|
18033
|
+
|
|
18034
|
+
function normalizeEventFilter(value) {
|
|
18035
|
+
return EVENT_FILTER_VALUES.has(value) ? value : "all";
|
|
18036
|
+
}
|
|
18037
|
+
|
|
18038
|
+
function readStoredEventFilter() {
|
|
18039
|
+
try {
|
|
18040
|
+
return normalizeEventFilter(localStorage.getItem(EVENT_FILTER_STORAGE_KEY));
|
|
18041
|
+
} catch {
|
|
18042
|
+
return "all";
|
|
18043
|
+
}
|
|
18044
|
+
}
|
|
18045
|
+
|
|
18046
|
+
function eventRowMatchesFilter(line, filter = eventFilter) {
|
|
18047
|
+
if (!line?.classList?.contains("event") || filter === "all") return true;
|
|
18048
|
+
if (filter === "errors") return line.dataset.eventLevel === "error";
|
|
18049
|
+
if (filter === "warnings") return line.dataset.eventLevel === "warn";
|
|
18050
|
+
if (filter === "tools") return ["start", "finish"].includes(line.dataset.eventToolPhase);
|
|
18051
|
+
if (filter === "tree") return line.dataset.eventTreeAvailable === "true";
|
|
18052
|
+
return true;
|
|
18053
|
+
}
|
|
18054
|
+
|
|
18055
|
+
function applyEventFilter() {
|
|
18056
|
+
const rows = [...(elements.eventLog?.children || [])].filter((line) => line.classList?.contains("event"));
|
|
18057
|
+
let shown = 0;
|
|
18058
|
+
for (const line of rows) {
|
|
18059
|
+
const matches = eventRowMatchesFilter(line);
|
|
18060
|
+
line.hidden = !matches;
|
|
18061
|
+
if (matches) shown += 1;
|
|
18062
|
+
}
|
|
18063
|
+
const total = rows.length;
|
|
18064
|
+
if (elements.eventFilterStatus) {
|
|
18065
|
+
elements.eventFilterStatus.textContent = total === 0
|
|
18066
|
+
? "No events yet"
|
|
18067
|
+
: eventFilter === "all"
|
|
18068
|
+
? `${total} event${total === 1 ? "" : "s"}`
|
|
18069
|
+
: `${shown} of ${total}`;
|
|
18070
|
+
}
|
|
18071
|
+
if (elements.eventFilterEmpty) {
|
|
18072
|
+
elements.eventFilterEmpty.hidden = total === 0 || shown > 0;
|
|
18073
|
+
const label = elements.eventFilterSelect?.selectedOptions?.[0]?.textContent?.trim() || "this filter";
|
|
18074
|
+
elements.eventFilterEmpty.textContent = `No events match ${label.toLowerCase()}.`;
|
|
18075
|
+
}
|
|
18076
|
+
}
|
|
18077
|
+
|
|
18078
|
+
function syncEventFilterUi() {
|
|
18079
|
+
if (elements.eventFilterSelect) elements.eventFilterSelect.value = eventFilter;
|
|
18080
|
+
applyEventFilter();
|
|
18081
|
+
}
|
|
18082
|
+
|
|
18083
|
+
function setEventFilter(value, { persist = true } = {}) {
|
|
18084
|
+
eventFilter = normalizeEventFilter(value);
|
|
18085
|
+
syncEventFilterUi();
|
|
18086
|
+
if (!persist) return;
|
|
18087
|
+
try {
|
|
18088
|
+
localStorage.setItem(EVENT_FILTER_STORAGE_KEY, eventFilter);
|
|
18089
|
+
} catch {
|
|
18090
|
+
// The filter remains active for this page when storage is unavailable.
|
|
18091
|
+
}
|
|
18092
|
+
}
|
|
18093
|
+
|
|
18094
|
+
function syncEventDisplayModeUi() {
|
|
18095
|
+
if (elements.eventLog) elements.eventLog.dataset.displayMode = eventDisplayMode;
|
|
18096
|
+
elements.eventDisplayDetailedAction?.setAttribute("aria-checked", String(eventDisplayMode === "detailed"));
|
|
18097
|
+
elements.eventDisplayCompactAction?.setAttribute("aria-checked", String(eventDisplayMode === "compact"));
|
|
18098
|
+
}
|
|
18099
|
+
|
|
18100
|
+
function setEventDisplayMode(value, { persist = true } = {}) {
|
|
18101
|
+
eventDisplayMode = normalizeEventDisplayMode(value);
|
|
18102
|
+
syncEventDisplayModeUi();
|
|
18103
|
+
if (!persist) return;
|
|
18104
|
+
try {
|
|
18105
|
+
localStorage.setItem(EVENT_DISPLAY_MODE_STORAGE_KEY, eventDisplayMode);
|
|
18106
|
+
} catch {
|
|
18107
|
+
// Display mode remains active for this page when storage is unavailable.
|
|
18108
|
+
}
|
|
18109
|
+
}
|
|
18110
|
+
|
|
18111
|
+
function addEvent(message, level = "info", { toolCallId = "", toolEventPhase = "", details = [], notify = true, occurredAt = Date.now(), aggregateKey = "", aggregateIncrement = 1, aggregateSingular = "", aggregatePlural = "" } = {}) {
|
|
18112
|
+
const stableAggregateKey = String(aggregateKey || "").trim();
|
|
18113
|
+
const priorAggregate = stableAggregateKey
|
|
18114
|
+
? [...(elements.eventLog?.children || [])].find((candidate) => candidate.dataset.eventAggregateKey === stableAggregateKey)
|
|
18115
|
+
: null;
|
|
18116
|
+
const aggregateCount = stableAggregateKey
|
|
18117
|
+
? Math.max(0, Number.parseInt(priorAggregate?.dataset.eventAggregateCount || "0", 10) || 0) + Math.max(1, Math.trunc(Number(aggregateIncrement) || 1))
|
|
18118
|
+
: 0;
|
|
18119
|
+
const eventMessage = stableAggregateKey && aggregateSingular
|
|
18120
|
+
? `${message} ${aggregateCount} ${aggregateCount === 1 ? aggregateSingular : aggregatePlural || aggregateSingular}`
|
|
18121
|
+
: String(message || "");
|
|
18122
|
+
priorAggregate?.remove();
|
|
17814
18123
|
const line = make("button", `event ${level}`.trim());
|
|
17815
18124
|
line.type = "button";
|
|
18125
|
+
line.dataset.eventLevel = String(level || "info").trim().toLowerCase() || "info";
|
|
17816
18126
|
line.dataset.chatEventTimestamp = String(occurredAt);
|
|
17817
|
-
if (
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
18127
|
+
if (stableAggregateKey) {
|
|
18128
|
+
line.dataset.eventAggregateKey = stableAggregateKey;
|
|
18129
|
+
line.dataset.eventAggregateCount = String(aggregateCount);
|
|
18130
|
+
}
|
|
18131
|
+
const stableToolCallId = String(toolCallId || "").trim();
|
|
18132
|
+
const toolLifecycle = ["start", "finish"].includes(toolEventPhase);
|
|
18133
|
+
const treeEligible = stableToolCallId && toolLifecycle;
|
|
18134
|
+
line.dataset.eventTreeAvailable = String(!!treeEligible);
|
|
18135
|
+
if (stableToolCallId) line.dataset.chatToolCallId = stableToolCallId;
|
|
18136
|
+
if (toolLifecycle) line.dataset.eventToolPhase = toolEventPhase;
|
|
18137
|
+
line.setAttribute("aria-keyshortcuts", "ContextMenu Shift+F10");
|
|
18138
|
+
const time = make("span", "event-time", `[${new Date(occurredAt).toLocaleTimeString()}]`);
|
|
18139
|
+
const summary = make("span", "event-summary", eventMessage);
|
|
18140
|
+
const main = make("span", "event-main");
|
|
18141
|
+
main.append(time, summary);
|
|
18142
|
+
line.append(main);
|
|
18143
|
+
if (Array.isArray(details) && details.length) {
|
|
18144
|
+
const meta = make("span", "event-details");
|
|
18145
|
+
for (const detail of details) {
|
|
18146
|
+
if (!detail?.label || !detail?.value) continue;
|
|
18147
|
+
const item = make("span", `event-detail${detail.tone ? ` ${detail.tone}` : ""}`);
|
|
18148
|
+
item.append(make("span", "event-detail-label", `${detail.label}:`), document.createTextNode(` ${detail.value}`));
|
|
18149
|
+
meta.append(item);
|
|
18150
|
+
}
|
|
18151
|
+
if (meta.childElementCount) line.append(meta);
|
|
18152
|
+
}
|
|
18153
|
+
const accessibleText = line.textContent.trim();
|
|
18154
|
+
line.title = `Jump to this event in the chat; open the context menu for display options${treeEligible ? " and Tree navigation" : ""}`;
|
|
18155
|
+
line.setAttribute("aria-label", `${accessibleText}. Jump to this event in the chat. Context menu: display options${treeEligible ? " and Tree navigation" : ""}.`);
|
|
17821
18156
|
line.addEventListener("click", () => jumpToChatEvent(line));
|
|
17822
18157
|
elements.eventLog.prepend(line);
|
|
17823
18158
|
while (elements.eventLog.children.length > 120) elements.eventLog.lastElementChild?.remove();
|
|
18159
|
+
applyEventFilter();
|
|
17824
18160
|
if (notify && (level === "error" || level === "warn")) {
|
|
17825
|
-
showNoticeToast(
|
|
18161
|
+
showNoticeToast(eventMessage, level);
|
|
17826
18162
|
noteUnreadEvent();
|
|
17827
18163
|
}
|
|
17828
18164
|
}
|
|
17829
18165
|
|
|
18166
|
+
function closeEventTreeContextMenu({ returnFocus = true } = {}) {
|
|
18167
|
+
const trigger = eventTreeContextMenuState?.trigger;
|
|
18168
|
+
eventTreeContextMenuState = null;
|
|
18169
|
+
if (elements.eventTreeContextMenu) elements.eventTreeContextMenu.hidden = true;
|
|
18170
|
+
if (elements.eventTreeContextMenuAction) elements.eventTreeContextMenuAction.disabled = false;
|
|
18171
|
+
if (returnFocus && trigger?.isConnected) queueMicrotask(() => trigger.focus({ preventScroll: true }));
|
|
18172
|
+
}
|
|
18173
|
+
|
|
18174
|
+
function setEventTreeContextMenuStatus(message = "", level = "info") {
|
|
18175
|
+
const status = elements.eventTreeContextMenuStatus;
|
|
18176
|
+
if (!status) return;
|
|
18177
|
+
status.textContent = message;
|
|
18178
|
+
status.hidden = !message;
|
|
18179
|
+
status.className = `event-tree-context-menu-status ${level}`;
|
|
18180
|
+
}
|
|
18181
|
+
|
|
18182
|
+
function closeOtherContextMenusForEventTree() {
|
|
18183
|
+
closeFileContextMenu({ returnFocus: false });
|
|
18184
|
+
closeGitPanelContextMenu({ returnFocus: false });
|
|
18185
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
18186
|
+
closeVisibilityContextMenu({ returnFocus: false });
|
|
18187
|
+
closeGitFooterContextMenu({ returnFocus: false });
|
|
18188
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
18189
|
+
}
|
|
18190
|
+
|
|
18191
|
+
function showEventTreeContextMenu(event, line = null) {
|
|
18192
|
+
const menu = elements.eventTreeContextMenu;
|
|
18193
|
+
if (!menu || (line && !elements.eventLog?.contains(line))) return;
|
|
18194
|
+
const toolCallId = String(line?.dataset.chatToolCallId || "").trim();
|
|
18195
|
+
const phase = line?.dataset.eventToolPhase || "";
|
|
18196
|
+
const treeEligible = !!toolCallId && ["start", "finish"].includes(phase);
|
|
18197
|
+
event.preventDefault();
|
|
18198
|
+
event.stopPropagation();
|
|
18199
|
+
closeOtherContextMenusForEventTree();
|
|
18200
|
+
eventTreeContextMenuState = {
|
|
18201
|
+
trigger: line,
|
|
18202
|
+
toolCallId,
|
|
18203
|
+
phase,
|
|
18204
|
+
tabContext: treeEligible ? activeTabContext() : null,
|
|
18205
|
+
busy: false,
|
|
18206
|
+
openedAt: performance.now(),
|
|
18207
|
+
};
|
|
18208
|
+
setEventTreeContextMenuStatus("");
|
|
18209
|
+
syncEventDisplayModeUi();
|
|
18210
|
+
if (elements.eventTreeContextMenuAction) elements.eventTreeContextMenuAction.hidden = !treeEligible;
|
|
18211
|
+
menu.hidden = false;
|
|
18212
|
+
const rect = menu.getBoundingClientRect();
|
|
18213
|
+
const left = Math.min(Number(event.clientX) || 0, Math.max(8, window.innerWidth - rect.width - 8));
|
|
18214
|
+
const top = Math.min(Number(event.clientY) || 0, Math.max(8, window.innerHeight - rect.height - 8));
|
|
18215
|
+
menu.style.left = `${Math.max(8, left)}px`;
|
|
18216
|
+
menu.style.top = `${Math.max(8, top)}px`;
|
|
18217
|
+
const displayAction = eventDisplayMode === "compact" ? elements.eventDisplayCompactAction : elements.eventDisplayDetailedAction;
|
|
18218
|
+
displayAction?.focus({ preventScroll: true });
|
|
18219
|
+
}
|
|
18220
|
+
|
|
18221
|
+
function eventTreeTargetEntryId(data, state) {
|
|
18222
|
+
const targets = Array.isArray(data?.eventTargets) ? data.eventTargets : [];
|
|
18223
|
+
const target = targets.find((item) => String(item?.toolCallId || "") === state.toolCallId);
|
|
18224
|
+
const entryId = state.phase === "start" ? target?.startEntryId : target?.finishEntryId || target?.startEntryId;
|
|
18225
|
+
if (typeof entryId !== "string" || !entryId.trim()) return "";
|
|
18226
|
+
const nodes = Array.isArray(data?.nodes) ? data.nodes : [];
|
|
18227
|
+
return nodes.some((node) => node?.id === entryId) ? entryId : "";
|
|
18228
|
+
}
|
|
18229
|
+
|
|
18230
|
+
async function navigateEventTreeBoundary() {
|
|
18231
|
+
const state = eventTreeContextMenuState;
|
|
18232
|
+
const action = elements.eventTreeContextMenuAction;
|
|
18233
|
+
if (!state || state.busy || !action || !isCurrentTabContext(state.tabContext)) return;
|
|
18234
|
+
state.busy = true;
|
|
18235
|
+
action.disabled = true;
|
|
18236
|
+
setEventTreeContextMenuStatus("Resolving this tool boundary…");
|
|
18237
|
+
try {
|
|
18238
|
+
const tree = await api("/api/session-tree", { tabId: state.tabContext.tabId });
|
|
18239
|
+
if (eventTreeContextMenuState !== state || !isCurrentTabContext(state.tabContext)) return;
|
|
18240
|
+
const entryId = eventTreeTargetEntryId(tree.data, state);
|
|
18241
|
+
if (!entryId) {
|
|
18242
|
+
setEventTreeContextMenuStatus("This tool boundary is not available in the current persisted session tree.", "warn");
|
|
18243
|
+
addEvent("Tree navigation target is unavailable or stale; the session was not changed.", "warn");
|
|
18244
|
+
return;
|
|
18245
|
+
}
|
|
18246
|
+
setEventTreeContextMenuStatus("");
|
|
18247
|
+
const confirmed = await appConfirm({
|
|
18248
|
+
title: "Navigate to this tool boundary?",
|
|
18249
|
+
summary: "This changes the current session branch. Later entries stay in the tree, and no automatic branch summary is generated.",
|
|
18250
|
+
affected: "Use /tree to navigate back or choose another branch.",
|
|
18251
|
+
undoable: true,
|
|
18252
|
+
confirmLabel: "Navigate",
|
|
18253
|
+
danger: false,
|
|
18254
|
+
});
|
|
18255
|
+
if (eventTreeContextMenuState !== state || !isCurrentTabContext(state.tabContext)) return;
|
|
18256
|
+
if (!confirmed) {
|
|
18257
|
+
setEventTreeContextMenuStatus("Navigation cancelled; the session was not changed.");
|
|
18258
|
+
return;
|
|
18259
|
+
}
|
|
18260
|
+
setEventTreeContextMenuStatus("Navigating…");
|
|
18261
|
+
const result = await api("/api/tree-navigate", {
|
|
18262
|
+
method: "POST",
|
|
18263
|
+
body: { entryId, summarize: false },
|
|
18264
|
+
tabId: state.tabContext.tabId,
|
|
18265
|
+
});
|
|
18266
|
+
if (!isCurrentTabContext(state.tabContext)) return;
|
|
18267
|
+
applyResponseTab(result);
|
|
18268
|
+
addTransientMessage({ role: "native", title: "/tree", content: result.data?.message || "Navigated to the selected tool boundary.", level: "info" });
|
|
18269
|
+
if (eventTreeContextMenuState === state) closeEventTreeContextMenu();
|
|
18270
|
+
await refreshAll(state.tabContext);
|
|
18271
|
+
} catch (error) {
|
|
18272
|
+
if (eventTreeContextMenuState === state && isCurrentTabContext(state.tabContext)) {
|
|
18273
|
+
const message = error?.message || String(error);
|
|
18274
|
+
setEventTreeContextMenuStatus(`Navigation failed: ${message}`, "error");
|
|
18275
|
+
addEvent(`Tree navigation failed: ${message}`, "error");
|
|
18276
|
+
}
|
|
18277
|
+
} finally {
|
|
18278
|
+
if (eventTreeContextMenuState === state) {
|
|
18279
|
+
state.busy = false;
|
|
18280
|
+
action.disabled = false;
|
|
18281
|
+
action.focus({ preventScroll: true });
|
|
18282
|
+
}
|
|
18283
|
+
}
|
|
18284
|
+
}
|
|
18285
|
+
|
|
17830
18286
|
// --- Non-blocking warn/error notices -------------------------------------------------------
|
|
17831
18287
|
// The Events log lives in a collapsed Control Deck section, so on its own it makes failures look
|
|
17832
18288
|
// like "nothing happened". Warnings and errors additionally surface as a short-lived toast (max 3,
|
|
@@ -19351,6 +19807,14 @@ function closeGitFooterContextMenu({ returnFocus = true } = {}) {
|
|
|
19351
19807
|
if (returnFocus && trigger?.isConnected) queueMicrotask(() => trigger.focus?.({ preventScroll: true }));
|
|
19352
19808
|
}
|
|
19353
19809
|
|
|
19810
|
+
function syncGitFooterAdvancedMenuItem(key = gitFooterContextMenuState?.key) {
|
|
19811
|
+
const advancedButton = elements.gitFooterContextMenu?.querySelector('[data-git-footer-menu-action="toggle-advanced"]');
|
|
19812
|
+
if (!advancedButton) return;
|
|
19813
|
+
advancedButton.hidden = key !== "model";
|
|
19814
|
+
advancedButton.textContent = footerScopedModelLayout === "advanced" ? "Toggle Simple" : "Toggle advanced";
|
|
19815
|
+
advancedButton.setAttribute("aria-checked", footerScopedModelLayout === "advanced" ? "true" : "false");
|
|
19816
|
+
}
|
|
19817
|
+
|
|
19354
19818
|
function showGitFooterContextMenu(event, chip, trigger) {
|
|
19355
19819
|
const menu = elements.gitFooterContextMenu;
|
|
19356
19820
|
const key = cleanStatusText(chip?.key);
|
|
@@ -19361,12 +19825,14 @@ function showGitFooterContextMenu(event, chip, trigger) {
|
|
|
19361
19825
|
closeGitPanelContextMenu({ returnFocus: false });
|
|
19362
19826
|
closeSidePanelContextMenu({ returnFocus: false });
|
|
19363
19827
|
closeGitFooterContextMenu({ returnFocus: false });
|
|
19828
|
+
closeEventTreeContextMenu({ returnFocus: false });
|
|
19364
19829
|
hideFooterTooltip();
|
|
19365
19830
|
|
|
19366
19831
|
const label = cleanStatusText(chip?.label) || gitFooterVisibilityLabel(key);
|
|
19367
19832
|
gitFooterContextMenuState = { key, label, trigger };
|
|
19368
19833
|
const disableButton = menu.querySelector('[data-git-footer-menu-action="disable"]');
|
|
19369
19834
|
if (disableButton) disableButton.textContent = `Disable ${label} box`;
|
|
19835
|
+
syncGitFooterAdvancedMenuItem(key);
|
|
19370
19836
|
menu.hidden = false;
|
|
19371
19837
|
const rect = menu.getBoundingClientRect();
|
|
19372
19838
|
const left = Math.min(event.clientX, Math.max(8, window.innerWidth - rect.width - 8));
|
|
@@ -20200,13 +20666,18 @@ function footerBranchPickerRenderKey() {
|
|
|
20200
20666
|
return footerBranchPickerOpen ? JSON.stringify(footerBranchPickerState) : "";
|
|
20201
20667
|
}
|
|
20202
20668
|
|
|
20669
|
+
function footerModelPickerRenderKey() {
|
|
20670
|
+
if (!footerModelPickerOpen) return "";
|
|
20671
|
+
return `${footerScopedModelLayout}:${orderedFooterScopedModels().map(footerScopedModelKey).join(",")}`;
|
|
20672
|
+
}
|
|
20673
|
+
|
|
20203
20674
|
function gitFooterPickerStateKey(payload) {
|
|
20204
20675
|
const tabContext = activeTabContext();
|
|
20205
20676
|
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
20206
20677
|
const syncInFlight = tabContext.tabId ? gitFooterSyncInFlightByTab.has(tabContext.tabId) : false;
|
|
20207
20678
|
const piCalibrationInFlight = tabContext.tabId ? gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId) : false;
|
|
20208
20679
|
const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
|
|
20209
|
-
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)}`;
|
|
20680
|
+
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)}`;
|
|
20210
20681
|
}
|
|
20211
20682
|
|
|
20212
20683
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
@@ -22499,7 +22970,7 @@ function renderSavedWorkspacePicker() {
|
|
|
22499
22970
|
return panel;
|
|
22500
22971
|
}
|
|
22501
22972
|
|
|
22502
|
-
function setFooterModelPickerOpen(open) {
|
|
22973
|
+
function setFooterModelPickerOpen(open, { restoreFocus = false } = {}) {
|
|
22503
22974
|
const wasOpen = footerModelPickerOpen;
|
|
22504
22975
|
footerModelPickerOpen = !!open;
|
|
22505
22976
|
if (footerModelPickerOpen) {
|
|
@@ -22516,7 +22987,11 @@ function setFooterModelPickerOpen(open) {
|
|
|
22516
22987
|
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
22517
22988
|
renderFooter();
|
|
22518
22989
|
updateFooterModelPickerPosition();
|
|
22519
|
-
if (
|
|
22990
|
+
if (footerModelPickerOpen && footerScopedModelLayout === "advanced") focusFooterModelPickerInitialOption();
|
|
22991
|
+
if (wasOpen && !footerModelPickerOpen) {
|
|
22992
|
+
scheduleDeferredUiFlushAfterDropdownClose();
|
|
22993
|
+
if (restoreFocus) focusFooterModelTrigger();
|
|
22994
|
+
}
|
|
22520
22995
|
}
|
|
22521
22996
|
|
|
22522
22997
|
function setFooterThinkingPickerOpen(open) {
|
|
@@ -23369,6 +23844,55 @@ function footerScopedModelKey(model) {
|
|
|
23369
23844
|
return model?.provider && model?.id ? `${model.provider}/${model.id}` : "";
|
|
23370
23845
|
}
|
|
23371
23846
|
|
|
23847
|
+
function normalizeFooterScopedModelLayout(value) {
|
|
23848
|
+
return value === "advanced" ? "advanced" : "flat";
|
|
23849
|
+
}
|
|
23850
|
+
|
|
23851
|
+
function readStoredFooterScopedModelLayout() {
|
|
23852
|
+
try {
|
|
23853
|
+
return normalizeFooterScopedModelLayout(localStorage.getItem(FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY));
|
|
23854
|
+
} catch {
|
|
23855
|
+
return "flat";
|
|
23856
|
+
}
|
|
23857
|
+
}
|
|
23858
|
+
|
|
23859
|
+
function setFooterScopedModelLayout(value, { persist = true } = {}) {
|
|
23860
|
+
const next = normalizeFooterScopedModelLayout(value);
|
|
23861
|
+
if (persist) {
|
|
23862
|
+
try {
|
|
23863
|
+
localStorage.setItem(FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY, next);
|
|
23864
|
+
} catch {}
|
|
23865
|
+
}
|
|
23866
|
+
const changed = next !== footerScopedModelLayout;
|
|
23867
|
+
footerScopedModelLayout = next;
|
|
23868
|
+
syncGitFooterAdvancedMenuItem();
|
|
23869
|
+
if (!changed || !footerModelPickerOpen) return;
|
|
23870
|
+
renderFooter();
|
|
23871
|
+
updateFooterModelPickerPosition();
|
|
23872
|
+
focusFooterModelPickerInitialOption();
|
|
23873
|
+
}
|
|
23874
|
+
|
|
23875
|
+
function toggleFooterScopedModelLayout() {
|
|
23876
|
+
setFooterScopedModelLayout(footerScopedModelLayout === "advanced" ? "flat" : "advanced");
|
|
23877
|
+
}
|
|
23878
|
+
|
|
23879
|
+
function compareFooterScopedModelProviders(a, b) {
|
|
23880
|
+
const baseOrder = String(a).localeCompare(String(b), undefined, { sensitivity: "base" });
|
|
23881
|
+
return baseOrder || String(a).localeCompare(String(b));
|
|
23882
|
+
}
|
|
23883
|
+
|
|
23884
|
+
function footerScopedModelProviderGroups(models = orderedFooterScopedModels()) {
|
|
23885
|
+
const modelsByProvider = new Map();
|
|
23886
|
+
for (const model of models) {
|
|
23887
|
+
const provider = String(model?.provider || "");
|
|
23888
|
+
if (!modelsByProvider.has(provider)) modelsByProvider.set(provider, []);
|
|
23889
|
+
modelsByProvider.get(provider).push(model);
|
|
23890
|
+
}
|
|
23891
|
+
return [...modelsByProvider.entries()]
|
|
23892
|
+
.sort(([a], [b]) => compareFooterScopedModelProviders(a, b))
|
|
23893
|
+
.map(([provider, providerModels]) => ({ provider, models: providerModels }));
|
|
23894
|
+
}
|
|
23895
|
+
|
|
23372
23896
|
function readFooterScopedModelOrder() {
|
|
23373
23897
|
try {
|
|
23374
23898
|
const parsed = JSON.parse(localStorage.getItem(FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY) || "[]");
|
|
@@ -23396,14 +23920,30 @@ function orderedFooterScopedModels() {
|
|
|
23396
23920
|
});
|
|
23397
23921
|
}
|
|
23398
23922
|
|
|
23923
|
+
function focusFooterScopedModelOrderButton(modelKey) {
|
|
23924
|
+
if (!modelKey) return;
|
|
23925
|
+
const movedButton = document.querySelector(`[data-footer-model-key="${CSS.escape(modelKey)}"]`);
|
|
23926
|
+
if (!movedButton) return;
|
|
23927
|
+
const advancedPicker = movedButton.closest(".footer-model-picker-advanced");
|
|
23928
|
+
if (advancedPicker) focusAdvancedFooterModelOption(advancedPicker, movedButton);
|
|
23929
|
+
else movedButton.focus();
|
|
23930
|
+
}
|
|
23931
|
+
|
|
23932
|
+
function rebuildOpenFooterModelPicker() {
|
|
23933
|
+
const picker = elements.statusBar.querySelector(".footer-model-picker");
|
|
23934
|
+
if (!footerModelPickerOpen || !picker) {
|
|
23935
|
+
renderFooter();
|
|
23936
|
+
return;
|
|
23937
|
+
}
|
|
23938
|
+
picker.replaceWith(renderFooterModelPicker());
|
|
23939
|
+
updateFooterModelPickerPosition();
|
|
23940
|
+
}
|
|
23941
|
+
|
|
23399
23942
|
function commitFooterScopedModelOrder(order, { render = true, focusKey = "" } = {}) {
|
|
23400
23943
|
writeFooterScopedModelOrder(order);
|
|
23401
23944
|
footerScopedModels = orderedFooterScopedModels();
|
|
23402
|
-
if (render)
|
|
23403
|
-
|
|
23404
|
-
const movedButton = document.querySelector(`[data-footer-model-key="${CSS.escape(focusKey)}"]`);
|
|
23405
|
-
if (movedButton) movedButton.focus();
|
|
23406
|
-
}
|
|
23945
|
+
if (render) rebuildOpenFooterModelPicker();
|
|
23946
|
+
focusFooterScopedModelOrderButton(focusKey);
|
|
23407
23947
|
}
|
|
23408
23948
|
|
|
23409
23949
|
function reorderFooterScopedModel(fromKey, toKey, { focus = true } = {}) {
|
|
@@ -23429,6 +23969,50 @@ function moveFooterScopedModelByOffset(modelKey, offset) {
|
|
|
23429
23969
|
return true;
|
|
23430
23970
|
}
|
|
23431
23971
|
|
|
23972
|
+
function footerScopedModelOrderWithProviderOrder(provider, providerOrder) {
|
|
23973
|
+
const models = orderedFooterScopedModels();
|
|
23974
|
+
const providerKeys = models
|
|
23975
|
+
.filter((model) => String(model?.provider || "") === provider)
|
|
23976
|
+
.map(footerScopedModelKey);
|
|
23977
|
+
const allowedKeys = new Set(providerKeys);
|
|
23978
|
+
const nextProviderKeys = [...new Set(providerOrder.filter((key) => allowedKeys.has(key)))];
|
|
23979
|
+
for (const key of providerKeys) {
|
|
23980
|
+
if (!nextProviderKeys.includes(key)) nextProviderKeys.push(key);
|
|
23981
|
+
}
|
|
23982
|
+
let providerIndex = 0;
|
|
23983
|
+
return models.map((model) => String(model?.provider || "") === provider
|
|
23984
|
+
? nextProviderKeys[providerIndex++]
|
|
23985
|
+
: footerScopedModelKey(model));
|
|
23986
|
+
}
|
|
23987
|
+
|
|
23988
|
+
function commitFooterScopedModelProviderOrder(provider, providerOrder, { render = true, focusKey = "" } = {}) {
|
|
23989
|
+
if (!provider || !providerOrder.length) return false;
|
|
23990
|
+
const currentOrder = orderedFooterScopedModels().map(footerScopedModelKey);
|
|
23991
|
+
const nextOrder = footerScopedModelOrderWithProviderOrder(provider, providerOrder);
|
|
23992
|
+
if (nextOrder.every((key, index) => key === currentOrder[index])) {
|
|
23993
|
+
focusFooterScopedModelOrderButton(focusKey);
|
|
23994
|
+
return false;
|
|
23995
|
+
}
|
|
23996
|
+
commitFooterScopedModelOrder(nextOrder, { render, focusKey });
|
|
23997
|
+
return true;
|
|
23998
|
+
}
|
|
23999
|
+
|
|
24000
|
+
function moveFooterScopedModelWithinProviderByOffset(modelKey, offset) {
|
|
24001
|
+
const models = orderedFooterScopedModels();
|
|
24002
|
+
const model = models.find((candidate) => footerScopedModelKey(candidate) === modelKey);
|
|
24003
|
+
const provider = String(model?.provider || "");
|
|
24004
|
+
if (!provider) return false;
|
|
24005
|
+
const providerOrder = models
|
|
24006
|
+
.filter((candidate) => String(candidate?.provider || "") === provider)
|
|
24007
|
+
.map(footerScopedModelKey);
|
|
24008
|
+
const fromIndex = providerOrder.indexOf(modelKey);
|
|
24009
|
+
const toIndex = fromIndex + offset;
|
|
24010
|
+
if (fromIndex < 0 || toIndex < 0 || toIndex >= providerOrder.length) return false;
|
|
24011
|
+
const [moved] = providerOrder.splice(fromIndex, 1);
|
|
24012
|
+
providerOrder.splice(toIndex, 0, moved);
|
|
24013
|
+
return commitFooterScopedModelProviderOrder(provider, providerOrder, { focusKey: modelKey });
|
|
24014
|
+
}
|
|
24015
|
+
|
|
23432
24016
|
function footerScopedModelButtons() {
|
|
23433
24017
|
return [...document.querySelectorAll(".footer-model-picker .footer-model-option[data-footer-model-key]")];
|
|
23434
24018
|
}
|
|
@@ -23443,9 +24027,16 @@ function clearFooterScopedModelDragMarkers() {
|
|
|
23443
24027
|
}
|
|
23444
24028
|
}
|
|
23445
24029
|
|
|
23446
|
-
function commitVisibleFooterScopedModelOrder({ render = false, focusKey = "" } = {}) {
|
|
23447
|
-
const order = footerScopedModelButtons()
|
|
24030
|
+
function commitVisibleFooterScopedModelOrder({ render = false, focusKey = "", provider = "" } = {}) {
|
|
24031
|
+
const order = footerScopedModelButtons()
|
|
24032
|
+
.filter((button) => !provider || button.dataset.footerProvider === provider)
|
|
24033
|
+
.map((button) => button.dataset.footerModelKey)
|
|
24034
|
+
.filter(Boolean);
|
|
23448
24035
|
if (!order.length) return;
|
|
24036
|
+
if (provider) {
|
|
24037
|
+
commitFooterScopedModelProviderOrder(provider, order, { render, focusKey });
|
|
24038
|
+
return;
|
|
24039
|
+
}
|
|
23449
24040
|
commitFooterScopedModelOrder(order, { render, focusKey });
|
|
23450
24041
|
}
|
|
23451
24042
|
|
|
@@ -23465,7 +24056,7 @@ function moveVisibleFooterScopedModel(fromKey, targetButton, clientY) {
|
|
|
23465
24056
|
|
|
23466
24057
|
if (insertBefore) parent.insertBefore(sourceButton, targetButton);
|
|
23467
24058
|
else parent.insertBefore(sourceButton, targetButton.nextSibling);
|
|
23468
|
-
commitVisibleFooterScopedModelOrder({ render: false });
|
|
24059
|
+
commitVisibleFooterScopedModelOrder({ render: false, provider: parent.dataset.footerProvider || "" });
|
|
23469
24060
|
return true;
|
|
23470
24061
|
}
|
|
23471
24062
|
|
|
@@ -23510,6 +24101,7 @@ function endFooterScopedModelPointerDrag(event) {
|
|
|
23510
24101
|
window.removeEventListener("pointercancel", endFooterScopedModelPointerDrag, { capture: true });
|
|
23511
24102
|
const wasActive = drag.active;
|
|
23512
24103
|
const sourceButton = document.querySelector(`[data-footer-model-key="${CSS.escape(drag.modelKey)}"]`);
|
|
24104
|
+
const provider = sourceButton?.dataset.footerProvider || "";
|
|
23513
24105
|
footerScopedModelPointerDrag = null;
|
|
23514
24106
|
footerScopedModelDragKey = "";
|
|
23515
24107
|
footerScopedModelLastDragOverKey = "";
|
|
@@ -23518,15 +24110,18 @@ function endFooterScopedModelPointerDrag(event) {
|
|
|
23518
24110
|
if (wasActive) {
|
|
23519
24111
|
footerScopedModelSuppressClickUntil = Date.now() + 250;
|
|
23520
24112
|
event.preventDefault();
|
|
23521
|
-
commitVisibleFooterScopedModelOrder({ render: false, focusKey: drag.modelKey });
|
|
24113
|
+
commitVisibleFooterScopedModelOrder({ render: false, focusKey: drag.modelKey, provider });
|
|
23522
24114
|
}
|
|
23523
24115
|
}
|
|
23524
24116
|
|
|
23525
24117
|
async function applyFooterModel(model) {
|
|
23526
|
-
if (!model?.provider || !model?.id) return;
|
|
24118
|
+
if (!model?.provider || !model?.id || footerModelApplyInFlight) return;
|
|
23527
24119
|
const tabContext = activeTabContext();
|
|
24120
|
+
footerModelApplyInFlight = true;
|
|
24121
|
+
footerModelPickerOpen = false;
|
|
24122
|
+
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
24123
|
+
renderFooter();
|
|
23528
24124
|
try {
|
|
23529
|
-
footerModelPickerOpen = false;
|
|
23530
24125
|
const response = await api("/api/model", { method: "POST", body: { provider: model.provider, modelId: model.id }, tabId: tabContext.tabId });
|
|
23531
24126
|
if (!isCurrentTabContext(tabContext)) return;
|
|
23532
24127
|
applyOptimisticModelSelection(response.data || model, tabContext);
|
|
@@ -23535,6 +24130,7 @@ async function applyFooterModel(model) {
|
|
|
23535
24130
|
} catch (error) {
|
|
23536
24131
|
if (isCurrentTabContext(tabContext)) addEvent(error.message, "error");
|
|
23537
24132
|
} finally {
|
|
24133
|
+
footerModelApplyInFlight = false;
|
|
23538
24134
|
if (isCurrentTabContext(tabContext)) {
|
|
23539
24135
|
document.body.classList.toggle("footer-model-picker-open", isFooterPickerOpen());
|
|
23540
24136
|
renderFooter();
|
|
@@ -23542,12 +24138,159 @@ async function applyFooterModel(model) {
|
|
|
23542
24138
|
}
|
|
23543
24139
|
}
|
|
23544
24140
|
|
|
24141
|
+
function focusFooterModelTrigger() {
|
|
24142
|
+
queueMicrotask(() => {
|
|
24143
|
+
const trigger = elements.statusBar.querySelector(".footer-model.footer-meta-action, .footer-tui-model");
|
|
24144
|
+
trigger?.focus({ preventScroll: true });
|
|
24145
|
+
});
|
|
24146
|
+
}
|
|
24147
|
+
|
|
24148
|
+
function footerModelPickerInitialKey() {
|
|
24149
|
+
const models = orderedFooterScopedModels();
|
|
24150
|
+
const currentKey = footerScopedModelKey(currentState?.model);
|
|
24151
|
+
return models.some((model) => footerScopedModelKey(model) === currentKey) ? currentKey : footerScopedModelKey(models[0]);
|
|
24152
|
+
}
|
|
24153
|
+
|
|
24154
|
+
function focusFooterModelPickerInitialOption({ retryAfterPointerRender = true } = {}) {
|
|
24155
|
+
const initialKey = footerModelPickerInitialKey();
|
|
24156
|
+
queueMicrotask(() => {
|
|
24157
|
+
if (!footerModelPickerOpen) return;
|
|
24158
|
+
const picker = elements.statusBar.querySelector(".footer-model-picker");
|
|
24159
|
+
if (!picker) {
|
|
24160
|
+
if (retryAfterPointerRender) setTimeout(() => focusFooterModelPickerInitialOption({ retryAfterPointerRender: false }), 0);
|
|
24161
|
+
return;
|
|
24162
|
+
}
|
|
24163
|
+
const escapedKey = initialKey ? CSS.escape(initialKey) : "";
|
|
24164
|
+
const target = (escapedKey && picker.querySelector(`[data-footer-model-key="${escapedKey}"]`))
|
|
24165
|
+
|| picker.querySelector(".footer-model-option[data-footer-model-key]");
|
|
24166
|
+
if (!target) return;
|
|
24167
|
+
if (footerScopedModelLayout === "advanced") {
|
|
24168
|
+
for (const button of picker.querySelectorAll(".footer-model-option[data-footer-model-key]")) button.tabIndex = button === target ? 0 : -1;
|
|
24169
|
+
}
|
|
24170
|
+
target.focus({ preventScroll: true });
|
|
24171
|
+
target.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
24172
|
+
});
|
|
24173
|
+
}
|
|
24174
|
+
|
|
24175
|
+
function syncAdvancedFooterModelRovingTabStop(picker = elements.statusBar.querySelector(".footer-model-picker-advanced")) {
|
|
24176
|
+
if (!picker) return;
|
|
24177
|
+
const options = [...picker.querySelectorAll(".footer-model-option[data-footer-model-key]")];
|
|
24178
|
+
const focused = picker.contains(document.activeElement) ? document.activeElement.closest?.(".footer-model-option[data-footer-model-key]") : null;
|
|
24179
|
+
const target = focused || options.find((option) => option.tabIndex === 0) || options[0];
|
|
24180
|
+
for (const option of options) option.tabIndex = option === target ? 0 : -1;
|
|
24181
|
+
}
|
|
24182
|
+
|
|
24183
|
+
function focusAdvancedFooterModelOption(picker, button) {
|
|
24184
|
+
if (!picker || !button) return;
|
|
24185
|
+
for (const option of picker.querySelectorAll(".footer-model-option[data-footer-model-key]")) option.tabIndex = option === button ? 0 : -1;
|
|
24186
|
+
button.focus({ preventScroll: true });
|
|
24187
|
+
button.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
24188
|
+
}
|
|
24189
|
+
|
|
24190
|
+
function advancedFooterModelColumnButtons(picker, providerIndex) {
|
|
24191
|
+
const column = picker.querySelector(`[data-footer-provider-index="${providerIndex}"]`);
|
|
24192
|
+
return column ? [...column.querySelectorAll(".footer-model-option[data-footer-model-key]")] : [];
|
|
24193
|
+
}
|
|
24194
|
+
|
|
24195
|
+
function handleAdvancedFooterModelKeydown(event, model) {
|
|
24196
|
+
const picker = event.currentTarget.closest(".footer-model-picker-advanced");
|
|
24197
|
+
if (!picker) return;
|
|
24198
|
+
const providerIndex = Number(event.currentTarget.dataset.footerProviderIndex);
|
|
24199
|
+
const modelIndex = Number(event.currentTarget.dataset.footerModelIndex);
|
|
24200
|
+
const columns = [...picker.querySelectorAll(".footer-model-provider-column[data-footer-provider-index]")];
|
|
24201
|
+
let target = null;
|
|
24202
|
+
|
|
24203
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
24204
|
+
event.preventDefault();
|
|
24205
|
+
if (!event.repeat) void applyFooterModel(model);
|
|
24206
|
+
return;
|
|
24207
|
+
}
|
|
24208
|
+
if (event.key === "Escape") {
|
|
24209
|
+
event.preventDefault();
|
|
24210
|
+
event.stopPropagation();
|
|
24211
|
+
setFooterModelPickerOpen(false, { restoreFocus: true });
|
|
24212
|
+
return;
|
|
24213
|
+
}
|
|
24214
|
+
if (event.altKey && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
24215
|
+
event.preventDefault();
|
|
24216
|
+
moveFooterScopedModelWithinProviderByOffset(footerScopedModelKey(model), event.key === "ArrowUp" ? -1 : 1);
|
|
24217
|
+
return;
|
|
24218
|
+
}
|
|
24219
|
+
if (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End") {
|
|
24220
|
+
const buttons = advancedFooterModelColumnButtons(picker, providerIndex);
|
|
24221
|
+
const lastIndex = Math.max(0, buttons.length - 1);
|
|
24222
|
+
const targetIndex = event.key === "Home"
|
|
24223
|
+
? 0
|
|
24224
|
+
: event.key === "End"
|
|
24225
|
+
? lastIndex
|
|
24226
|
+
: Math.min(lastIndex, Math.max(0, modelIndex + (event.key === "ArrowUp" ? -1 : 1)));
|
|
24227
|
+
target = buttons[targetIndex] || event.currentTarget;
|
|
24228
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
24229
|
+
const lastProviderIndex = Math.max(0, columns.length - 1);
|
|
24230
|
+
const targetProviderIndex = Math.min(lastProviderIndex, Math.max(0, providerIndex + (event.key === "ArrowLeft" ? -1 : 1)));
|
|
24231
|
+
const buttons = advancedFooterModelColumnButtons(picker, targetProviderIndex);
|
|
24232
|
+
target = buttons[Math.min(Math.max(0, modelIndex), Math.max(0, buttons.length - 1))] || event.currentTarget;
|
|
24233
|
+
} else {
|
|
24234
|
+
return;
|
|
24235
|
+
}
|
|
24236
|
+
|
|
24237
|
+
event.preventDefault();
|
|
24238
|
+
focusAdvancedFooterModelOption(picker, target);
|
|
24239
|
+
}
|
|
24240
|
+
|
|
24241
|
+
function renderFooterModelOption(model, { advanced = false, providerIndex = -1, modelIndex = -1, initialKey = "" } = {}) {
|
|
24242
|
+
const current = currentState?.model;
|
|
24243
|
+
const selected = current?.provider === model.provider && current?.id === model.id;
|
|
24244
|
+
const modelKey = footerScopedModelKey(model);
|
|
24245
|
+
const dragging = footerScopedModelDragKey === modelKey;
|
|
24246
|
+
const dragOver = footerScopedModelDragKey && footerScopedModelLastDragOverKey === modelKey;
|
|
24247
|
+
const button = make("button", `footer-model-option${selected ? " active" : ""}${dragging ? " dragging" : ""}${dragOver ? " drag-over" : ""}`);
|
|
24248
|
+
button.type = "button";
|
|
24249
|
+
button.draggable = false;
|
|
24250
|
+
button.dataset.footerModelKey = modelKey;
|
|
24251
|
+
button.setAttribute("role", "option");
|
|
24252
|
+
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
24253
|
+
button.title = `${model.provider}/${model.id}${model.name ? ` · ${model.name}` : ""}`;
|
|
24254
|
+
button.append(
|
|
24255
|
+
make("span", "footer-model-option-main", advanced ? model.id : `${model.provider}/${model.id}`),
|
|
24256
|
+
make("span", "footer-model-option-name", model.name || ""),
|
|
24257
|
+
);
|
|
24258
|
+
button.addEventListener("click", (event) => {
|
|
24259
|
+
if (Date.now() < footerScopedModelSuppressClickUntil) {
|
|
24260
|
+
event.preventDefault();
|
|
24261
|
+
return;
|
|
24262
|
+
}
|
|
24263
|
+
void applyFooterModel(model);
|
|
24264
|
+
});
|
|
24265
|
+
if (advanced) {
|
|
24266
|
+
button.dataset.footerProvider = model.provider;
|
|
24267
|
+
button.dataset.footerProviderIndex = String(providerIndex);
|
|
24268
|
+
button.dataset.footerModelIndex = String(modelIndex);
|
|
24269
|
+
button.tabIndex = modelKey === initialKey ? 0 : -1;
|
|
24270
|
+
button.addEventListener("keydown", (event) => handleAdvancedFooterModelKeydown(event, model));
|
|
24271
|
+
} else {
|
|
24272
|
+
button.addEventListener("keydown", (event) => {
|
|
24273
|
+
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
|
|
24274
|
+
event.preventDefault();
|
|
24275
|
+
moveFooterScopedModelByOffset(modelKey, event.key === "ArrowUp" ? -1 : 1);
|
|
24276
|
+
});
|
|
24277
|
+
}
|
|
24278
|
+
button.addEventListener("pointerdown", (event) => beginFooterScopedModelPointerDrag(event, modelKey));
|
|
24279
|
+
return button;
|
|
24280
|
+
}
|
|
24281
|
+
|
|
23545
24282
|
function renderFooterModelPicker() {
|
|
23546
|
-
const
|
|
24283
|
+
const advanced = footerScopedModelLayout === "advanced";
|
|
24284
|
+
const picker = make("div", `footer-model-picker${advanced ? " footer-model-picker-advanced" : ""}`);
|
|
23547
24285
|
picker.setAttribute("role", "listbox");
|
|
23548
|
-
picker.setAttribute("aria-label", "Scoped models");
|
|
23549
|
-
picker.append(make("div", "footer-model-picker-title", "Scoped models"));
|
|
23550
|
-
|
|
24286
|
+
picker.setAttribute("aria-label", advanced ? "Scoped models by provider" : "Scoped models");
|
|
24287
|
+
picker.append(make("div", "footer-model-picker-title", advanced ? "Scoped models by provider" : "Scoped models"));
|
|
24288
|
+
const help = make("div", "footer-model-picker-source", advanced
|
|
24289
|
+
? "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"
|
|
24290
|
+
: "Drag models to reorder · Alt+Up/Down moves focused model");
|
|
24291
|
+
help.id = "footerModelPickerHelp";
|
|
24292
|
+
picker.setAttribute("aria-describedby", help.id);
|
|
24293
|
+
picker.append(help);
|
|
23551
24294
|
if (footerScopedModels.length === 0) {
|
|
23552
24295
|
const empty = make("div", "footer-model-picker-empty muted");
|
|
23553
24296
|
empty.append(
|
|
@@ -23557,39 +24300,29 @@ function renderFooterModelPicker() {
|
|
|
23557
24300
|
picker.append(empty);
|
|
23558
24301
|
return picker;
|
|
23559
24302
|
}
|
|
23560
|
-
const current = currentState?.model;
|
|
23561
24303
|
footerScopedModels = orderedFooterScopedModels();
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
const
|
|
23565
|
-
|
|
23566
|
-
const dragOver = footerScopedModelDragKey && footerScopedModelLastDragOverKey === modelKey;
|
|
23567
|
-
const button = make("button", `footer-model-option${selected ? " active" : ""}${dragging ? " dragging" : ""}${dragOver ? " drag-over" : ""}`);
|
|
23568
|
-
button.type = "button";
|
|
23569
|
-
button.draggable = false;
|
|
23570
|
-
button.dataset.footerModelKey = modelKey;
|
|
23571
|
-
button.setAttribute("role", "option");
|
|
23572
|
-
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
23573
|
-
button.title = `${model.provider}/${model.id}${model.name ? ` · ${model.name}` : ""}`;
|
|
23574
|
-
button.append(
|
|
23575
|
-
make("span", "footer-model-option-main", `${model.provider}/${model.id}`),
|
|
23576
|
-
make("span", "footer-model-option-name", model.name || ""),
|
|
23577
|
-
);
|
|
23578
|
-
button.addEventListener("click", (event) => {
|
|
23579
|
-
if (Date.now() < footerScopedModelSuppressClickUntil) {
|
|
23580
|
-
event.preventDefault();
|
|
23581
|
-
return;
|
|
23582
|
-
}
|
|
23583
|
-
applyFooterModel(model);
|
|
23584
|
-
});
|
|
23585
|
-
button.addEventListener("keydown", (event) => {
|
|
23586
|
-
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
|
|
23587
|
-
event.preventDefault();
|
|
23588
|
-
moveFooterScopedModelByOffset(modelKey, event.key === "ArrowUp" ? -1 : 1);
|
|
23589
|
-
});
|
|
23590
|
-
button.addEventListener("pointerdown", (event) => beginFooterScopedModelPointerDrag(event, modelKey));
|
|
23591
|
-
picker.append(button);
|
|
24304
|
+
const initialKey = footerModelPickerInitialKey();
|
|
24305
|
+
if (!advanced) {
|
|
24306
|
+
for (const model of footerScopedModels) picker.append(renderFooterModelOption(model));
|
|
24307
|
+
return picker;
|
|
23592
24308
|
}
|
|
24309
|
+
|
|
24310
|
+
const columns = make("div", "footer-model-provider-columns");
|
|
24311
|
+
for (const [providerIndex, group] of footerScopedModelProviderGroups(footerScopedModels).entries()) {
|
|
24312
|
+
const heading = make("div", "footer-model-provider-title", group.provider);
|
|
24313
|
+
heading.id = `footerModelProvider${providerIndex}`;
|
|
24314
|
+
const column = make("div", "footer-model-provider-column");
|
|
24315
|
+
column.dataset.footerProvider = group.provider;
|
|
24316
|
+
column.dataset.footerProviderIndex = String(providerIndex);
|
|
24317
|
+
column.setAttribute("role", "group");
|
|
24318
|
+
column.setAttribute("aria-labelledby", heading.id);
|
|
24319
|
+
column.append(heading);
|
|
24320
|
+
for (const [modelIndex, model] of group.models.entries()) {
|
|
24321
|
+
column.append(renderFooterModelOption(model, { advanced: true, providerIndex, modelIndex, initialKey }));
|
|
24322
|
+
}
|
|
24323
|
+
columns.append(column);
|
|
24324
|
+
}
|
|
24325
|
+
picker.append(columns);
|
|
23593
24326
|
return picker;
|
|
23594
24327
|
}
|
|
23595
24328
|
|
|
@@ -24072,6 +24805,7 @@ function renderFooter() {
|
|
|
24072
24805
|
else renderMinimalFooter();
|
|
24073
24806
|
if (!tooltipSnapshot && footerTooltipTarget && !footerTooltipTarget.isConnected) hideFooterTooltip();
|
|
24074
24807
|
restoreScopedControlContinuity(elements.statusBar, continuityContextKey, focusSnapshot, (key) => [...elements.statusBar.querySelectorAll("input, textarea, select, button")].find((node) => footerControlKey(node) === key));
|
|
24808
|
+
syncAdvancedFooterModelRovingTabStop();
|
|
24075
24809
|
restoreTooltipContinuity(elements.statusBar, tooltipSnapshot);
|
|
24076
24810
|
}
|
|
24077
24811
|
|
|
@@ -25169,7 +25903,18 @@ async function clearFinishedSubagentRuns({ automatic = false } = {}) {
|
|
|
25169
25903
|
renderSubagents();
|
|
25170
25904
|
scheduleRefreshSubagents();
|
|
25171
25905
|
}
|
|
25172
|
-
if (dismissed)
|
|
25906
|
+
if (dismissed) {
|
|
25907
|
+
if (automatic) {
|
|
25908
|
+
addEvent("auto-cleared", "info", {
|
|
25909
|
+
aggregateKey: "subagent-auto-clear",
|
|
25910
|
+
aggregateIncrement: dismissed,
|
|
25911
|
+
aggregateSingular: "finished subagent run",
|
|
25912
|
+
aggregatePlural: "finished subagent runs",
|
|
25913
|
+
});
|
|
25914
|
+
} else {
|
|
25915
|
+
addEvent(`cleared ${dismissed} finished subagent ${dismissed === 1 ? "run" : "runs"}`, "info");
|
|
25916
|
+
}
|
|
25917
|
+
}
|
|
25173
25918
|
if (failures.length) addEvent(`could not ${automatic ? "auto-clear" : "clear"} ${failures.length} finished subagent ${failures.length === 1 ? "run" : "runs"}`, "warn");
|
|
25174
25919
|
}
|
|
25175
25920
|
|
|
@@ -31630,6 +32375,109 @@ function appendGitWorkflowOutput(text, { tabId = activeTabId } = {}) {
|
|
|
31630
32375
|
setGitWorkflow({ output: next.slice(-60000) }, { tabId });
|
|
31631
32376
|
}
|
|
31632
32377
|
|
|
32378
|
+
function gitWorkflowGenerationProfileText(profile) {
|
|
32379
|
+
const provider = String(profile?.provider || "").trim();
|
|
32380
|
+
const modelId = String(profile?.modelId || "").trim();
|
|
32381
|
+
const thinkingLevel = String(profile?.thinkingLevel || "").trim();
|
|
32382
|
+
if (!provider || !modelId) return "no model";
|
|
32383
|
+
return `${provider}/${modelId}${thinkingLevel ? ` at ${thinkingLevel} effort` : ""}`;
|
|
32384
|
+
}
|
|
32385
|
+
|
|
32386
|
+
function gitWorkflowFallbackConfigured(preferences) {
|
|
32387
|
+
return !!preferences?.generation?.fallback?.provider && !!preferences?.generation?.fallback?.modelId;
|
|
32388
|
+
}
|
|
32389
|
+
|
|
32390
|
+
function gitWorkflowConfiguredGenerationText(preferences) {
|
|
32391
|
+
const primary = gitWorkflowGenerationProfileText(preferences?.generation);
|
|
32392
|
+
if (!gitWorkflowFallbackConfigured(preferences)) return `Primary Git-writing model: ${primary}. No fallback is configured.`;
|
|
32393
|
+
return `Primary Git-writing model: ${primary}. Fallback after a final primary generation failure: ${gitWorkflowGenerationProfileText(preferences.generation.fallback)} (one attempt).`;
|
|
32394
|
+
}
|
|
32395
|
+
|
|
32396
|
+
function gitWorkflowGenerationAcceptedText(generation, subject) {
|
|
32397
|
+
const effective = gitWorkflowGenerationProfileText(generation?.generation);
|
|
32398
|
+
if (generation?.fallbackUsed === true) {
|
|
32399
|
+
const primary = gitWorkflowGenerationProfileText(generation.primaryGeneration);
|
|
32400
|
+
return `The primary Git-writing model ${primary} failed. ${subject} continued with the fallback ${effective}.`;
|
|
32401
|
+
}
|
|
32402
|
+
return `${subject} started with the primary Git-writing model ${effective}.`;
|
|
32403
|
+
}
|
|
32404
|
+
|
|
32405
|
+
function gitWorkflowFallbackEventMatchesPendingRequest(workflow, event) {
|
|
32406
|
+
if (!workflow?.active || workflow.generationKind !== event?.kind) return false;
|
|
32407
|
+
const expectedSteps = { commit: "generating", branch: "branchNaming", pr: "prGenerating" };
|
|
32408
|
+
return workflow.step === expectedSteps[event.kind] && !!String(event.generationId || "").trim();
|
|
32409
|
+
}
|
|
32410
|
+
|
|
32411
|
+
function gitWorkflowFallbackEventMatches(workflow, event) {
|
|
32412
|
+
if (!workflow?.generationAccepted || !gitWorkflowFallbackEventMatchesPendingRequest(workflow, event)) return false;
|
|
32413
|
+
return String(event.generationId || "").trim() === String(workflow.generationId || "").trim();
|
|
32414
|
+
}
|
|
32415
|
+
|
|
32416
|
+
function gitWorkflowFallbackLifecycleKey(workflow, event) {
|
|
32417
|
+
return [event.type, workflow.runId, event.kind, event.generationId || "", event.generation?.provider || "", event.generation?.modelId || ""].join(":");
|
|
32418
|
+
}
|
|
32419
|
+
|
|
32420
|
+
function applyGitWorkflowFallbackLifecycleEvent(workflow, event, tabId) {
|
|
32421
|
+
if (!gitWorkflowFallbackEventMatches(workflow, event)) return false;
|
|
32422
|
+
const keys = workflow.fallbackLifecycleKeys instanceof Set ? workflow.fallbackLifecycleKeys : new Set();
|
|
32423
|
+
const key = gitWorkflowFallbackLifecycleKey(workflow, event);
|
|
32424
|
+
if (keys.has(key)) return true;
|
|
32425
|
+
keys.add(key);
|
|
32426
|
+
const primary = gitWorkflowGenerationProfileText(event.primaryGeneration);
|
|
32427
|
+
const fallback = gitWorkflowGenerationProfileText(event.generation);
|
|
32428
|
+
if (event.type === "webui_git_workflow_generation_fallback_started") {
|
|
32429
|
+
setGitWorkflow({ fallbackStarted: true, fallbackLifecycleKeys: keys }, { tabId });
|
|
32430
|
+
appendGitWorkflowOutput(`The primary Git-writing model ${primary} failed${event.reason ? `: ${event.reason}` : "."} Generation continued with the fallback ${fallback}.`, { tabId });
|
|
32431
|
+
} else {
|
|
32432
|
+
setGitWorkflow({ fallbackLifecycleKeys: keys }, { tabId });
|
|
32433
|
+
appendGitWorkflowOutput(`The fallback Git-writing model ${fallback} also failed${event.error ? `: ${event.error}` : "."} No additional model retry will run.`, { tabId });
|
|
32434
|
+
}
|
|
32435
|
+
return true;
|
|
32436
|
+
}
|
|
32437
|
+
|
|
32438
|
+
function flushPendingGitWorkflowFallbackLifecycleEvents(tabId) {
|
|
32439
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
32440
|
+
if (!workflow?.generationAccepted) return;
|
|
32441
|
+
const pending = Array.isArray(workflow.pendingFallbackLifecycleEvents) ? workflow.pendingFallbackLifecycleEvents : [];
|
|
32442
|
+
setGitWorkflow({ pendingFallbackLifecycleEvents: [] }, { tabId });
|
|
32443
|
+
for (const event of pending) applyGitWorkflowFallbackLifecycleEvent(gitWorkflowForTab(tabId, { create: false }), event, tabId);
|
|
32444
|
+
}
|
|
32445
|
+
|
|
32446
|
+
function acceptGitWorkflowGenerationCorrelation(generation, tabId) {
|
|
32447
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
32448
|
+
const generationId = String(generation?.generationId || "").trim();
|
|
32449
|
+
if (!workflow || !generationId || generation?.kind !== workflow.generationKind) return false;
|
|
32450
|
+
setGitWorkflow({
|
|
32451
|
+
generationId,
|
|
32452
|
+
messageGenerationId: generation.kind === "commit" ? generationId : workflow.messageGenerationId,
|
|
32453
|
+
generationAccepted: true,
|
|
32454
|
+
}, { tabId });
|
|
32455
|
+
flushPendingGitWorkflowFallbackLifecycleEvents(tabId);
|
|
32456
|
+
if (generation.fallbackUsed === true) setGitWorkflow({ fallbackStarted: true }, { tabId });
|
|
32457
|
+
return true;
|
|
32458
|
+
}
|
|
32459
|
+
|
|
32460
|
+
function acceptGitWorkflowGenerationErrorCorrelation(error, tabId) {
|
|
32461
|
+
return acceptGitWorkflowGenerationCorrelation(error?.data?.gitWorkflowGeneration, tabId);
|
|
32462
|
+
}
|
|
32463
|
+
|
|
32464
|
+
function handleGitWorkflowFallbackLifecycleEvent(event) {
|
|
32465
|
+
if (!["webui_git_workflow_generation_fallback_started", "webui_git_workflow_generation_fallback_failed"].includes(event?.type)) return false;
|
|
32466
|
+
const tabId = event.tabId;
|
|
32467
|
+
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
32468
|
+
if (!tabId || !gitWorkflowFallbackEventMatchesPendingRequest(workflow, event)) return true;
|
|
32469
|
+
if (!workflow.generationAccepted) {
|
|
32470
|
+
const pending = Array.isArray(workflow.pendingFallbackLifecycleEvents) ? workflow.pendingFallbackLifecycleEvents : [];
|
|
32471
|
+
const key = gitWorkflowFallbackLifecycleKey(workflow, event);
|
|
32472
|
+
if (!pending.some((item) => gitWorkflowFallbackLifecycleKey(workflow, item) === key)) {
|
|
32473
|
+
setGitWorkflow({ pendingFallbackLifecycleEvents: [...pending, event].slice(-4) }, { tabId });
|
|
32474
|
+
}
|
|
32475
|
+
return true;
|
|
32476
|
+
}
|
|
32477
|
+
applyGitWorkflowFallbackLifecycleEvent(workflow, event, tabId);
|
|
32478
|
+
return true;
|
|
32479
|
+
}
|
|
32480
|
+
|
|
31633
32481
|
function formatGitCommandResult(result) {
|
|
31634
32482
|
if (!result) return "";
|
|
31635
32483
|
const lines = [`$ ${result.command || "git"}`];
|
|
@@ -32409,10 +33257,10 @@ function renderGitWorkflow() {
|
|
|
32409
33257
|
addGitWorkflowAction("Creating PR…", () => {}, "primary", true);
|
|
32410
33258
|
} else if (gitWorkflow.step === "done") {
|
|
32411
33259
|
addGitWorkflowAction("Close", () => setGitWorkflow({ active: false }), "primary", false);
|
|
32412
|
-
addGitWorkflowAction("Start another", () =>
|
|
33260
|
+
addGitWorkflowAction("Start another", () => launchGuidedGitWorkflow(gitWorkflowActionTabId()), "", false);
|
|
32413
33261
|
} else if (["cancelled", "error"].includes(gitWorkflow.step)) {
|
|
32414
33262
|
addGitWorkflowAction("Close", () => setGitWorkflow({ active: false }), "primary", false);
|
|
32415
|
-
addGitWorkflowAction("Restart", () =>
|
|
33263
|
+
addGitWorkflowAction("Restart", () => launchGuidedGitWorkflow(gitWorkflowActionTabId()), "", false);
|
|
32416
33264
|
}
|
|
32417
33265
|
restoreGitWorkflowInputFocus(inputFocus);
|
|
32418
33266
|
}
|
|
@@ -32667,14 +33515,108 @@ function reconcileGuidedGitReviewWidgetRemoval(tabId) {
|
|
|
32667
33515
|
return true;
|
|
32668
33516
|
}
|
|
32669
33517
|
|
|
32670
|
-
|
|
32671
|
-
|
|
32672
|
-
|
|
32673
|
-
|
|
32674
|
-
|
|
32675
|
-
|
|
32676
|
-
|
|
32677
|
-
|
|
33518
|
+
function guidedGitPromptCommandUnavailable(commandName) {
|
|
33519
|
+
return `Guided Git browser generation requires /${commandName} from @firstpick/pi-prompts-git-pr in the originating tab.`;
|
|
33520
|
+
}
|
|
33521
|
+
|
|
33522
|
+
function guidedGitPromptCompanionAvailable(tabId) {
|
|
33523
|
+
return !isOptionalFeatureDisabled("gitWorkflow") && hasLoadedRpcCommand("git-staged-msg", { tabId });
|
|
33524
|
+
}
|
|
33525
|
+
|
|
33526
|
+
function reportGuidedGitPromptCompanionUnavailable(tabId) {
|
|
33527
|
+
const tabContext = activeTabContext(tabId);
|
|
33528
|
+
const message = isOptionalFeatureDisabled("gitWorkflow")
|
|
33529
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33530
|
+
: guidedGitPromptCommandUnavailable("git-staged-msg");
|
|
33531
|
+
addEvent(message, "warn");
|
|
33532
|
+
refreshCommands(tabContext).catch((error) => {
|
|
33533
|
+
if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
|
|
33534
|
+
});
|
|
33535
|
+
}
|
|
33536
|
+
|
|
33537
|
+
function handleGuidedGitActivationRequest(request) {
|
|
33538
|
+
if (request?.method !== "setStatus" || request.statusKey !== GUIDED_GIT_START_STATUS_KEY) return false;
|
|
33539
|
+
const result = guidedGitActivationController.consume(request, async (tabId, activationIsCurrent) => {
|
|
33540
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33541
|
+
reportGuidedGitPromptCompanionUnavailable(tabId);
|
|
33542
|
+
return;
|
|
33543
|
+
}
|
|
33544
|
+
await startGitWorkflow(tabId, { activationIsCurrent });
|
|
33545
|
+
});
|
|
33546
|
+
result.promise?.catch((error) => addEvent(`Guided Git could not start: ${error?.message || String(error)}`, "error"));
|
|
33547
|
+
return true;
|
|
33548
|
+
}
|
|
33549
|
+
|
|
33550
|
+
function guidedGitLaunchStateForTab(tabId) {
|
|
33551
|
+
return tabId === activeTabId ? currentState : tabStateCache.get(tabId) || null;
|
|
33552
|
+
}
|
|
33553
|
+
|
|
33554
|
+
function guidedGitLaunchRefusalReason(tabId) {
|
|
33555
|
+
if (promptRoutingTabs.has(tabId)) return "pending";
|
|
33556
|
+
return guidedGitLaunchBlockedReason(guidedGitLaunchStateForTab(tabId), queueMessageCount(queuedSnapshotForTab(tabId)));
|
|
33557
|
+
}
|
|
33558
|
+
|
|
33559
|
+
function reportGuidedGitLaunchRefused(reason) {
|
|
33560
|
+
const detail = reason === "compacting"
|
|
33561
|
+
? "Pi is compacting context"
|
|
33562
|
+
: reason === "streaming"
|
|
33563
|
+
? "Pi is running"
|
|
33564
|
+
: reason === "pending"
|
|
33565
|
+
? "the tab has pending messages"
|
|
33566
|
+
: "the tab state is not ready";
|
|
33567
|
+
addEvent(`Guided Git was not started because ${detail}. Wait until the originating tab is idle with no pending messages, then start it again.`, "warn");
|
|
33568
|
+
}
|
|
33569
|
+
|
|
33570
|
+
function guidedGitLaunchAdmitted(tabId) {
|
|
33571
|
+
const reason = guidedGitLaunchRefusalReason(tabId);
|
|
33572
|
+
if (!reason) return true;
|
|
33573
|
+
reportGuidedGitLaunchRefused(reason);
|
|
33574
|
+
return false;
|
|
33575
|
+
}
|
|
33576
|
+
|
|
33577
|
+
async function startLegacyGuidedGitWorkflowFallback(tabId) {
|
|
33578
|
+
if (!guidedGitLaunchAdmitted(tabId)) return;
|
|
33579
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33580
|
+
addEvent(isOptionalFeatureDisabled("gitWorkflow")
|
|
33581
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33582
|
+
: "Guided Git is unavailable: install @firstpick/pi-extension-git-guided-workflow. Browser generation also requires @firstpick/pi-prompts-git-pr.", "warn");
|
|
33583
|
+
return;
|
|
33584
|
+
}
|
|
33585
|
+
try {
|
|
33586
|
+
await api("/api/git-workflow/launch-admission", { method: "POST", body: {}, tabId });
|
|
33587
|
+
} catch (error) {
|
|
33588
|
+
reportGuidedGitLaunchRefused("pending");
|
|
33589
|
+
return;
|
|
33590
|
+
}
|
|
33591
|
+
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");
|
|
33592
|
+
await guidedGitActivationController.run(tabId, (_tabId, activationIsCurrent) => startGitWorkflow(tabId, { activationIsCurrent }));
|
|
33593
|
+
}
|
|
33594
|
+
|
|
33595
|
+
async function launchGuidedGitWorkflow(tabId = activeTabId) {
|
|
33596
|
+
if (!tabId || !guidedGitLaunchAdmitted(tabId)) return;
|
|
33597
|
+
const launchMode = guidedGitLaunchModeForTabCatalog(commandCatalogForTab(tabId), { disabled: isOptionalFeatureDisabled("gitWorkflow") });
|
|
33598
|
+
if (launchMode === "fallback") {
|
|
33599
|
+
await startLegacyGuidedGitWorkflowFallback(tabId);
|
|
33600
|
+
return;
|
|
33601
|
+
}
|
|
33602
|
+
if (launchMode !== "extension") {
|
|
33603
|
+
addEvent(launchMode === "disabled"
|
|
33604
|
+
? optionalFeatureUnavailableMessage("gitWorkflow")
|
|
33605
|
+
: "Guided Git is unavailable: install @firstpick/pi-extension-git-guided-workflow. Browser generation also requires @firstpick/pi-prompts-git-pr.", "warn");
|
|
33606
|
+
return;
|
|
33607
|
+
}
|
|
33608
|
+
const commandName = resolveAvailableCommandName("git-guided-workflow", { tabId, rpcOnly: true });
|
|
33609
|
+
try {
|
|
33610
|
+
await sendPrompt("prompt", `/${commandName}`, { targetTabId: tabId, throwOnError: true });
|
|
33611
|
+
} catch (error) {
|
|
33612
|
+
addEvent(`Guided Git activation request failed: ${error?.message || String(error)}`, "error");
|
|
33613
|
+
}
|
|
33614
|
+
}
|
|
33615
|
+
|
|
33616
|
+
async function startGitWorkflow(tabId = activeTabId, { skipSetup = false, activationIsCurrent = () => true } = {}) {
|
|
33617
|
+
if (!tabId || !activationIsCurrent()) return;
|
|
33618
|
+
if (!guidedGitPromptCompanionAvailable(tabId)) {
|
|
33619
|
+
reportGuidedGitPromptCompanionUnavailable(tabId);
|
|
32678
33620
|
return;
|
|
32679
33621
|
}
|
|
32680
33622
|
|
|
@@ -32682,6 +33624,7 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
32682
33624
|
try {
|
|
32683
33625
|
const response = await api("/api/git-workflow/preferences", { tabId });
|
|
32684
33626
|
setupData = response.data || {};
|
|
33627
|
+
if (!activationIsCurrent()) return;
|
|
32685
33628
|
gitWorkflowPreferences = setupData.preferences || null;
|
|
32686
33629
|
} catch (error) {
|
|
32687
33630
|
addEvent(`guided Git setup could not be loaded: ${error.message || String(error)}`, "error");
|
|
@@ -32693,12 +33636,17 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
32693
33636
|
return;
|
|
32694
33637
|
}
|
|
32695
33638
|
addEvent("Complete Guided Git Setup before starting the workflow.", "info");
|
|
32696
|
-
await openNativeGitWorkflowSetupDialog({
|
|
33639
|
+
await openNativeGitWorkflowSetupDialog({
|
|
33640
|
+
tabId,
|
|
33641
|
+
activationIsCurrent,
|
|
33642
|
+
onSaved: () => startGitWorkflow(tabId, { skipSetup: true, activationIsCurrent }),
|
|
33643
|
+
});
|
|
32697
33644
|
return;
|
|
32698
33645
|
}
|
|
32699
33646
|
|
|
32700
33647
|
const workflow = gitWorkflowForTab(tabId);
|
|
32701
33648
|
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;
|
|
33649
|
+
if (!activationIsCurrent()) return;
|
|
32702
33650
|
const preferences = setupData.preferences;
|
|
32703
33651
|
workflow.runId += 1;
|
|
32704
33652
|
setGitWorkflow({
|
|
@@ -32707,7 +33655,7 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
32707
33655
|
step: "add",
|
|
32708
33656
|
process: "stage",
|
|
32709
33657
|
busy: false,
|
|
32710
|
-
output: `${gitWorkflowStagingReadyMessage(preferences)}\n\
|
|
33658
|
+
output: `${gitWorkflowStagingReadyMessage(preferences)}\n\n${gitWorkflowConfiguredGenerationText(preferences)} The active tab model and effort are restored after generation.`,
|
|
32711
33659
|
error: "",
|
|
32712
33660
|
githubUsername: "",
|
|
32713
33661
|
repoName: "",
|
|
@@ -32721,6 +33669,12 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
32721
33669
|
...resetGitWorkflowManualCommitDefaultPatch(),
|
|
32722
33670
|
messageRequestedAt: 0,
|
|
32723
33671
|
messageGenerationId: "",
|
|
33672
|
+
generationId: "",
|
|
33673
|
+
generationKind: "",
|
|
33674
|
+
generationAccepted: false,
|
|
33675
|
+
fallbackStarted: false,
|
|
33676
|
+
fallbackLifecycleKeys: new Set(),
|
|
33677
|
+
pendingFallbackLifecycleEvents: [],
|
|
32724
33678
|
branchName: "",
|
|
32725
33679
|
branchNameRequestedAt: 0,
|
|
32726
33680
|
actionsDone: createGitWorkflowActionsDone(),
|
|
@@ -33138,6 +34092,10 @@ async function loadGitWorkflowDefaultCommitMessage({ runId, tabId = activeTabId
|
|
|
33138
34092
|
|
|
33139
34093
|
async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
33140
34094
|
const tabContext = activeTabContext(tabId);
|
|
34095
|
+
if (!hasLoadedRpcCommand("git-staged-msg", { tabId })) {
|
|
34096
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("git-staged-msg")), "generate", { tabId });
|
|
34097
|
+
return;
|
|
34098
|
+
}
|
|
33141
34099
|
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
33142
34100
|
const targetBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
33143
34101
|
if (targetBusy) {
|
|
@@ -33161,6 +34119,12 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33161
34119
|
error: "",
|
|
33162
34120
|
messageRequestedAt: requestedAt,
|
|
33163
34121
|
messageGenerationId: "",
|
|
34122
|
+
generationId: "",
|
|
34123
|
+
generationKind: "commit",
|
|
34124
|
+
generationAccepted: false,
|
|
34125
|
+
fallbackStarted: false,
|
|
34126
|
+
fallbackLifecycleKeys: new Set(),
|
|
34127
|
+
pendingFallbackLifecycleEvents: [],
|
|
33164
34128
|
output: "Asking Pi to write the commit message…\n\nCancel stops the request.",
|
|
33165
34129
|
}, { tabId });
|
|
33166
34130
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Generating commit message…");
|
|
@@ -33168,9 +34132,8 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33168
34132
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
33169
34133
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
33170
34134
|
const generationId = String(generation.generationId || "").trim();
|
|
33171
|
-
if (!
|
|
33172
|
-
|
|
33173
|
-
appendGitWorkflowOutput(`Commit message generation started with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for Pi to finish, then the short and long messages will be loaded.`, { tabId });
|
|
34135
|
+
if (!acceptGitWorkflowGenerationCorrelation(generation, tabId)) throw new Error("The WebUI server did not return a commit-message generation ID. Restart Pi Web UI and regenerate.");
|
|
34136
|
+
appendGitWorkflowOutput(`${gitWorkflowGenerationAcceptedText(generation, "Commit message generation")} Waiting for Pi to finish, then the short and long messages will be loaded.`, { tabId });
|
|
33174
34137
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
33175
34138
|
setTimeout(() => {
|
|
33176
34139
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -33182,6 +34145,7 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33182
34145
|
}, 2500);
|
|
33183
34146
|
} catch (error) {
|
|
33184
34147
|
if (isCurrentGitWorkflowRun(runId, tabId)) {
|
|
34148
|
+
acceptGitWorkflowGenerationErrorCorrelation(error, tabId);
|
|
33185
34149
|
if (isCurrentTabContext(tabContext)) clearRunIndicatorActivity();
|
|
33186
34150
|
failGitWorkflow(error, "generate", { tabId });
|
|
33187
34151
|
}
|
|
@@ -33222,7 +34186,7 @@ async function loadGitWorkflowMessage({ requireFresh = false, generationId, runI
|
|
|
33222
34186
|
if (existing?.key === loadKey) return existing.promise;
|
|
33223
34187
|
|
|
33224
34188
|
const promise = (async () => {
|
|
33225
|
-
|
|
34189
|
+
let deadline = Date.now() + (requireFresh ? GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS : 0);
|
|
33226
34190
|
const baseOutput = workflow.output || "Waiting for generated commit message files…";
|
|
33227
34191
|
let attempt = 0;
|
|
33228
34192
|
while (gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) {
|
|
@@ -33232,6 +34196,7 @@ async function loadGitWorkflowMessage({ requireFresh = false, generationId, runI
|
|
|
33232
34196
|
if (!message || !gitWorkflowMessageLoadIsCurrent(tabId, expectedRunId, expectedGenerationId)) return;
|
|
33233
34197
|
if (message.ready === false) {
|
|
33234
34198
|
if (message.expired) throw new Error(message.reason || "This commit-message generation has expired. Regenerate the message files.");
|
|
34199
|
+
if (message.running === true) deadline = Date.now() + GIT_WORKFLOW_MESSAGE_POLL_TIMEOUT_MS;
|
|
33235
34200
|
if (!requireFresh || Date.now() >= deadline) {
|
|
33236
34201
|
throw new Error(`${message.reason || "Generated commit message files are not ready."} Regenerate, or use Preview current message files after verifying both files.`);
|
|
33237
34202
|
}
|
|
@@ -33304,6 +34269,10 @@ async function createGitPrBranchManually(tabId = gitWorkflowActionTabId()) {
|
|
|
33304
34269
|
|
|
33305
34270
|
async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
33306
34271
|
const tabContext = activeTabContext(tabId);
|
|
34272
|
+
if (!hasLoadedRpcCommand("git-branch-name", { tabId })) {
|
|
34273
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("git-branch-name")), "message", { tabId });
|
|
34274
|
+
return;
|
|
34275
|
+
}
|
|
33307
34276
|
const targetTab = tabs.find((tab) => tab.id === tabId);
|
|
33308
34277
|
const targetBusy = tabId === activeTabId ? !!currentState?.isStreaming : activityForTab(targetTab).isWorking;
|
|
33309
34278
|
if (targetBusy) {
|
|
@@ -33326,13 +34295,20 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33326
34295
|
busy: true,
|
|
33327
34296
|
error: "",
|
|
33328
34297
|
branchNameRequestedAt: requestedAt,
|
|
34298
|
+
generationId: "",
|
|
34299
|
+
generationKind: "branch",
|
|
34300
|
+
generationAccepted: false,
|
|
34301
|
+
fallbackStarted: false,
|
|
34302
|
+
fallbackLifecycleKeys: new Set(),
|
|
34303
|
+
pendingFallbackLifecycleEvents: [],
|
|
33329
34304
|
output: "Sending branch-name request to Pi.\n\nCancel will request Pi abort.",
|
|
33330
34305
|
}, { tabId });
|
|
33331
34306
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending branch-name request to Pi…");
|
|
33332
34307
|
try {
|
|
33333
34308
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "branch", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
33334
34309
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
33335
|
-
|
|
34310
|
+
if (!acceptGitWorkflowGenerationCorrelation(generation, tabId)) throw new Error("The WebUI server did not return a branch-name generation ID. Restart Pi Web UI and regenerate.");
|
|
34311
|
+
appendGitWorkflowOutput(`${gitWorkflowGenerationAcceptedText(generation, "Branch-name generation")} Waiting for Pi to finish, then the branch name will be loaded.`, { tabId });
|
|
33336
34312
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
33337
34313
|
setTimeout(() => {
|
|
33338
34314
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -33343,6 +34319,7 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33343
34319
|
}, 2500);
|
|
33344
34320
|
} catch (error) {
|
|
33345
34321
|
if (isCurrentGitWorkflowRun(runId, tabId)) {
|
|
34322
|
+
acceptGitWorkflowGenerationErrorCorrelation(error, tabId);
|
|
33346
34323
|
if (isCurrentTabContext(tabContext)) clearRunIndicatorActivity();
|
|
33347
34324
|
failGitWorkflow(error, "message", { tabId });
|
|
33348
34325
|
}
|
|
@@ -33352,8 +34329,11 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
33352
34329
|
async function loadGitWorkflowBranchName({ requireFresh = false, retries = 0, runId, tabId = activeTabId } = {}) {
|
|
33353
34330
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
33354
34331
|
const expectedRunId = runId ?? workflow?.runId;
|
|
34332
|
+
const generationId = requireFresh ? String(workflow?.generationId || "").trim() : "";
|
|
34333
|
+
if (requireFresh && !generationId) return;
|
|
33355
34334
|
try {
|
|
33356
|
-
const
|
|
34335
|
+
const query = generationId ? `?generationId=${encodeURIComponent(generationId)}` : "";
|
|
34336
|
+
const branchName = await gitWorkflowRequest(`/api/git-workflow/branch-name${query}`, { method: "GET", runId: expectedRunId, tabId });
|
|
33357
34337
|
if (!branchName) return;
|
|
33358
34338
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
33359
34339
|
if (!currentWorkflow) return;
|
|
@@ -33656,8 +34636,8 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
33656
34636
|
failGitWorkflow(new Error("Pi is currently running. Wait for it to finish or abort before generating a PR description."), "push", { tabId });
|
|
33657
34637
|
return;
|
|
33658
34638
|
}
|
|
33659
|
-
if (!
|
|
33660
|
-
failGitWorkflow(new Error(
|
|
34639
|
+
if (!hasLoadedRpcCommand("pr", { tabId })) {
|
|
34640
|
+
failGitWorkflow(new Error(guidedGitPromptCommandUnavailable("pr")), "push", { tabId });
|
|
33661
34641
|
return;
|
|
33662
34642
|
}
|
|
33663
34643
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -33669,13 +34649,20 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
33669
34649
|
busy: true,
|
|
33670
34650
|
error: "",
|
|
33671
34651
|
prRequestedAt: requestedAt,
|
|
34652
|
+
generationId: "",
|
|
34653
|
+
generationKind: "pr",
|
|
34654
|
+
generationAccepted: false,
|
|
34655
|
+
fallbackStarted: false,
|
|
34656
|
+
fallbackLifecycleKeys: new Set(),
|
|
34657
|
+
pendingFallbackLifecycleEvents: [],
|
|
33672
34658
|
output: `${prefixOutput ? `${prefixOutput}\n\n` : ""}Sending /pr to Pi.\n\nCancel will request Pi abort.`,
|
|
33673
34659
|
}, { tabId });
|
|
33674
34660
|
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Sending /pr to Pi…");
|
|
33675
34661
|
try {
|
|
33676
34662
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "pr" }, runId, tabId });
|
|
33677
34663
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
33678
|
-
|
|
34664
|
+
if (!acceptGitWorkflowGenerationCorrelation(generation, tabId)) throw new Error("The WebUI server did not return a PR-text generation ID. Restart Pi Web UI and regenerate.");
|
|
34665
|
+
appendGitWorkflowOutput(`${gitWorkflowGenerationAcceptedText(generation, "PR text generation")} Waiting for Pi to finish, then the PR description will be loaded.`, { tabId });
|
|
33679
34666
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
33680
34667
|
setTimeout(() => {
|
|
33681
34668
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -33686,6 +34673,7 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
33686
34673
|
}, 2500);
|
|
33687
34674
|
} catch (error) {
|
|
33688
34675
|
if (isCurrentGitWorkflowRun(runId, tabId)) {
|
|
34676
|
+
acceptGitWorkflowGenerationErrorCorrelation(error, tabId);
|
|
33689
34677
|
if (isCurrentTabContext(tabContext)) clearRunIndicatorActivity();
|
|
33690
34678
|
failGitWorkflow(error, "push", { tabId });
|
|
33691
34679
|
}
|
|
@@ -33695,8 +34683,11 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
33695
34683
|
async function loadGitWorkflowPr({ requireFresh = false, retries = 0, runId, tabId = activeTabId } = {}) {
|
|
33696
34684
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
33697
34685
|
const expectedRunId = runId ?? workflow?.runId;
|
|
34686
|
+
const generationId = requireFresh ? String(workflow?.generationId || "").trim() : "";
|
|
34687
|
+
if (requireFresh && !generationId) return;
|
|
33698
34688
|
try {
|
|
33699
|
-
const
|
|
34689
|
+
const query = generationId ? `?generationId=${encodeURIComponent(generationId)}` : "";
|
|
34690
|
+
const pr = await gitWorkflowRequest(`/api/git-workflow/pr-description${query}`, { method: "GET", runId: expectedRunId, tabId });
|
|
33700
34691
|
if (!pr) return;
|
|
33701
34692
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
33702
34693
|
if (!currentWorkflow) return;
|
|
@@ -36097,11 +37088,8 @@ function assistantFailureDisplayMessage(message, base) {
|
|
|
36097
37088
|
function assistantDisplayMessages(message) {
|
|
36098
37089
|
if (message?.role !== "assistant") return [message];
|
|
36099
37090
|
const failure = assistantFailureDisplayMessage(message, { timestamp: message.timestamp });
|
|
36100
|
-
|
|
36101
|
-
|
|
36102
|
-
return [...rest, failure];
|
|
36103
|
-
}
|
|
36104
|
-
return assistantDisplayMessagesWithoutFailure(message);
|
|
37091
|
+
const displayMessages = assistantDisplayMessagesWithoutFailure(failure ? { ...message, stopReason: undefined } : message);
|
|
37092
|
+
return groupConsecutiveThinkingMessages(failure ? [...displayMessages, failure] : displayMessages);
|
|
36105
37093
|
}
|
|
36106
37094
|
|
|
36107
37095
|
function assistantDisplayMessagesWithoutFailure(message) {
|
|
@@ -37439,6 +38427,11 @@ function handleToolExecutionEnd(event) {
|
|
|
37439
38427
|
if (run) renderLiveToolRun(run);
|
|
37440
38428
|
}
|
|
37441
38429
|
|
|
38430
|
+
function thinkingDisclosurePreviewText(message, charLimit = 140) {
|
|
38431
|
+
const raw = visibleThinkingText(message?.thinking || textFromContent(message?.content));
|
|
38432
|
+
return speakableTextFromMarkdown(raw).slice(0, Math.max(0, charLimit));
|
|
38433
|
+
}
|
|
38434
|
+
|
|
37442
38435
|
function toolResultPreviewText(message, lineLimit = 10) {
|
|
37443
38436
|
const text = textFromContent(message?.content).replace(/\s+$/g, "");
|
|
37444
38437
|
if (!text) return "(empty tool result)";
|
|
@@ -37592,7 +38585,7 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
37592
38585
|
details.classList.add("thinking-disclosure");
|
|
37593
38586
|
details.open = compactThinkingDisclosureExpanded(thinkingKey, false);
|
|
37594
38587
|
details.addEventListener("toggle", () => setCompactThinkingDisclosureExpanded(thinkingKey, details.open, false));
|
|
37595
|
-
const previewText =
|
|
38588
|
+
const previewText = thinkingDisclosurePreviewText(message);
|
|
37596
38589
|
if (previewText) header.append(make("span", "thinking-disclosure-preview", previewText));
|
|
37597
38590
|
} else if (shouldOpenMessageCollapseByDefault(message)) details.open = true;
|
|
37598
38591
|
details.append(header, body);
|
|
@@ -38162,6 +39155,24 @@ function groupWorkflowStatusTranscriptItems(items, toolResults) {
|
|
|
38162
39155
|
return groupConsecutiveWorkflowStatusItems(projected);
|
|
38163
39156
|
}
|
|
38164
39157
|
|
|
39158
|
+
function transcriptItemThinkingMessage(item) {
|
|
39159
|
+
if (!thinkingOutputVisible) return null;
|
|
39160
|
+
const message = item?.message;
|
|
39161
|
+
const displayMessages = message?.role === "assistant" ? assistantDisplayMessages(message) : [message];
|
|
39162
|
+
if (displayMessages.length !== 1 || displayMessages[0]?.role !== "thinking") return null;
|
|
39163
|
+
const candidate = displayMessages[0];
|
|
39164
|
+
const thinking = visibleThinkingText(candidate.thinking || textFromContent(candidate.content));
|
|
39165
|
+
return thinking ? { ...candidate, content: thinking, thinking } : null;
|
|
39166
|
+
}
|
|
39167
|
+
|
|
39168
|
+
function groupConsecutiveThinkingTranscriptItems(items) {
|
|
39169
|
+
return groupConsecutiveThinkingItems(items, transcriptItemThinkingMessage).map((item) => {
|
|
39170
|
+
if (!(item.thinkingGroupSourceCount > 1)) return item;
|
|
39171
|
+
const sourceKey = item.transcriptKey || `${item.transient ? "t" : "m"}:${item.messageIndex}:${item.order}`;
|
|
39172
|
+
return { ...item, messageIndex: -1, transcriptKey: `thinking-group:${sourceKey}` };
|
|
39173
|
+
});
|
|
39174
|
+
}
|
|
39175
|
+
|
|
38165
39176
|
function orderedTranscriptItems() {
|
|
38166
39177
|
const items = compactOutputActive() ? compactStoredTranscriptItems() : [];
|
|
38167
39178
|
const assistantToolCallIds = buildAssistantToolCallIdSet(latestMessages);
|
|
@@ -38187,7 +39198,8 @@ function orderedTranscriptItems() {
|
|
|
38187
39198
|
}
|
|
38188
39199
|
}
|
|
38189
39200
|
const ordered = items.sort((a, b) => a.timestampMs - b.timestampMs || a.order - b.order);
|
|
38190
|
-
|
|
39201
|
+
const groupedThinking = compactOutputActive() ? ordered : groupConsecutiveThinkingTranscriptItems(ordered);
|
|
39202
|
+
return groupWorkflowStatusTranscriptItems(groupedThinking, toolResults);
|
|
38191
39203
|
}
|
|
38192
39204
|
|
|
38193
39205
|
/**
|
|
@@ -40214,7 +41226,7 @@ function updateOptionalFeatureAvailability() {
|
|
|
40214
41226
|
optionalFeatureAvailability.bangCommandAutocomplete = hasAvailableCommand("bang-status") || hasAvailableCommand("bang-refresh");
|
|
40215
41227
|
optionalFeatureAvailability.fishUserBash = hasAvailableCommand("user-bash-shell");
|
|
40216
41228
|
optionalFeatureAvailability.btwCommand = hasAvailableCommand("btw") || optionalFeatureAvailability.btwCommand || statusEntries.has(BTW_WEBUI_STATUS_KEY) || widgets.has(BTW_OUTPUT_WIDGET_KEY);
|
|
40217
|
-
optionalFeatureAvailability.gitWorkflow = hasAvailableCommand("git-staged-msg");
|
|
41229
|
+
optionalFeatureAvailability.gitWorkflow = hasAvailableCommand("git-guided-workflow") || hasAvailableCommand("git-staged-msg");
|
|
40218
41230
|
optionalFeatureAvailability.releaseNpm = hasAvailableCommand("release-npm");
|
|
40219
41231
|
optionalFeatureAvailability.releaseAur = hasAvailableCommand("release-aur");
|
|
40220
41232
|
optionalFeatureAvailability.aurReview = hasAvailableCommand("aur-review") || optionalFeatureAvailability.aurReview || widgets.has(AUR_REVIEW_RPC_WIDGET_KEY);
|
|
@@ -40441,7 +41453,7 @@ function renderOptionalFeatureSection(section, features) {
|
|
|
40441
41453
|
|
|
40442
41454
|
function optionalFeatureSetupAvailable(feature) {
|
|
40443
41455
|
switch (feature?.setup) {
|
|
40444
|
-
case "git-workflow": return
|
|
41456
|
+
case "git-workflow": return true;
|
|
40445
41457
|
case "workflows": return hasLoadedRpcCommand("workflow-setup");
|
|
40446
41458
|
case "safety-guard": return hasAvailableCommand("safety-guard-setup");
|
|
40447
41459
|
case "skills": return hasLoadedRpcCommand("skills");
|
|
@@ -42541,21 +43553,50 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
42541
43553
|
}, "primary");
|
|
42542
43554
|
}
|
|
42543
43555
|
|
|
42544
|
-
async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
43556
|
+
async function openNativeGitWorkflowSetupDialog({ onSaved, tabId = activeTabId, activationIsCurrent = () => true } = {}) {
|
|
43557
|
+
if (!tabId || !activationIsCurrent()) return "stale";
|
|
43558
|
+
nativeCommandTabId = tabId;
|
|
42545
43559
|
openNativeCommandDialog({
|
|
42546
43560
|
title: "/git-workflow-setup",
|
|
42547
43561
|
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.",
|
|
42548
43562
|
});
|
|
42549
43563
|
renderNativeLoading("Loading guided Git preferences and available models…");
|
|
42550
43564
|
|
|
43565
|
+
const setupOwner = Symbol(tabId);
|
|
43566
|
+
guidedGitSetupDialogOwner = setupOwner;
|
|
43567
|
+
const setupOwnsDialog = () => guidedGitSetupDialogOwner === setupOwner;
|
|
43568
|
+
const closeOwnedSetupDialog = () => {
|
|
43569
|
+
if (setupOwnsDialog()) closeNativeCommandDialog({ force: true });
|
|
43570
|
+
};
|
|
43571
|
+
let setupSettled = false;
|
|
43572
|
+
let saveInFlight = false;
|
|
43573
|
+
let resolveSetup;
|
|
43574
|
+
const setupSettlement = new Promise((resolve) => { resolveSetup = resolve; });
|
|
43575
|
+
const settleSetup = (status) => {
|
|
43576
|
+
if (setupSettled) return;
|
|
43577
|
+
setupSettled = true;
|
|
43578
|
+
if (setupOwnsDialog()) guidedGitSetupDialogOwner = null;
|
|
43579
|
+
elements.nativeCommandDialog.removeEventListener("close", handleSetupClose);
|
|
43580
|
+
resolveSetup(status);
|
|
43581
|
+
};
|
|
43582
|
+
const handleSetupClose = () => {
|
|
43583
|
+
if (!saveInFlight) settleSetup("cancelled");
|
|
43584
|
+
};
|
|
43585
|
+
elements.nativeCommandDialog.addEventListener("close", handleSetupClose);
|
|
43586
|
+
|
|
42551
43587
|
let data;
|
|
42552
43588
|
try {
|
|
42553
|
-
const response = await nativeCommandApi("/api/git-workflow/preferences");
|
|
43589
|
+
const response = await nativeCommandApi("/api/git-workflow/preferences", { tabId });
|
|
42554
43590
|
data = response.data || {};
|
|
42555
43591
|
} catch (error) {
|
|
42556
43592
|
setNativeCommandError(error.message || String(error));
|
|
42557
43593
|
elements.nativeCommandBody.replaceChildren();
|
|
42558
|
-
return;
|
|
43594
|
+
return setupSettlement;
|
|
43595
|
+
}
|
|
43596
|
+
if (!activationIsCurrent()) {
|
|
43597
|
+
closeOwnedSetupDialog();
|
|
43598
|
+
settleSetup("stale");
|
|
43599
|
+
return setupSettlement;
|
|
42559
43600
|
}
|
|
42560
43601
|
|
|
42561
43602
|
const preferences = data.preferences || {};
|
|
@@ -42563,25 +43604,34 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
42563
43604
|
if (!models.length) {
|
|
42564
43605
|
setNativeCommandError("No authenticated Pi models are available. Run /login or configure a provider first.");
|
|
42565
43606
|
elements.nativeCommandBody.replaceChildren();
|
|
42566
|
-
return;
|
|
43607
|
+
return setupSettlement;
|
|
42567
43608
|
}
|
|
42568
43609
|
|
|
42569
43610
|
const configuredModelKey = `${preferences.generation?.provider || ""}/${preferences.generation?.modelId || ""}`;
|
|
42570
|
-
const
|
|
43611
|
+
const configuredFallbackKey = `${preferences.generation?.fallback?.provider || ""}/${preferences.generation?.fallback?.modelId || ""}`;
|
|
43612
|
+
const targetState = tabId === activeTabId ? currentState : tabStateCache.get(tabId);
|
|
43613
|
+
const activeModelKey = gitWorkflowSetupModelKey(targetState?.model);
|
|
42571
43614
|
const modelKeys = new Set(models.map(gitWorkflowSetupModelKey));
|
|
42572
43615
|
const initialModelKey = modelKeys.has(configuredModelKey)
|
|
42573
43616
|
? configuredModelKey
|
|
42574
43617
|
: modelKeys.has(activeModelKey)
|
|
42575
43618
|
? activeModelKey
|
|
42576
43619
|
: gitWorkflowSetupModelKey(models[0]);
|
|
43620
|
+
const initialFallbackKey = modelKeys.has(configuredFallbackKey) && configuredFallbackKey !== initialModelKey ? configuredFallbackKey : "";
|
|
42577
43621
|
const modelOptions = models.map((model) => ({
|
|
42578
43622
|
value: gitWorkflowSetupModelKey(model),
|
|
42579
43623
|
label: `${gitWorkflowSetupModelKey(model)}${model.name && model.name !== model.id ? ` · ${model.name}` : ""}`,
|
|
42580
43624
|
}));
|
|
43625
|
+
const fallbackModelOptions = (primaryKey) => [
|
|
43626
|
+
{ value: "", label: "No fallback" },
|
|
43627
|
+
...modelOptions.filter((option) => option.value !== primaryKey),
|
|
43628
|
+
];
|
|
42581
43629
|
|
|
42582
43630
|
const controls = {
|
|
42583
|
-
model: nativeSettingSelect("Git-writing model", initialModelKey, modelOptions, "Exact authenticated provider/model used for commit messages, branch names, and PR descriptions.", { label: "required", tone: "safety" }),
|
|
42584
|
-
thinking: nativeSettingSelect("
|
|
43631
|
+
model: nativeSettingSelect("Primary Git-writing model", initialModelKey, modelOptions, "Exact authenticated provider/model normally used for commit messages, branch names, and PR descriptions.", { label: "required", tone: "safety" }),
|
|
43632
|
+
thinking: nativeSettingSelect("Primary reasoning effort", preferences.generation?.thinkingLevel || "low", SETTINGS_THINKING_OPTIONS, "Only levels supported by the primary model are shown. Low is recommended for routine commit messages.", { label: "required", tone: "safety" }),
|
|
43633
|
+
fallbackModel: nativeSettingSelect("Fallback model", initialFallbackKey, fallbackModelOptions(initialModelKey), "Optional. After a final primary model-generation failure, Guided Git tries this different model once.", { label: "optional", tone: "browser" }),
|
|
43634
|
+
fallbackThinking: nativeSettingSelect("Fallback reasoning effort", preferences.generation?.fallback?.thinkingLevel || "low", SETTINGS_THINKING_OPTIONS, "Uses only levels supported by the fallback model and is disabled when No fallback is selected.", { label: "optional", tone: "browser" }),
|
|
42585
43635
|
language: nativeSettingSelect("Generated language", preferences.commit?.language || "en", [
|
|
42586
43636
|
{ value: "en", label: "English" },
|
|
42587
43637
|
{ value: "de", label: "German" },
|
|
@@ -42624,13 +43674,30 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
42624
43674
|
const levels = thinkingLevelsForModel(controls.model.select.value);
|
|
42625
43675
|
replaceNativeSettingSelectOptions(controls.thinking.select, levels, current);
|
|
42626
43676
|
};
|
|
42627
|
-
|
|
43677
|
+
const syncFallbackThinkingLevels = () => {
|
|
43678
|
+
const fallbackKey = controls.fallbackModel.select.value;
|
|
43679
|
+
const current = controls.fallbackThinking.select.value || preferences.generation?.fallback?.thinkingLevel || "low";
|
|
43680
|
+
const levels = fallbackKey ? thinkingLevelsForModel(fallbackKey) : [preferences.generation?.fallback?.thinkingLevel || "low"];
|
|
43681
|
+
replaceNativeSettingSelectOptions(controls.fallbackThinking.select, levels, current);
|
|
43682
|
+
controls.fallbackThinking.select.disabled = !fallbackKey;
|
|
43683
|
+
};
|
|
43684
|
+
const syncFallbackModelOptions = () => {
|
|
43685
|
+
const current = controls.fallbackModel.select.value;
|
|
43686
|
+
replaceNativeSettingSelectOptions(controls.fallbackModel.select, fallbackModelOptions(controls.model.select.value), current);
|
|
43687
|
+
syncFallbackThinkingLevels();
|
|
43688
|
+
};
|
|
43689
|
+
controls.model.select.addEventListener("change", () => {
|
|
43690
|
+
syncThinkingLevels();
|
|
43691
|
+
syncFallbackModelOptions();
|
|
43692
|
+
});
|
|
43693
|
+
controls.fallbackModel.select.addEventListener("change", syncFallbackThinkingLevels);
|
|
42628
43694
|
syncThinkingLevels();
|
|
43695
|
+
syncFallbackModelOptions();
|
|
42629
43696
|
|
|
42630
43697
|
const body = make("div", "native-settings-panel");
|
|
42631
43698
|
body.append(
|
|
42632
43699
|
nativeSettingsNote("Persistence", `Saved globally in ${data.path || "the Pi Web UI settings file"}. Credentials are never stored here.`),
|
|
42633
|
-
nativeSettingsSection("Generation profile", "
|
|
43700
|
+
nativeSettingsSection("Generation profile", "Choose the required primary profile and an optional one-shot fallback with its own effort.", [controls.model, controls.thinking, controls.fallbackModel, controls.fallbackThinking], { open: true }),
|
|
42634
43701
|
nativeSettingsSection("Commit style", "Conventional Commit output preferences.", [controls.language, controls.defaultVariant, controls.scope], { open: true }),
|
|
42635
43702
|
nativeSettingsSection("Workflow safety", "Staging, review, delivery, and verification defaults; push and PR confirmation remain mandatory.", [controls.staging, controls.reviewProcess, controls.delivery, controls.verification], { open: true }),
|
|
42636
43703
|
);
|
|
@@ -42639,13 +43706,24 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
42639
43706
|
addNativeCommandAction("Cancel", closeNativeCommandDialog);
|
|
42640
43707
|
|
|
42641
43708
|
const save = addNativeCommandAction("Save setup", async () => {
|
|
43709
|
+
saveInFlight = true;
|
|
42642
43710
|
setNativeActionBusy(save, true, "Saving…");
|
|
42643
43711
|
setNativeCommandError("");
|
|
42644
43712
|
try {
|
|
43713
|
+
if (!activationIsCurrent()) {
|
|
43714
|
+
closeOwnedSetupDialog();
|
|
43715
|
+
settleSetup("stale");
|
|
43716
|
+
return;
|
|
43717
|
+
}
|
|
42645
43718
|
const selectedModel = models.find((model) => gitWorkflowSetupModelKey(model) === controls.model.select.value);
|
|
42646
|
-
if (!selectedModel) throw new Error("Select an available Git-writing model.");
|
|
43719
|
+
if (!selectedModel) throw new Error("Select an available primary Git-writing model.");
|
|
43720
|
+
const selectedFallback = models.find((model) => gitWorkflowSetupModelKey(model) === controls.fallbackModel.select.value) || null;
|
|
43721
|
+
if (selectedFallback && gitWorkflowSetupModelKey(selectedFallback) === gitWorkflowSetupModelKey(selectedModel)) {
|
|
43722
|
+
throw new Error("Select a fallback model different from the primary model.");
|
|
43723
|
+
}
|
|
42647
43724
|
const response = await nativeCommandApi("/api/git-workflow/preferences", {
|
|
42648
43725
|
method: "POST",
|
|
43726
|
+
tabId,
|
|
42649
43727
|
body: {
|
|
42650
43728
|
preferences: {
|
|
42651
43729
|
generation: {
|
|
@@ -42653,6 +43731,11 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
42653
43731
|
modelId: selectedModel.id,
|
|
42654
43732
|
thinkingLevel: controls.thinking.select.value,
|
|
42655
43733
|
unavailablePolicy: "ask",
|
|
43734
|
+
fallback: {
|
|
43735
|
+
provider: selectedFallback?.provider || "",
|
|
43736
|
+
modelId: selectedFallback?.id || "",
|
|
43737
|
+
thinkingLevel: controls.fallbackThinking.select.value || preferences.generation?.fallback?.thinkingLevel || "low",
|
|
43738
|
+
},
|
|
42656
43739
|
},
|
|
42657
43740
|
commit: {
|
|
42658
43741
|
language: controls.language.select.value,
|
|
@@ -42666,21 +43749,37 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
42666
43749
|
},
|
|
42667
43750
|
},
|
|
42668
43751
|
});
|
|
43752
|
+
if (!activationIsCurrent()) {
|
|
43753
|
+
closeOwnedSetupDialog();
|
|
43754
|
+
settleSetup("stale");
|
|
43755
|
+
return;
|
|
43756
|
+
}
|
|
42669
43757
|
gitWorkflowPreferences = response.data?.preferences || null;
|
|
42670
43758
|
addTransientMessage({
|
|
42671
43759
|
role: "native",
|
|
42672
43760
|
title: "/git-workflow-setup",
|
|
42673
|
-
content: `Guided Git setup saved
|
|
43761
|
+
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."}`,
|
|
42674
43762
|
level: "info",
|
|
42675
43763
|
});
|
|
42676
|
-
|
|
42677
|
-
|
|
43764
|
+
nativeSettingsDirty = false;
|
|
43765
|
+
closeOwnedSetupDialog();
|
|
43766
|
+
if (typeof onSaved === "function" && activationIsCurrent()) {
|
|
43767
|
+
try {
|
|
43768
|
+
await onSaved(gitWorkflowPreferences);
|
|
43769
|
+
} catch (error) {
|
|
43770
|
+
addEvent(`Guided Git could not continue after setup: ${error?.message || String(error)}`, "error");
|
|
43771
|
+
}
|
|
43772
|
+
}
|
|
43773
|
+
settleSetup(activationIsCurrent() ? "saved" : "stale");
|
|
42678
43774
|
} catch (error) {
|
|
42679
43775
|
setNativeCommandError(error.message || String(error));
|
|
42680
43776
|
} finally {
|
|
43777
|
+
saveInFlight = false;
|
|
42681
43778
|
setNativeActionBusy(save, false);
|
|
43779
|
+
if (!elements.nativeCommandDialog.open) settleSetup("cancelled");
|
|
42682
43780
|
}
|
|
42683
43781
|
}, "primary");
|
|
43782
|
+
return setupSettlement;
|
|
42684
43783
|
}
|
|
42685
43784
|
|
|
42686
43785
|
function normalizedWorkflowPolicyList(value) {
|
|
@@ -45850,7 +46949,7 @@ function commandPaletteCoreItems() {
|
|
|
45850
46949
|
{ kind: "Pi", label: "/tools", description: "Manage active tools", keywords: "capabilities", run: () => runNativeCommandMenu("/tools") },
|
|
45851
46950
|
{ kind: "Pi", label: "/skills", description: "Manage active skills", keywords: "system prompt", run: () => runNativeCommandMenu("/skills") },
|
|
45852
46951
|
{ kind: "Pi", label: "/theme", description: "Choose the Web UI theme", keywords: "dark light colors appearance", run: () => openNativeThemeSelector() },
|
|
45853
|
-
{ 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: () =>
|
|
46952
|
+
{ 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() },
|
|
45854
46953
|
{ kind: "Git", label: "Git changes", description: "Review and stage local changes with diffs", keywords: "git diff stage unstage discard status", run: () => openGitChangesDialog() },
|
|
45855
46954
|
{ kind: "Action", label: "Files panel", description: "Open the Files section of the Control Deck", keywords: "tree browse project explorer", run: () => revealSidePanelSectionById("files") },
|
|
45856
46955
|
{ kind: "Action", label: "Git panel", description: "Open the Git section of the Control Deck", keywords: "repository status history", run: () => revealSidePanelSectionById("git") },
|
|
@@ -46596,6 +47695,17 @@ function createBrowserPromptRequestId() {
|
|
|
46596
47695
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
46597
47696
|
}
|
|
46598
47697
|
|
|
47698
|
+
function createBrowserGuidedGitLaunchId() {
|
|
47699
|
+
const generated = globalThis.crypto?.randomUUID?.();
|
|
47700
|
+
if (generated) return generated;
|
|
47701
|
+
const bytes = new Uint8Array(16);
|
|
47702
|
+
globalThis.crypto?.getRandomValues?.(bytes);
|
|
47703
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
47704
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
47705
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
47706
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
47707
|
+
}
|
|
47708
|
+
|
|
46599
47709
|
async function retryMobileFailedSend() {
|
|
46600
47710
|
const pending = mobileFailedSend;
|
|
46601
47711
|
if (!pending || pending.retrying) return;
|
|
@@ -46656,8 +47766,24 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
46656
47766
|
return;
|
|
46657
47767
|
}
|
|
46658
47768
|
|
|
46659
|
-
const
|
|
46660
|
-
|
|
47769
|
+
const guidedGitExtensionLaunch = kind === "prompt"
|
|
47770
|
+
&& attachments.length === 0
|
|
47771
|
+
&& guidedGitWorkflowCommandForTabCatalog(commandCatalogForTab(targetTabId), originalMessage);
|
|
47772
|
+
let guidedGitPermitGranted = false;
|
|
47773
|
+
let guidedGitLaunchId = "";
|
|
47774
|
+
if (guidedGitExtensionLaunch) {
|
|
47775
|
+
if (!guidedGitLaunchAdmitted(targetTabId)) return;
|
|
47776
|
+
guidedGitLaunchId = createBrowserGuidedGitLaunchId();
|
|
47777
|
+
if (!guidedGitLaunchPermits.grant(targetTabId, guidedGitLaunchId)) {
|
|
47778
|
+
addEvent("Guided Git activation is already pending for this tab.", "warn");
|
|
47779
|
+
return;
|
|
47780
|
+
}
|
|
47781
|
+
guidedGitPermitGranted = true;
|
|
47782
|
+
}
|
|
47783
|
+
|
|
47784
|
+
const targetState = targetTabId === activeTabId ? currentState : tabStateCache.get(targetTabId);
|
|
47785
|
+
const targetWasStreaming = !!targetState?.isStreaming;
|
|
47786
|
+
const targetWasCompacting = !!targetState?.isCompacting;
|
|
46661
47787
|
const targetWasBusy = targetWasStreaming || targetWasCompacting;
|
|
46662
47788
|
const busyBehavior = normalizeBusyPromptBehavior(busyPromptBehavior);
|
|
46663
47789
|
const startsRun = kind === "prompt" && !targetWasBusy;
|
|
@@ -46688,6 +47814,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
46688
47814
|
// targetTabId. This implementation intentionally never retries an
|
|
46689
47815
|
// ambiguous mutation automatically.
|
|
46690
47816
|
if (kind === "prompt") bodyBase.requestId = createBrowserPromptRequestId();
|
|
47817
|
+
if (guidedGitLaunchId) bodyBase.guidedGitLaunchId = guidedGitLaunchId;
|
|
46691
47818
|
if (prepared.images.length) bodyBase.images = prepared.images;
|
|
46692
47819
|
if (!message.startsWith("/")) {
|
|
46693
47820
|
rememberPromptHistory(message, { tabId: targetTabId });
|
|
@@ -46737,6 +47864,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
|
|
|
46737
47864
|
scheduleRefreshTabs(300);
|
|
46738
47865
|
}
|
|
46739
47866
|
} catch (error) {
|
|
47867
|
+
if (guidedGitPermitGranted) guidedGitLaunchPermits.clearTab(targetTabId);
|
|
46740
47868
|
restorePromptInputAfterRoutingError(inputMessage, { usesPromptInput, targetTabId, tabContext });
|
|
46741
47869
|
if (dispatchedRequest?.kind === "prompt" && dispatchedRequest.body?.requestId && error?.backendOffline === true && isMobileShellV2Active()) {
|
|
46742
47870
|
mobileFailedSend = { ...dispatchedRequest, retrying: false };
|
|
@@ -46781,6 +47909,7 @@ function removeQueuedDialogRequests(ids = []) {
|
|
|
46781
47909
|
}
|
|
46782
47910
|
|
|
46783
47911
|
function handleExtensionUiRequest(request) {
|
|
47912
|
+
if (handleGuidedGitActivationRequest(request)) return;
|
|
46784
47913
|
request.tabId ||= activeTabId;
|
|
46785
47914
|
switch (request.method) {
|
|
46786
47915
|
case "notify": {
|
|
@@ -47314,7 +48443,7 @@ function supervisorContinuityKey(event, fallbackTabId = activeTabId) {
|
|
|
47314
48443
|
function scheduleSupervisorContinuityRefresh(event, { gap = false } = {}) {
|
|
47315
48444
|
const tabContext = activeTabContext(event?.tabId || activeTabId);
|
|
47316
48445
|
const key = supervisorContinuityKey(event, tabContext.tabId);
|
|
47317
|
-
if (!key || !tabContext.tabId || !isCurrentTabContext(tabContext)) return;
|
|
48446
|
+
if (!key || !tabContext.tabId || !isCurrentTabContext(tabContext) || closingTerminalTabIds.has(tabContext.tabId)) return;
|
|
47318
48447
|
|
|
47319
48448
|
if (gap && !supervisorGapWarnings.has(key)) {
|
|
47320
48449
|
supervisorGapWarnings.add(key);
|
|
@@ -47324,14 +48453,15 @@ function scheduleSupervisorContinuityRefresh(event, { gap = false } = {}) {
|
|
|
47324
48453
|
|
|
47325
48454
|
const timer = setTimeout(async () => {
|
|
47326
48455
|
try {
|
|
48456
|
+
if (closingTerminalTabIds.has(tabContext.tabId)) return;
|
|
47327
48457
|
const results = await Promise.allSettled([refreshTabs()]);
|
|
47328
|
-
if (isCurrentTabContext(tabContext)) {
|
|
48458
|
+
if (isCurrentTabContext(tabContext) && !closingTerminalTabIds.has(tabContext.tabId)) {
|
|
47329
48459
|
results.push(...(await Promise.allSettled([
|
|
47330
48460
|
refreshState(tabContext),
|
|
47331
48461
|
refreshMessages(tabContext, { authoritative: true }),
|
|
47332
48462
|
])));
|
|
47333
48463
|
}
|
|
47334
|
-
if (!isCurrentTabContext(tabContext)) return;
|
|
48464
|
+
if (!isCurrentTabContext(tabContext) || closingTerminalTabIds.has(tabContext.tabId)) return;
|
|
47335
48465
|
for (const result of results) {
|
|
47336
48466
|
if (result.status === "rejected") addEvent(`continuity refresh failed: ${result.reason?.message || String(result.reason)}`, "error");
|
|
47337
48467
|
}
|
|
@@ -47343,6 +48473,7 @@ function scheduleSupervisorContinuityRefresh(event, { gap = false } = {}) {
|
|
|
47343
48473
|
}
|
|
47344
48474
|
|
|
47345
48475
|
function handleInactiveTabEvent(event) {
|
|
48476
|
+
if (handleGuidedGitActivationRequest(event)) return;
|
|
47346
48477
|
if (event.type === "extension_ui_request" && EXTENSION_UI_BLOCKING_METHODS.has(event.method)) {
|
|
47347
48478
|
if (!event.replayed) notifyBlockedTab(event.tabId, { request: event, count: event.pendingExtensionUiRequestCount });
|
|
47348
48479
|
renderTabs();
|
|
@@ -47453,6 +48584,7 @@ function handleEvent(event) {
|
|
|
47453
48584
|
// the same run identity semantics as the foreground tab.
|
|
47454
48585
|
if (event?.type === "agent_start") beginToolBoundaryRun(event);
|
|
47455
48586
|
if (eventMayAffectSkillUsage(event)) trackSkillsFromEvent(event);
|
|
48587
|
+
if (handleGitWorkflowFallbackLifecycleEvent(event)) return;
|
|
47456
48588
|
if (!eventTargetsActiveTab(event)) {
|
|
47457
48589
|
handleInactiveTabEvent(event);
|
|
47458
48590
|
return;
|
|
@@ -47702,7 +48834,7 @@ function handleEvent(event) {
|
|
|
47702
48834
|
handleToolExecutionStart(event);
|
|
47703
48835
|
}
|
|
47704
48836
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`);
|
|
47705
|
-
if (claimToolBoundaryRecord(event, "log:start")) addEvent(
|
|
48837
|
+
if (claimToolBoundaryRecord(event, "log:start")) addEvent(...toolLifecycleEventArguments(event, "start"));
|
|
47706
48838
|
break;
|
|
47707
48839
|
case "tool_execution_end": {
|
|
47708
48840
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: false });
|
|
@@ -47722,7 +48854,7 @@ function handleEvent(event) {
|
|
|
47722
48854
|
handleToolExecutionEnd(event);
|
|
47723
48855
|
}
|
|
47724
48856
|
setRunIndicatorActivity(`Tool ${runIndicatorToolName(event.toolName)} ${event.isError ? "failed" : "finished"}; waiting for the agent's next step…`);
|
|
47725
|
-
if (claimToolBoundaryRecord(event, "log:end")) addEvent(
|
|
48857
|
+
if (claimToolBoundaryRecord(event, "log:end")) addEvent(...toolLifecycleEventArguments(event, "finish"));
|
|
47726
48858
|
// Compact tool shells deliberately defer rich body construction to the
|
|
47727
48859
|
// final transcript reconciliation; normal mode retains its live card.
|
|
47728
48860
|
scheduleSemanticReconcile({ footerData: true }, tabContext);
|
|
@@ -48095,7 +49227,7 @@ elements.commandPaletteButton?.addEventListener("click", () => openCommandPalett
|
|
|
48095
49227
|
elements.workspaceDashboardToggleButton?.addEventListener("click", () => setWorkspaceDashboardCollapsed(!workspaceDashboardCollapsed));
|
|
48096
49228
|
elements.gitWorkflowButton.addEventListener("click", () => {
|
|
48097
49229
|
setComposerActionsOpen(false);
|
|
48098
|
-
|
|
49230
|
+
launchGuidedGitWorkflow();
|
|
48099
49231
|
});
|
|
48100
49232
|
const publishMenuContainer = elements.publishButton.parentElement;
|
|
48101
49233
|
elements.publishButton.addEventListener("click", () => {
|
|
@@ -49122,6 +50254,9 @@ document.addEventListener("pointerdown", (event) => {
|
|
|
49122
50254
|
if (elements.gitFooterContextMenu && !elements.gitFooterContextMenu.hidden && !event.target?.closest?.(".git-footer-context-menu")) {
|
|
49123
50255
|
closeGitFooterContextMenu();
|
|
49124
50256
|
}
|
|
50257
|
+
if (elements.eventTreeContextMenu && !elements.eventTreeContextMenu.hidden && !event.target?.closest?.(".event-tree-context-menu")) {
|
|
50258
|
+
closeEventTreeContextMenu();
|
|
50259
|
+
}
|
|
49125
50260
|
}, { passive: true });
|
|
49126
50261
|
document.addEventListener("pointermove", (event) => {
|
|
49127
50262
|
if (openTerminalTabGroupKey && !event.target?.closest?.(".terminal-tab-group")) {
|
|
@@ -49449,6 +50584,7 @@ window.addEventListener("storage", (event) => {
|
|
|
49449
50584
|
footerScopedModels = orderedFooterScopedModels();
|
|
49450
50585
|
renderFooter();
|
|
49451
50586
|
}
|
|
50587
|
+
if (event.key === FOOTER_SCOPED_MODEL_LAYOUT_STORAGE_KEY) setFooterScopedModelLayout(event.newValue, { persist: false });
|
|
49452
50588
|
if (event.key === FILE_VIEWER_WIDTH_STORAGE_KEY) restoreFileViewerWidthPreference();
|
|
49453
50589
|
});
|
|
49454
50590
|
// Durable layout reconciliation runs on its own foreground/online lifecycle
|
|
@@ -49516,7 +50652,7 @@ window.addEventListener("keydown", (event) => {
|
|
|
49516
50652
|
return;
|
|
49517
50653
|
}
|
|
49518
50654
|
if (isFooterPickerOpen()) {
|
|
49519
|
-
setFooterModelPickerOpen(false);
|
|
50655
|
+
setFooterModelPickerOpen(false, { restoreFocus: footerModelPickerOpen });
|
|
49520
50656
|
setFooterThinkingPickerOpen(false);
|
|
49521
50657
|
setFooterBranchPickerOpen(false);
|
|
49522
50658
|
return;
|
|
@@ -49620,6 +50756,59 @@ elements.fileTreeSearchInput?.addEventListener("keydown", (event) => {
|
|
|
49620
50756
|
}
|
|
49621
50757
|
});
|
|
49622
50758
|
elements.fileTreeSearchClearButton?.addEventListener("click", () => clearFileTreeSearch({ focus: true }));
|
|
50759
|
+
syncEventDisplayModeUi();
|
|
50760
|
+
syncEventFilterUi();
|
|
50761
|
+
elements.eventFilterSelect?.addEventListener("change", () => setEventFilter(elements.eventFilterSelect.value));
|
|
50762
|
+
elements.eventLog?.addEventListener("contextmenu", (event) => {
|
|
50763
|
+
const line = event.target?.closest?.(".event") || null;
|
|
50764
|
+
if (!line && event.target !== elements.eventLog) return;
|
|
50765
|
+
showEventTreeContextMenu(event, line);
|
|
50766
|
+
});
|
|
50767
|
+
elements.eventLog?.addEventListener("keydown", (event) => {
|
|
50768
|
+
if (event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10")) return;
|
|
50769
|
+
const line = event.target?.closest?.(".event");
|
|
50770
|
+
if (!line || !elements.eventLog.contains(line)) return;
|
|
50771
|
+
const rect = line.getBoundingClientRect();
|
|
50772
|
+
showEventTreeContextMenu({
|
|
50773
|
+
preventDefault: () => event.preventDefault(),
|
|
50774
|
+
stopPropagation: () => event.stopPropagation(),
|
|
50775
|
+
clientX: rect.left + Math.min(rect.width, 24),
|
|
50776
|
+
clientY: rect.bottom,
|
|
50777
|
+
}, line);
|
|
50778
|
+
});
|
|
50779
|
+
elements.eventTreeContextMenu?.addEventListener("keydown", (event) => {
|
|
50780
|
+
const items = [...elements.eventTreeContextMenu.querySelectorAll('[role="menuitem"]:not([disabled]):not([hidden]), [role="menuitemradio"]:not([disabled]):not([hidden])')];
|
|
50781
|
+
const index = items.indexOf(document.activeElement);
|
|
50782
|
+
if (event.key === "Escape") {
|
|
50783
|
+
event.preventDefault();
|
|
50784
|
+
closeEventTreeContextMenu();
|
|
50785
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
50786
|
+
event.preventDefault();
|
|
50787
|
+
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
50788
|
+
items[(Math.max(0, index) + direction + items.length) % items.length]?.focus({ preventScroll: true });
|
|
50789
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
50790
|
+
event.preventDefault();
|
|
50791
|
+
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
50792
|
+
}
|
|
50793
|
+
});
|
|
50794
|
+
elements.eventDisplayDetailedAction?.addEventListener("click", () => {
|
|
50795
|
+
setEventDisplayMode("detailed");
|
|
50796
|
+
closeEventTreeContextMenu();
|
|
50797
|
+
});
|
|
50798
|
+
elements.eventDisplayCompactAction?.addEventListener("click", () => {
|
|
50799
|
+
setEventDisplayMode("compact");
|
|
50800
|
+
closeEventTreeContextMenu();
|
|
50801
|
+
});
|
|
50802
|
+
elements.eventTreeContextMenuAction?.addEventListener("click", () => void navigateEventTreeBoundary());
|
|
50803
|
+
window.addEventListener("storage", (event) => {
|
|
50804
|
+
if (event.key === EVENT_DISPLAY_MODE_STORAGE_KEY) setEventDisplayMode(event.newValue, { persist: false });
|
|
50805
|
+
if (event.key === EVENT_FILTER_STORAGE_KEY) setEventFilter(event.newValue, { persist: false });
|
|
50806
|
+
});
|
|
50807
|
+
window.addEventListener("resize", () => closeEventTreeContextMenu(), { passive: true });
|
|
50808
|
+
document.addEventListener("scroll", () => {
|
|
50809
|
+
if (!eventTreeContextMenuState || performance.now() - eventTreeContextMenuState.openedAt < 100) return;
|
|
50810
|
+
closeEventTreeContextMenu();
|
|
50811
|
+
}, { capture: true, passive: true });
|
|
49623
50812
|
elements.fileContextMenu?.addEventListener("keydown", (event) => {
|
|
49624
50813
|
const items = [...elements.fileContextMenu.querySelectorAll('[role="menuitem"]:not([disabled])')];
|
|
49625
50814
|
const index = items.indexOf(document.activeElement);
|
|
@@ -49694,12 +50883,17 @@ elements.visibilityContextMenu?.addEventListener("click", (event) => {
|
|
|
49694
50883
|
return;
|
|
49695
50884
|
}
|
|
49696
50885
|
const action = button.dataset.visibilityMenuAction;
|
|
49697
|
-
if (action === "
|
|
50886
|
+
if (action === "open-setup") {
|
|
50887
|
+
const trigger = visibilityContextMenuState?.trigger;
|
|
50888
|
+
closeVisibilityContextMenu({ returnFocus: false });
|
|
50889
|
+
openControlVisibilitySetupDialog(trigger);
|
|
50890
|
+
} else if (action === "hide") {
|
|
49698
50891
|
const entryId = visibilityContextMenuState?.entryId;
|
|
49699
|
-
closeVisibilityContextMenu();
|
|
50892
|
+
closeVisibilityContextMenu({ returnFocus: false });
|
|
49700
50893
|
if (entryId) {
|
|
49701
50894
|
const label = CONTROL_VISIBILITY_REGISTRY.get(entryId)?.label || "control";
|
|
49702
50895
|
setControlVisibilityHidden(entryId, true);
|
|
50896
|
+
elements.promptInput?.focus({ preventScroll: true });
|
|
49703
50897
|
offerUndo({
|
|
49704
50898
|
message: `Hid ${label}. Right-click a toolbar area (or use the command palette) to show hidden controls again.`,
|
|
49705
50899
|
undo: () => setControlVisibilityHidden(entryId, false),
|
|
@@ -49714,8 +50908,30 @@ elements.visibilityContextMenu?.addEventListener("click", (event) => {
|
|
|
49714
50908
|
resetControlVisibilityDefaults();
|
|
49715
50909
|
}
|
|
49716
50910
|
});
|
|
50911
|
+
elements.controlVisibilitySetupBody?.addEventListener("change", (event) => {
|
|
50912
|
+
const checkbox = event.target?.closest?.("[data-visibility-setup-id]");
|
|
50913
|
+
if (!(checkbox instanceof HTMLInputElement)) return;
|
|
50914
|
+
const entry = CONTROL_VISIBILITY_REGISTRY.get(checkbox.dataset.visibilitySetupId);
|
|
50915
|
+
if (!entry) return;
|
|
50916
|
+
setControlVisibilityHidden(entry.id, !checkbox.checked);
|
|
50917
|
+
refreshControlVisibilitySetupDialog();
|
|
50918
|
+
setControlVisibilitySetupStatus(`${entry.label} is ${checkbox.checked ? "shown" : "hidden"} by preference.`);
|
|
50919
|
+
});
|
|
50920
|
+
elements.controlVisibilitySetupShowAllButton?.addEventListener("click", () => {
|
|
50921
|
+
showAllControls();
|
|
50922
|
+
refreshControlVisibilitySetupDialog();
|
|
50923
|
+
setControlVisibilitySetupStatus("All optional controls are shown by preference.");
|
|
50924
|
+
});
|
|
50925
|
+
elements.controlVisibilitySetupResetButton?.addEventListener("click", () => {
|
|
50926
|
+
resetControlVisibilityDefaults();
|
|
50927
|
+
refreshControlVisibilitySetupDialog();
|
|
50928
|
+
setControlVisibilitySetupStatus("Control visibility was reset to its defaults.");
|
|
50929
|
+
});
|
|
50930
|
+
elements.controlVisibilitySetupCloseButton?.addEventListener("click", () => elements.controlVisibilitySetupDialog?.close());
|
|
50931
|
+
elements.controlVisibilitySetupDialog?.querySelector("form")?.addEventListener("submit", (event) => event.preventDefault());
|
|
50932
|
+
elements.controlVisibilitySetupDialog?.addEventListener("close", restoreControlVisibilitySetupFocus);
|
|
49717
50933
|
elements.gitFooterContextMenu?.addEventListener("keydown", (event) => {
|
|
49718
|
-
const items = [...elements.gitFooterContextMenu.querySelectorAll('[role="menuitem"]:not([disabled])')];
|
|
50934
|
+
const items = [...elements.gitFooterContextMenu.querySelectorAll('[role="menuitem"]:not([disabled]):not([hidden]), [role="menuitemcheckbox"]:not([disabled]):not([hidden])')];
|
|
49719
50935
|
const index = items.indexOf(document.activeElement);
|
|
49720
50936
|
if (event.key === "Escape") {
|
|
49721
50937
|
event.preventDefault();
|
|
@@ -49736,6 +50952,7 @@ elements.gitFooterContextMenu?.addEventListener("click", (event) => {
|
|
|
49736
50952
|
const action = button.dataset.gitFooterMenuAction;
|
|
49737
50953
|
closeGitFooterContextMenu({ returnFocus: action !== "visibility" });
|
|
49738
50954
|
if (action === "disable") void disableGitFooterContextChip(state.key, state.label);
|
|
50955
|
+
else if (action === "toggle-advanced" && state.key === "model") toggleFooterScopedModelLayout();
|
|
49739
50956
|
else if (action === "visibility") openGitFooterVisibilityDialog();
|
|
49740
50957
|
});
|
|
49741
50958
|
elements.fileTreeNewFileButton?.addEventListener("click", () => createFileTreeEntry(null, "file").catch((error) => addEvent(error.message || String(error), "error")));
|