@firstpick/pi-package-webui 0.5.7 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/app.js CHANGED
@@ -52,6 +52,7 @@ const elements = {
52
52
  busyPromptBehaviorTag: $("#busyPromptBehaviorTag"),
53
53
  busyPromptBehaviorMenu: $("#busyPromptBehaviorMenu"),
54
54
  sessionSkillTags: $("#sessionSkillTags"),
55
+ conversationModeChip: $("#conversationModeChip"),
55
56
  skillEditorDialog: $("#skillEditorDialog"),
56
57
  skillEditorTitle: $("#skillEditorTitle"),
57
58
  skillEditorMeta: $("#skillEditorMeta"),
@@ -68,6 +69,7 @@ const elements = {
68
69
  steerButton: $("#steerButton"),
69
70
  followUpButton: $("#followUpButton"),
70
71
  abortButton: $("#abortButton"),
72
+ conversationModeEndButton: $("#conversationModeEndButton"),
71
73
  newSessionButton: $("#newSessionButton"),
72
74
  compactButton: $("#compactButton"),
73
75
  gitWorkflowButton: $("#gitWorkflowButton"),
@@ -86,6 +88,7 @@ const elements = {
86
88
  optionsMenuButton: $("#optionsMenuButton"),
87
89
  optionsMenu: $("#optionsMenu"),
88
90
  optionsCommandPaletteButton: $("#optionsCommandPaletteButton"),
91
+ optionsConversationModeButton: $("#optionsConversationModeButton"),
89
92
  optionsResumeButton: $("#optionsResumeButton"),
90
93
  optionsReloadButton: $("#optionsReloadButton"),
91
94
  optionsRemoteButton: $("#optionsRemoteButton"),
@@ -142,6 +145,7 @@ const elements = {
142
145
  remoteAuthToggle: $("#remoteAuthToggle"),
143
146
  remoteAuthStatus: $("#remoteAuthStatus"),
144
147
  openNetworkButton: $("#openNetworkButton"),
148
+ showRemoteQrButton: $("#showRemoteQrButton"),
145
149
  remoteQrDialog: $("#remoteQrDialog"),
146
150
  remoteQrMessage: $("#remoteQrMessage"),
147
151
  remoteQrBody: $("#remoteQrBody"),
@@ -295,7 +299,7 @@ let foregroundReconcileTimer = null;
295
299
  let eventSource = null;
296
300
  let activeDialog = null;
297
301
  let activeGitPrDialogResolve = null;
298
- let gitChangesState = { loading: false, pulling: false, error: "", message: "", data: null, tabId: null };
302
+ let gitChangesState = { loading: false, pulling: false, error: "", message: "", pullResult: null, data: null, tabId: null };
299
303
  let gitChangesRequestSerial = 0;
300
304
  const gitChangesUntrackedContentRequests = new Set();
301
305
  let nativeCommandTabId = null;
@@ -484,6 +488,8 @@ const GIT_INIT_STACK_STORAGE_KEY = "pi-webui-git-init-stack";
484
488
  const STATS_WEBUI_STATUS_KEY = "stats-webui";
485
489
  const STATS_WEBUI_PAYLOAD_TYPE = "firstpick.pi-extension-stats.overlay";
486
490
  const STATS_WEBUI_PAYLOAD_VERSION = 1;
491
+ const NATURAL_CONVERSATION_STATUS_KEY = "natural-conversation";
492
+ const NATURAL_CONVERSATION_COMMAND_NAMES = ["talk", "voice", "conversation"];
487
493
  const REMOTE_WEBUI_CONTROLS_STATUS_KEY = "pi-remote-webui:controls";
488
494
  const REMOTE_WEBUI_CONTROLS_PAYLOAD_TYPE = "firstpick.pi-package-remote-webui.controls";
489
495
  const REMOTE_WEBUI_CONTROLS_PAYLOAD_VERSION = 1;
@@ -496,6 +502,7 @@ const WORKFLOW_WIDGET_PAYLOAD_PREFIX = "WORKFLOW_WEBUI_PAYLOAD ";
496
502
  const WORKFLOW_SUBPROCESS_PAYLOAD_TYPE = "firstpick.pi-extension-workflows.subprocess";
497
503
  const WORKFLOW_SUBPROCESS_PAYLOAD_VERSION = 1;
498
504
  const GIT_CHANGES_RENDER_ROW_LIMIT = 4000;
505
+ const GIT_PULL_RESULT_FILE_LIMIT = 48;
499
506
  const LAST_USER_PROMPT_STORAGE_KEY = "pi-webui-last-user-prompts";
500
507
  const PROMPT_HISTORY_STORAGE_KEY = "pi-webui-prompt-history";
501
508
  const PROMPT_LIST_STORAGE_KEY = "pi-webui-prompt-lists";
@@ -567,6 +574,7 @@ const todoProgressGoalByTab = new Map();
567
574
  const todoProgressSignatureByTab = new Map();
568
575
  const releaseNpmOutputExpandedByTab = new Map();
569
576
  const appRunnerDataByTab = new Map();
577
+ const conversationModeByTab = new Map();
570
578
  const appRunnerInputDraftByRun = new Map();
571
579
  const appRunnerContextLineDraftByRun = new Map();
572
580
  const liveToolRuns = new Map();
@@ -589,6 +597,7 @@ const optionalFeatureAvailability = {
589
597
  todoProgressWidget: false,
590
598
  tuiToolsCommand: false,
591
599
  remoteWebui: false,
600
+ naturalConversation: false,
592
601
  themeBundle: false,
593
602
  };
594
603
  const APP_RUNNER_CONTEXT_DEFAULT_LINES = 80;
@@ -664,6 +673,13 @@ const OPTIONAL_FEATURES = [
664
673
  capabilityLabel: "/remote",
665
674
  description: "Trusted-LAN QR helper for opening the Web UI from mobile browsers.",
666
675
  },
676
+ {
677
+ id: "naturalConversation",
678
+ label: "Natural Conversation",
679
+ packageName: "@firstpick/pi-package-natural-conversation",
680
+ capabilityLabel: "/talk, /voice, or /conversation",
681
+ description: "Per-tab conversation-mode shell that delegates safety constraints to the standalone package and reserves WebUI audio for later phases.",
682
+ },
667
683
  {
668
684
  id: "gitFooterStatus",
669
685
  label: "Git footer status",
@@ -702,6 +718,9 @@ const OPTIONAL_COMMAND_FEATURES = new Map([
702
718
  ["skills", "tuiSkillsCommand"],
703
719
  ["tools", "tuiToolsCommand"],
704
720
  ["remote", "remoteWebui"],
721
+ ["talk", "naturalConversation"],
722
+ ["voice", "naturalConversation"],
723
+ ["conversation", "naturalConversation"],
705
724
  ["stats", "statsCommand"],
706
725
  ["git-footer-refresh", "gitFooterStatus"],
707
726
  ["todo-progress-status", "todoProgressWidget"],
@@ -733,6 +752,7 @@ const optionalFeatureInstallInProgress = new Set();
733
752
  const optionalFeaturePackageStatuses = new Map();
734
753
  const optionalFeatureInstallMessages = new Map();
735
754
  const gitFooterPayloadRefreshInFlightByTab = new Set();
755
+ const gitFooterSyncPushInFlightByTab = new Set();
736
756
  const gitFooterPiCalibrationInFlightByTab = new Set();
737
757
 
738
758
  function createGitWorkflowActionsDone(patch = {}) {
@@ -2160,7 +2180,7 @@ function isUserBashRunningOrQueued(tabId = activeTabId) {
2160
2180
  }
2161
2181
 
2162
2182
  function isRunActive() {
2163
- return !!currentState?.isStreaming || isUserBashRunningOrQueued() || (runIndicatorLocallyActive && !currentState?.isCompacting);
2183
+ return !!currentState?.isStreaming || !!currentState?.isCompacting || isUserBashRunningOrQueued() || runIndicatorLocallyActive;
2164
2184
  }
2165
2185
 
2166
2186
  function isAbortAvailable() {
@@ -4031,6 +4051,156 @@ function isOptionalFeatureEnabled(featureId) {
4031
4051
  return isOptionalFeatureDetected(featureId) && !isOptionalFeatureDisabled(featureId);
4032
4052
  }
4033
4053
 
4054
+ function defaultConversationModeState(patch = {}) {
4055
+ return {
4056
+ featureId: "naturalConversation",
4057
+ available: false,
4058
+ enabled: false,
4059
+ uiState: "off",
4060
+ statusText: "",
4061
+ allowedTools: ["read", "grep", "find", "ls"],
4062
+ provider: "browser-shell",
4063
+ startedAt: null,
4064
+ packageInstalled: false,
4065
+ loadedCommands: [],
4066
+ updatedAt: "",
4067
+ ...patch,
4068
+ };
4069
+ }
4070
+
4071
+ function normalizeConversationModeState(value = {}) {
4072
+ const source = value && typeof value === "object" ? value : {};
4073
+ const enabled = source.enabled === true;
4074
+ return defaultConversationModeState({
4075
+ ...source,
4076
+ available: source.available === true,
4077
+ enabled,
4078
+ uiState: enabled ? cleanStatusText(source.uiState || "listening").toLowerCase() || "listening" : "off",
4079
+ statusText: cleanStatusText(source.statusText || ""),
4080
+ allowedTools: Array.isArray(source.allowedTools) && source.allowedTools.length ? source.allowedTools.map((name) => String(name)).filter(Boolean) : ["read", "grep", "find", "ls"],
4081
+ packageInstalled: source.packageInstalled === true,
4082
+ loadedCommands: Array.isArray(source.loadedCommands) ? source.loadedCommands.map((name) => String(name)).filter(Boolean) : [],
4083
+ });
4084
+ }
4085
+
4086
+ function updateConversationModeForTab(tabId = activeTabId, mode = {}, { render = true } = {}) {
4087
+ if (!tabId) return normalizeConversationModeState(mode);
4088
+ const previous = conversationModeByTab.get(tabId) || tabs.find((tab) => tab.id === tabId)?.conversationMode || {};
4089
+ const next = normalizeConversationModeState({ ...previous, ...mode });
4090
+ conversationModeByTab.set(tabId, next);
4091
+ if (tabId === activeTabId && render) renderConversationModeControls();
4092
+ return next;
4093
+ }
4094
+
4095
+ function activeConversationMode() {
4096
+ return normalizeConversationModeState(conversationModeByTab.get(activeTabId) || activeTab()?.conversationMode || {});
4097
+ }
4098
+
4099
+ function conversationModeCommandName() {
4100
+ for (const name of NATURAL_CONVERSATION_COMMAND_NAMES) {
4101
+ const resolved = resolveAvailableCommandName(name, { rpcOnly: true });
4102
+ if (resolved) return resolved;
4103
+ }
4104
+ return "";
4105
+ }
4106
+
4107
+ function conversationModeButtonLabel(mode = activeConversationMode()) {
4108
+ return mode.enabled ? "End Conversation" : "Start Conversation";
4109
+ }
4110
+
4111
+ function conversationModeDisplayText(mode = activeConversationMode()) {
4112
+ return mode.enabled ? `Voice: ${mode.uiState || "listening"}` : "Voice: off";
4113
+ }
4114
+
4115
+ function conversationModeUnavailableText() {
4116
+ return optionalFeatureUnavailableMessage("naturalConversation");
4117
+ }
4118
+
4119
+ function renderConversationModeControls() {
4120
+ const mode = activeConversationMode();
4121
+ const commandName = conversationModeCommandName();
4122
+ const commandAvailable = !!commandName && isOptionalFeatureEnabled("naturalConversation");
4123
+ const active = mode.enabled === true;
4124
+ document.body.classList.toggle("conversation-mode-active", active);
4125
+ elements.composer?.classList.toggle("conversation-mode-active", active);
4126
+
4127
+ if (elements.optionsConversationModeButton) {
4128
+ elements.optionsConversationModeButton.hidden = !commandAvailable && !active;
4129
+ elements.optionsConversationModeButton.disabled = !commandName;
4130
+ elements.optionsConversationModeButton.classList.toggle("active", active);
4131
+ elements.optionsConversationModeButton.querySelector("span").textContent = conversationModeButtonLabel(mode);
4132
+ const tooltip = commandName
4133
+ ? `${active ? "End" : "Start"} Natural Conversation Mode for this Pi tab via /${commandName}. Safety is owned by @firstpick/pi-package-natural-conversation.`
4134
+ : conversationModeUnavailableText();
4135
+ elements.optionsConversationModeButton.title = tooltip;
4136
+ elements.optionsConversationModeButton.setAttribute("data-tooltip", tooltip);
4137
+ elements.optionsConversationModeButton.setAttribute("aria-pressed", active ? "true" : "false");
4138
+ }
4139
+
4140
+ if (elements.conversationModeChip) {
4141
+ elements.conversationModeChip.hidden = !active;
4142
+ elements.conversationModeChip.textContent = conversationModeDisplayText(mode);
4143
+ elements.conversationModeChip.title = `Natural Conversation Mode is active in this tab. Thinking is forced off; tools are limited to ${mode.allowedTools.join(", ")}.`;
4144
+ }
4145
+
4146
+ if (elements.conversationModeEndButton) {
4147
+ elements.conversationModeEndButton.hidden = !active;
4148
+ elements.conversationModeEndButton.disabled = !commandName;
4149
+ elements.conversationModeEndButton.title = commandName ? `End Natural Conversation Mode with /${commandName} off.` : conversationModeUnavailableText();
4150
+ }
4151
+ }
4152
+
4153
+ function handleNaturalConversationStatus(statusText, tabId = activeTabId) {
4154
+ const text = cleanStatusText(statusText || "");
4155
+ const match = text.match(/voice\s*:\s*([a-z0-9_-]+)/i);
4156
+ updateConversationModeForTab(tabId, {
4157
+ available: true,
4158
+ enabled: !!text,
4159
+ uiState: text ? (match?.[1] || "listening").toLowerCase() : "off",
4160
+ statusText: text,
4161
+ loadedCommands: NATURAL_CONVERSATION_COMMAND_NAMES.filter((name) => hasLoadedRpcCommand(name)),
4162
+ });
4163
+ }
4164
+
4165
+ async function refreshNaturalConversationMode(tabContext = activeTabContext()) {
4166
+ if (!tabContext.tabId) return;
4167
+ try {
4168
+ const response = await api("/api/conversation-mode", { tabId: tabContext.tabId });
4169
+ if (!isCurrentTabContext(tabContext)) return;
4170
+ updateConversationModeForTab(tabContext.tabId, response.data?.mode || {}, { render: true });
4171
+ if (response.data?.available) optionalFeatureAvailability.naturalConversation = true;
4172
+ } catch (error) {
4173
+ if (isCurrentTabContext(tabContext)) addEvent(`natural conversation status check failed: ${error.message || String(error)}`, "warn");
4174
+ }
4175
+ }
4176
+
4177
+ async function setNaturalConversationModeEnabled(enabled) {
4178
+ const tabContext = activeTabContext();
4179
+ if (!tabContext.tabId) return;
4180
+ const commandName = conversationModeCommandName();
4181
+ if (!commandName) {
4182
+ addEvent(conversationModeUnavailableText(), "warn");
4183
+ await Promise.allSettled([refreshCommands(tabContext), refreshOptionalFeaturePackageStatuses()]);
4184
+ return;
4185
+ }
4186
+ try {
4187
+ const response = await api("/api/conversation-mode", { method: "POST", body: { enabled: enabled === true }, tabId: tabContext.tabId });
4188
+ applyResponseTab(response);
4189
+ if (!isCurrentTabContext(tabContext)) return;
4190
+ updateConversationModeForTab(tabContext.tabId, response.data?.mode || {}, { render: true });
4191
+ addEvent(enabled ? "Natural Conversation Mode started." : "Natural Conversation Mode ended.", "info");
4192
+ if (enabled) addTransientMessage({ role: "native", title: "/talk", content: "Natural Conversation Mode is active. Thinking is off; write/shell workflows are blocked by the package safety controller.", level: "info" });
4193
+ await Promise.allSettled([refreshState(tabContext), refreshCommands(tabContext)]);
4194
+ } catch (error) {
4195
+ if (isCurrentTabContext(tabContext)) addEvent(error.message || String(error), "error");
4196
+ }
4197
+ }
4198
+
4199
+ function toggleNaturalConversationMode() {
4200
+ const mode = activeConversationMode();
4201
+ return setNaturalConversationModeEnabled(!mode.enabled);
4202
+ }
4203
+
4034
4204
  function renderOptionalFeatureDependentDisplays() {
4035
4205
  renderOptionalFeatureControls();
4036
4206
  renderThemeSelect();
@@ -4070,6 +4240,10 @@ function setOptionalFeatureDisabled(featureId, disabled) {
4070
4240
  statusEntries.delete("pi-remote-webui");
4071
4241
  widgets.delete("pi-remote-webui");
4072
4242
  }
4243
+ if (featureId === "naturalConversation" && disabled && !activeConversationMode().enabled) {
4244
+ statusEntries.delete(NATURAL_CONVERSATION_STATUS_KEY);
4245
+ updateConversationModeForTab(activeTabId, { available: false, enabled: false, uiState: "off", statusText: "" }, { render: false });
4246
+ }
4073
4247
  storeDisabledOptionalFeatures();
4074
4248
  renderOptionalFeatureDependentDisplays();
4075
4249
  const tabContext = activeTabContext();
@@ -4500,6 +4674,7 @@ function syncTabMetadata(nextTabs = []) {
4500
4674
  liveIds.add(tab.id);
4501
4675
  setTabActivity(tab.id, tab.activity);
4502
4676
  if (Object.prototype.hasOwnProperty.call(tab, "appRunner")) setAppRunnerData(tab.id, { activeRun: tab.appRunner });
4677
+ if (Object.prototype.hasOwnProperty.call(tab, "conversationMode")) updateConversationModeForTab(tab.id, tab.conversationMode, { render: false });
4503
4678
  }
4504
4679
  for (const tabId of tabActivities.keys()) {
4505
4680
  if (!liveIds.has(tabId)) {
@@ -4512,6 +4687,7 @@ function syncTabMetadata(nextTabs = []) {
4512
4687
  tabMessagesCache.delete(tabId);
4513
4688
  widgetsByTab.delete(tabId);
4514
4689
  appRunnerDataByTab.delete(tabId);
4690
+ conversationModeByTab.delete(tabId);
4515
4691
  clearGitWorkflowForTab(tabId);
4516
4692
  }
4517
4693
  }
@@ -4527,6 +4703,8 @@ function applyTabMetadata(tab) {
4527
4703
  if (index === -1) tabs.push(tab);
4528
4704
  else tabs[index] = { ...tabs[index], ...tab };
4529
4705
  if (tab.activity) setTabActivity(tab.id, tab.activity);
4706
+ if (Object.prototype.hasOwnProperty.call(tab, "conversationMode")) updateConversationModeForTab(tab.id, tab.conversationMode, { render: false });
4707
+ renderConversationModeControls();
4530
4708
  renderTabs();
4531
4709
  return true;
4532
4710
  }
@@ -5033,17 +5211,34 @@ function terminalAppRunnerTooltip(run) {
5033
5211
  return appRunnerIsRunning(run) ? ` · ${terminalAppRunnerLabel(run)}` : "";
5034
5212
  }
5035
5213
 
5214
+ function tabConversationMode(tab) {
5215
+ if (!tab?.id) return normalizeConversationModeState(tab?.conversationMode || {});
5216
+ return normalizeConversationModeState(conversationModeByTab.get(tab.id) || tab.conversationMode || {});
5217
+ }
5218
+
5219
+ function tabConversationModeActive(tab) {
5220
+ return tabConversationMode(tab).enabled === true;
5221
+ }
5222
+
5223
+ function terminalConversationModeTooltip(tab) {
5224
+ const mode = tabConversationMode(tab);
5225
+ return mode.enabled ? ` · natural conversation: ${mode.uiState || "listening"}` : "";
5226
+ }
5227
+
5036
5228
  function terminalTabMeta(tab, indicator) {
5037
- const meta = tab.running ? `${indicator.meta} · pid ${tab.pid || "…"}` : "stopped";
5038
- return tabAppRunnerRunningRun(tab) ? `${meta} · app runner` : meta;
5229
+ const parts = [tab.running ? `${indicator.meta} · pid ${tab.pid || "…"}` : "stopped"];
5230
+ if (tabAppRunnerRunningRun(tab)) parts.push("app runner");
5231
+ if (tabConversationModeActive(tab)) parts.push("voice");
5232
+ return parts.join(" · ");
5039
5233
  }
5040
5234
 
5041
- function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null }) {
5235
+ function appendTerminalTabContent(button, { title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false }) {
5042
5236
  const titleRow = make("span", "terminal-tab-title-row");
5043
5237
  const indicatorDot = make("span", "terminal-tab-activity-indicator");
5044
5238
  indicatorDot.setAttribute("aria-hidden", "true");
5045
5239
  titleRow.append(indicatorDot, make("span", "terminal-tab-title", title));
5046
5240
  if (appRunnerIsRunning(appRunnerRun)) titleRow.append(make("span", "terminal-tab-app-runner-indicator", "app"));
5241
+ if (conversationModeActive) titleRow.append(make("span", "terminal-tab-conversation-indicator", "voice"));
5047
5242
  if (count !== null) titleRow.append(make("span", "terminal-tab-group-count", String(count)));
5048
5243
  button.append(titleRow, make("span", "terminal-tab-meta", meta));
5049
5244
  }
@@ -5053,7 +5248,9 @@ function renderTerminalTab(tab) {
5053
5248
  const indicator = tabIndicator(tab);
5054
5249
  const appRunnerRun = tabAppRunnerRunningRun(tab);
5055
5250
  const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
5056
- const wrapper = make("div", `terminal-tab activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}`);
5251
+ const conversationModeActive = tabConversationModeActive(tab);
5252
+ const conversationLabel = conversationModeActive ? `, natural conversation ${tabConversationMode(tab).uiState || "listening"}` : "";
5253
+ const wrapper = make("div", `terminal-tab activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}${conversationModeActive ? " conversation-mode-running" : ""}`);
5057
5254
  wrapper.dataset.tabId = tab.id;
5058
5255
  bindTerminalTabDragAndDrop(wrapper, { sourceTabId: tab.id, target: { type: "tab", tabId: tab.id } });
5059
5256
  const button = make("button", "terminal-tab-button");
@@ -5061,10 +5258,10 @@ function renderTerminalTab(tab) {
5061
5258
  button.draggable = false;
5062
5259
  button.setAttribute("role", "tab");
5063
5260
  button.setAttribute("aria-selected", isActive ? "true" : "false");
5064
- button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}`);
5065
- const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)} · drag onto another tab or group to group`;
5261
+ button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}${conversationLabel}`);
5262
+ const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)}${terminalConversationModeTooltip(tab)} · drag onto another tab or group to group`;
5066
5263
  applyStyledTooltip(button, tooltip, { ariaLabel: false });
5067
- appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun });
5264
+ appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive });
5068
5265
  button.addEventListener("click", () => switchTab(tab.id));
5069
5266
  wrapper.append(button);
5070
5267
 
@@ -5089,7 +5286,9 @@ function renderTerminalTabGroupItem(tab, group) {
5089
5286
  const indicator = tabIndicator(tab);
5090
5287
  const appRunnerRun = tabAppRunnerRunningRun(tab);
5091
5288
  const appRunnerLabel = appRunnerRun ? terminalAppRunnerLabel(appRunnerRun) : "";
5092
- const item = make("div", `terminal-tab-group-item activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}`);
5289
+ const conversationModeActive = tabConversationModeActive(tab);
5290
+ const conversationLabel = conversationModeActive ? `, natural conversation ${tabConversationMode(tab).uiState || "listening"}` : "";
5291
+ const item = make("div", `terminal-tab-group-item activity-${indicator.state}${isActive ? " active" : ""}${tab.running ? "" : " stopped"}${appRunnerRun ? " app-runner-running" : ""}${conversationModeActive ? " conversation-mode-running" : ""}`);
5093
5292
  item.dataset.tabId = tab.id;
5094
5293
  bindTerminalTabDragAndDrop(item, { sourceTabId: tab.id, target: group?.custom ? { type: "group", group } : { type: "tab", tabId: tab.id } });
5095
5294
  const button = make("button", "terminal-tab-button terminal-tab-group-item-button");
@@ -5097,10 +5296,10 @@ function renderTerminalTabGroupItem(tab, group) {
5097
5296
  button.draggable = false;
5098
5297
  button.setAttribute("role", "tab");
5099
5298
  button.setAttribute("aria-selected", isActive ? "true" : "false");
5100
- button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}`);
5101
- const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)} · drag onto another tab or group to group`;
5299
+ button.setAttribute("aria-label", `${tab.title}: ${indicator.label}${appRunnerLabel ? `, ${appRunnerLabel}` : ""}${conversationLabel}`);
5300
+ const tooltip = `${tab.title} · ${indicator.label}${tab.running ? ` · pid ${tab.pid || "starting"}` : " · stopped"}${terminalAppRunnerTooltip(appRunnerRun)}${terminalConversationModeTooltip(tab)} · drag onto another tab or group to group`;
5102
5301
  applyStyledTooltip(button, tooltip, { ariaLabel: false });
5103
- appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun });
5302
+ appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive });
5104
5303
  button.addEventListener("click", (event) => {
5105
5304
  event.stopPropagation();
5106
5305
  switchTab(tab.id);
@@ -6422,6 +6621,10 @@ function footerMeta(label, value, className = "", options = {}) {
6422
6621
  node.addEventListener("click", options.onClick);
6423
6622
  if (options.ariaPressed !== undefined) node.setAttribute("aria-pressed", options.ariaPressed ? "true" : "false");
6424
6623
  if (options.ariaBusy) node.setAttribute("aria-busy", "true");
6624
+ if (options.disabled) {
6625
+ node.disabled = true;
6626
+ node.setAttribute("aria-disabled", "true");
6627
+ }
6425
6628
  }
6426
6629
  node.append(make("span", "footer-meta-label", label), make("span", "footer-meta-value", value));
6427
6630
  return applyFooterTooltip(node, options.title || `${label}: ${value}`, { align: options.tooltipAlign });
@@ -6460,7 +6663,7 @@ const GIT_FOOTER_TOOLTIP_COPY = {
6460
6663
  cwd: "Active working directory for this Web UI tab.",
6461
6664
  git: "Current Git branch. detached means HEAD is not on a branch; no repo means the cwd is outside a Git work tree.",
6462
6665
  "git-state": "Active Git operation or detached state. Finish or abort rebase/merge/cherry-pick/revert/bisect before normal commits.",
6463
- sync: "Remote tracking divergence. ↑ means local commits ahead; ↓ means remote commits to pull.",
6666
+ sync: "Remote tracking divergence. ↑ means local commits ahead; ↓ means remote commits to pull. Click when ↑ appears to run git push for this tab.",
6464
6667
  changes: "Working tree and fetched remote summary. 🟢 staged, ✏️ modified unstaged, ➕ untracked, ⚠️ conflicted; ⬇️ means fetched remote commits to pull; 🔄/✓/⚠️ fetch shows the tab git fetch state; ✅ means no changes.",
6465
6668
  "git-extra": "Extra Git signals. 📦 stash, 🧩 dirty submodules, 🌳 worktrees, 🏷️ tag at HEAD, 🕒 last commit age, 🔓 signing mismatch.",
6466
6669
  worktree: "Git worktree checkout for this tab. Use branch worktrees to work on branches in parallel without switching this checkout.",
@@ -6801,6 +7004,43 @@ function renderGitFooterPayloadMetric(chip) {
6801
7004
  return chip.contextUsage ? applyFooterContextUsage(node, chip.contextUsage) : node;
6802
7005
  }
6803
7006
 
7007
+ function gitFooterSyncOutgoingCount(value) {
7008
+ const match = String(value || "").match(/[↑⇡]\s*(\d+)/u);
7009
+ return match ? Number.parseInt(match[1] || "0", 10) || 0 : 0;
7010
+ }
7011
+
7012
+ function gitFooterSyncChipHasOutgoing(chip) {
7013
+ return chip?.key === "sync" && gitFooterSyncOutgoingCount(chip.value) > 0;
7014
+ }
7015
+
7016
+ async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
7017
+ if (!tabId || gitFooterSyncPushInFlightByTab.has(tabId)) return;
7018
+ const outgoing = gitFooterSyncOutgoingCount(syncValue);
7019
+ if (outgoing <= 0) return;
7020
+ const tabContext = activeTabContext(tabId);
7021
+ const tab = tabs.find((item) => item.id === tabId);
7022
+ const target = tab?.title || tab?.cwd || "this tab";
7023
+ hideFooterTooltip();
7024
+ if (!window.confirm(`Run git push for ${outgoing} outgoing commit${outgoing === 1 ? "" : "s"} in ${target}?`)) return;
7025
+
7026
+ gitFooterSyncPushInFlightByTab.add(tabId);
7027
+ if (isCurrentTabContext(tabContext)) renderFooter();
7028
+ try {
7029
+ const response = await api("/api/git-workflow/push", { method: "POST", body: {}, tabId });
7030
+ if (!response.ok) {
7031
+ const detail = [response.error, formatGitCommandResult(response.data)].filter(Boolean).join("\n\n").trim();
7032
+ throw new Error(detail || "git push failed");
7033
+ }
7034
+ addEvent(`Pushed ${outgoing} outgoing commit${outgoing === 1 ? "" : "s"}.`, "success");
7035
+ requestGitFooterWebuiPayload(tabContext, { force: true });
7036
+ } catch (error) {
7037
+ addEvent(error.message || String(error), "error");
7038
+ } finally {
7039
+ gitFooterSyncPushInFlightByTab.delete(tabId);
7040
+ if (isCurrentTabContext(tabContext)) renderFooter();
7041
+ }
7042
+ }
7043
+
6804
7044
  function renderGitFooterPayloadMeta(chip, tab) {
6805
7045
  const options = {};
6806
7046
  let action = "";
@@ -6816,6 +7056,13 @@ function renderGitFooterPayloadMeta(chip, tab) {
6816
7056
  } else if (chip.key === "worktree") {
6817
7057
  options.onClick = () => setFooterBranchPickerOpen(!footerBranchPickerOpen);
6818
7058
  action = "Click to manage branch worktrees for this repository.";
7059
+ } else if (chip.key === "sync" && gitFooterSyncChipHasOutgoing(chip)) {
7060
+ const tabId = tab?.id || activeTabId;
7061
+ const inFlight = tabId ? gitFooterSyncPushInFlightByTab.has(tabId) : false;
7062
+ options.onClick = () => pushGitFooterSync(tabId, chip.value);
7063
+ options.ariaBusy = inFlight;
7064
+ options.disabled = inFlight;
7065
+ action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
6819
7066
  } else if (chip.key === "changes") {
6820
7067
  options.onClick = openGitChangesDialog;
6821
7068
  action = "Click to view the current git diff.";
@@ -6857,8 +7104,9 @@ function gitFooterChipShapeKey(chip) {
6857
7104
  function gitFooterPickerStateKey() {
6858
7105
  const tabContext = activeTabContext();
6859
7106
  const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
7107
+ const syncPushInFlight = tabContext.tabId ? gitFooterSyncPushInFlightByTab.has(tabContext.tabId) : false;
6860
7108
  const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
6861
- return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}`;
7109
+ return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncPushInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}`;
6862
7110
  }
6863
7111
 
6864
7112
  function updateGitFooterChipNodeValue(node, chip, valueSelector) {
@@ -7363,9 +7611,148 @@ function gitChangesGeneratedLabel(data) {
7363
7611
  return `Updated ${new Date(timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" })}`;
7364
7612
  }
7365
7613
 
7614
+ function gitPullOutputLines(result = {}) {
7615
+ return [result.stdout, result.stderr]
7616
+ .map((value) => stripAnsi(value || "").trim())
7617
+ .filter(Boolean)
7618
+ .join("\n")
7619
+ .split(/\r?\n/)
7620
+ .map((line) => line.trimEnd())
7621
+ .filter((line) => line.trim());
7622
+ }
7623
+
7624
+ function parseGitPullSummaryLine(line) {
7625
+ const text = String(line || "").trim();
7626
+ if (!/\bfiles? changed\b|\binsertions?\(\+\)|\bdeletions?\(-\)/.test(text)) return null;
7627
+ const numberFrom = (regex) => {
7628
+ const match = text.match(regex);
7629
+ return match ? Number.parseInt(String(match[1] || "0").replace(/,/g, ""), 10) || 0 : 0;
7630
+ };
7631
+ return {
7632
+ summaryLine: text,
7633
+ totalFiles: numberFrom(/([\d,]+)\s+files? changed/),
7634
+ insertions: numberFrom(/([\d,]+)\s+insertions?\(\+\)/),
7635
+ deletions: numberFrom(/([\d,]+)\s+deletions?\(-\)/),
7636
+ };
7637
+ }
7638
+
7639
+ function parseGitPullFileStatLine(line) {
7640
+ const match = String(line || "").match(/^(.+?)\s+\|\s+(.+)$/);
7641
+ if (!match) return null;
7642
+ const path = match[1].trim();
7643
+ const stats = match[2].trim();
7644
+ if (!path || !stats) return null;
7645
+ const tone = stats.includes("-") && !stats.includes("+") ? "danger" : stats.includes("+") ? "success" : "muted";
7646
+ return { path, stats, tone };
7647
+ }
7648
+
7649
+ function normalizeGitPullResult(result = {}) {
7650
+ const outputLines = gitPullOutputLines(result);
7651
+ const changedFiles = [];
7652
+ const modeLines = [];
7653
+ let updateRange = "";
7654
+ let strategy = "";
7655
+ let summary = null;
7656
+ let alreadyUpToDate = false;
7657
+
7658
+ for (const line of outputLines) {
7659
+ const text = line.trim();
7660
+ const rangeMatch = text.match(/^Updating\s+([0-9a-f]+)\.\.([0-9a-f]+)/i);
7661
+ if (!updateRange && rangeMatch) updateRange = `${rangeMatch[1]}…${rangeMatch[2]}`;
7662
+ if (!strategy && (/^Fast-forward$/i.test(text) || /^Merge made by\b/i.test(text))) strategy = text;
7663
+ if (/^Already up to date\.?$/i.test(text)) {
7664
+ alreadyUpToDate = true;
7665
+ strategy = text.replace(/\.?$/, ".");
7666
+ }
7667
+ const summaryLine = parseGitPullSummaryLine(text);
7668
+ if (summaryLine) summary = summaryLine;
7669
+ const stat = parseGitPullFileStatLine(text);
7670
+ if (stat) changedFiles.push(stat);
7671
+ if (/^(create|delete) mode\s+|^(rename|copy) (from|to)\s+/i.test(text)) modeLines.push(text);
7672
+ }
7673
+
7674
+ return {
7675
+ command: result.command || "git pull --ff-only",
7676
+ outputLines,
7677
+ changedFiles,
7678
+ modeLines,
7679
+ updateRange,
7680
+ strategy,
7681
+ alreadyUpToDate,
7682
+ summaryLine: summary?.summaryLine || "",
7683
+ totalFiles: summary?.totalFiles || changedFiles.length || 0,
7684
+ insertions: summary?.insertions || 0,
7685
+ deletions: summary?.deletions || 0,
7686
+ };
7687
+ }
7688
+
7689
+ function gitPullResultStatus(result) {
7690
+ if (!result) return "";
7691
+ if (result.alreadyUpToDate) return "Already up to date.";
7692
+ const totalFiles = Number(result.totalFiles || 0) || 0;
7693
+ const insertions = Number(result.insertions || 0) || 0;
7694
+ const deletions = Number(result.deletions || 0) || 0;
7695
+ if (totalFiles > 0) {
7696
+ const parts = [`${totalFiles.toLocaleString()} file${totalFiles === 1 ? "" : "s"} changed`];
7697
+ if (insertions > 0) parts.push(`+${insertions.toLocaleString()}`);
7698
+ if (deletions > 0) parts.push(`−${deletions.toLocaleString()}`);
7699
+ return `Pulled remote changes: ${parts.join(" · ")}.`;
7700
+ }
7701
+ if (result.summaryLine) return `Pulled remote changes: ${result.summaryLine}.`;
7702
+ if (result.strategy) return `Pulled remote changes (${result.strategy}).`;
7703
+ return "Pulled remote changes successfully.";
7704
+ }
7705
+
7706
+ function renderGitPullResultPanel(result) {
7707
+ if (!result) return null;
7708
+ const panel = make("section", "git-pull-result-panel");
7709
+ const header = make("div", "git-pull-result-header");
7710
+ const copy = make("div", "git-pull-result-copy");
7711
+ copy.append(
7712
+ make("span", "git-pull-result-kicker", "Pull result"),
7713
+ make("strong", undefined, gitPullResultStatus(result)),
7714
+ make("span", "git-pull-result-meta", [result.updateRange, result.strategy, result.command].filter(Boolean).join(" · ")),
7715
+ );
7716
+ header.append(copy);
7717
+ panel.append(header);
7718
+
7719
+ const metrics = make("div", "git-pull-result-metrics");
7720
+ metrics.append(
7721
+ gitChangesChip("changed", result.totalFiles || result.changedFiles.length || 0, (result.totalFiles || result.changedFiles.length) ? "warning" : "muted"),
7722
+ gitChangesChip("insertions", result.insertions > 0 ? `+${result.insertions.toLocaleString()}` : 0, result.insertions > 0 ? "success" : "muted"),
7723
+ gitChangesChip("deletions", result.deletions > 0 ? `−${result.deletions.toLocaleString()}` : 0, result.deletions > 0 ? "danger" : "muted"),
7724
+ gitChangesChip("mode ops", result.modeLines.length || 0, result.modeLines.length ? "warning" : "muted"),
7725
+ );
7726
+ panel.append(metrics);
7727
+
7728
+ if (result.changedFiles.length) {
7729
+ const list = make("div", "git-pull-file-list");
7730
+ list.append(make("span", "git-pull-file-list-label", `${result.changedFiles.length} pulled file${result.changedFiles.length === 1 ? "" : "s"}`));
7731
+ for (const file of result.changedFiles.slice(0, GIT_PULL_RESULT_FILE_LIMIT)) {
7732
+ const row = make("div", `git-pull-file ${file.tone || ""}`.trim());
7733
+ row.append(make("span", "git-pull-file-path", file.path), make("span", "git-pull-file-stats", file.stats));
7734
+ list.append(row);
7735
+ }
7736
+ const remaining = result.changedFiles.length - GIT_PULL_RESULT_FILE_LIMIT;
7737
+ if (remaining > 0) list.append(make("div", "git-pull-result-more", `${remaining} more file${remaining === 1 ? "" : "s"}; expand command output for the full git stat.`));
7738
+ panel.append(list);
7739
+ }
7740
+
7741
+ if (result.modeLines.length) {
7742
+ const details = make("details", "git-pull-output-details git-pull-mode-details");
7743
+ details.append(make("summary", undefined, `Mode changes (${result.modeLines.length})`), make("pre", undefined, result.modeLines.join("\n")));
7744
+ panel.append(details);
7745
+ }
7746
+
7747
+ const details = make("details", "git-pull-output-details");
7748
+ details.append(make("summary", undefined, "Command output"), make("pre", undefined, result.outputLines.join("\n") || "No command output."));
7749
+ panel.append(details);
7750
+ return panel;
7751
+ }
7752
+
7366
7753
  function renderGitChangesDialog() {
7367
7754
  if (!elements.gitChangesDialog || !elements.gitChangesBody) return;
7368
- const { loading, pulling, error, message, data } = gitChangesState;
7755
+ const { loading, pulling, error, message, pullResult, data } = gitChangesState;
7369
7756
  const behind = Number(data?.remote?.behind ?? data?.summary?.behind ?? 0) || 0;
7370
7757
  const canPull = behind > 0 && data?.remote?.canPull !== false;
7371
7758
  const remoteNotice = !error && data?.remote?.error ? `Incoming diff unavailable: ${data.remote.error}` : "";
@@ -7405,6 +7792,7 @@ function renderGitChangesDialog() {
7405
7792
  return;
7406
7793
  }
7407
7794
 
7795
+ if (pullResult) body.append(renderGitPullResultPanel(pullResult));
7408
7796
  body.append(renderGitChangesOverview(data));
7409
7797
  const parsedSections = (Array.isArray(data.sections) ? data.sections : [])
7410
7798
  .map((section) => ({ section, files: parseGitUnifiedDiff(section.diff || "") }))
@@ -7428,13 +7816,13 @@ function renderGitChangesDialog() {
7428
7816
  async function loadGitChangesDialog(tabContext = activeTabContext()) {
7429
7817
  const requestSerial = ++gitChangesRequestSerial;
7430
7818
  gitChangesUntrackedContentRequests.clear();
7431
- gitChangesState = { ...gitChangesState, loading: true, error: "", message: "", tabId: tabContext.tabId || activeTabId };
7819
+ gitChangesState = { ...gitChangesState, loading: true, error: "", message: "", pullResult: null, tabId: tabContext.tabId || activeTabId };
7432
7820
  renderGitChangesDialog();
7433
7821
  try {
7434
7822
  const response = await api("/api/git-changes", { tabId: tabContext.tabId });
7435
7823
  if (requestSerial !== gitChangesRequestSerial) return;
7436
7824
  if (!response.ok) throw new Error(response.error || "Failed to load git changes");
7437
- gitChangesState = { loading: false, pulling: false, error: "", message: "", data: response.data || null, tabId: tabContext.tabId || activeTabId };
7825
+ gitChangesState = { loading: false, pulling: false, error: "", message: "", pullResult: null, data: response.data || null, tabId: tabContext.tabId || activeTabId };
7438
7826
  } catch (error) {
7439
7827
  if (requestSerial !== gitChangesRequestSerial) return;
7440
7828
  gitChangesState = { ...gitChangesState, loading: false, error: error.message || String(error) };
@@ -7447,7 +7835,7 @@ function openGitChangesDialog() {
7447
7835
  hideFooterTooltip();
7448
7836
  const tabContext = activeTabContext();
7449
7837
  const tabId = tabContext.tabId || activeTabId;
7450
- gitChangesState = { loading: true, pulling: false, error: "", message: "", data: gitChangesState.tabId === tabId ? gitChangesState.data : null, tabId };
7838
+ gitChangesState = { loading: true, pulling: false, error: "", message: "", pullResult: null, data: gitChangesState.tabId === tabId ? gitChangesState.data : null, tabId };
7451
7839
  renderGitChangesDialog();
7452
7840
  if (!elements.gitChangesDialog.open) elements.gitChangesDialog.showModal();
7453
7841
  loadGitChangesDialog(tabContext).catch((error) => addEvent(error.message || String(error), "error"));
@@ -7466,7 +7854,7 @@ async function pullGitChangesDialog() {
7466
7854
  if (!window.confirm(`Run git pull --ff-only in ${root}?`)) return;
7467
7855
 
7468
7856
  const requestSerial = ++gitChangesRequestSerial;
7469
- gitChangesState = { ...gitChangesState, pulling: true, loading: false, error: "", message: "", tabId: tabContext.tabId };
7857
+ gitChangesState = { ...gitChangesState, pulling: true, loading: false, error: "", message: "", pullResult: null, tabId: tabContext.tabId };
7470
7858
  renderGitChangesDialog();
7471
7859
  try {
7472
7860
  const response = await api("/api/git-changes/pull", { method: "POST", body: {}, tabId: tabContext.tabId });
@@ -7475,12 +7863,13 @@ async function pullGitChangesDialog() {
7475
7863
  const detail = [response.error, response.data?.stderr || response.data?.stdout].filter(Boolean).join("\n").trim();
7476
7864
  throw new Error(detail || "Failed to pull git changes");
7477
7865
  }
7478
- const output = String(response.data?.stdout || response.data?.stderr || "").trim();
7866
+ const pullResult = normalizeGitPullResult(response.data || {});
7479
7867
  gitChangesState = {
7480
7868
  loading: false,
7481
7869
  pulling: false,
7482
7870
  error: "",
7483
- message: output || "Pulled remote changes successfully.",
7871
+ message: gitPullResultStatus(pullResult),
7872
+ pullResult,
7484
7873
  data: response.data?.changes || gitChangesState.data,
7485
7874
  tabId: tabContext.tabId,
7486
7875
  };
@@ -11384,14 +11773,16 @@ function base64UrlEncodeUtf8(value) {
11384
11773
  return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
11385
11774
  }
11386
11775
 
11387
- function btwTransferPayload(payload) {
11776
+ function btwTransferPayload(payload, { transferMode = "full" } = {}) {
11388
11777
  return {
11389
11778
  question: payload?.question || "",
11390
11779
  answer: payload?.answer || payload?.error || "",
11780
+ summary: payload?.summary || "",
11391
11781
  status: payload?.status || "done",
11392
11782
  model: payload?.model || "",
11393
11783
  generatedAt: payload?.generatedAt || 0,
11394
11784
  updatedAt: payload?.updatedAt || Date.now(),
11785
+ transferMode: transferMode === "summary" ? "summary" : "full",
11395
11786
  };
11396
11787
  }
11397
11788
 
@@ -11426,23 +11817,40 @@ function makeBtwTransferIcon() {
11426
11817
  return svg;
11427
11818
  }
11428
11819
 
11429
- async function transferBtwContextToMain(button) {
11820
+ async function transferBtwContextToMain(button, { transferMode = "full" } = {}) {
11430
11821
  const payload = currentBtwWidgetPayload();
11431
- const transferPayload = btwTransferPayload(payload);
11822
+ const normalizedMode = transferMode === "summary" ? "summary" : "full";
11823
+ const transferPayload = btwTransferPayload(payload, { transferMode: normalizedMode });
11432
11824
  if (!transferPayload.question && !transferPayload.answer) return;
11433
11825
  const targetTabId = activeTabId;
11434
11826
  const liveSteer = !!currentState?.isStreaming;
11435
- const original = button?.querySelector("span")?.textContent || "Transfer Context";
11827
+ const label = button?.querySelector(".btw-action-label") || button?.querySelector("span");
11828
+ const original = label?.textContent || button?.textContent || (normalizedMode === "summary" ? "Summarize & Steer" : "Transfer Context");
11436
11829
  const encoded = base64UrlEncodeUtf8(JSON.stringify(transferPayload));
11830
+ if (label) label.textContent = normalizedMode === "summary" ? "Summarizing…" : "Steering…";
11831
+ else if (button) button.textContent = normalizedMode === "summary" ? "Summarizing…" : "Steering…";
11832
+ if (button) button.disabled = true;
11437
11833
  try {
11438
- await sendPrompt("prompt", `/btw-transfer ${encoded}`, { targetTabId, throwOnError: true, streamingBehavior: liveSteer ? "steer" : undefined });
11439
- const label = button?.querySelector("span");
11440
- if (label) label.textContent = liveSteer ? "Steered" : "Transferred";
11441
- addEvent(liveSteer
11442
- ? "/btw context sent as live steering; it will be injected after the next agent action"
11443
- : "/btw context transferred into the main conversation", "info");
11444
- setTimeout(() => { if (label) label.textContent = original; }, 1800);
11834
+ await sendPrompt("prompt", `/btw-transfer ${encoded}`, { targetTabId, throwOnError: true, streamingBehavior: "steer" });
11835
+ const doneLabel = normalizedMode === "summary" ? "Summary Sent" : (liveSteer ? "Steered" : "Transferred");
11836
+ if (label) label.textContent = doneLabel;
11837
+ else if (button) button.textContent = doneLabel;
11838
+ addEvent(normalizedMode === "summary"
11839
+ ? (liveSteer
11840
+ ? "/btw summary sent as live steering; it will be injected after the next agent action"
11841
+ : "/btw summary transferred as steering context")
11842
+ : (liveSteer
11843
+ ? "/btw context sent as live steering; it will be injected after the next agent action"
11844
+ : "/btw context transferred as steering context"), "info");
11845
+ setTimeout(() => {
11846
+ if (label) label.textContent = original;
11847
+ else if (button) button.textContent = original;
11848
+ if (button) button.disabled = false;
11849
+ }, 1800);
11445
11850
  } catch {
11851
+ if (label) label.textContent = original;
11852
+ else if (button) button.textContent = original;
11853
+ if (button) button.disabled = false;
11446
11854
  // sendPrompt already reports the error.
11447
11855
  }
11448
11856
  }
@@ -11509,14 +11917,22 @@ function renderBtwOutputWidget() {
11509
11917
  if (payload?.model) meta.append(make("span", "release-npm-pill", payload.model));
11510
11918
 
11511
11919
  const actions = make("div", "release-npm-actions");
11920
+ const hasTransferContent = !!payload && !!(payload.answer || payload.error || payload.question);
11512
11921
  const transferButton = btwWidgetActionButton("", transferBtwContextToMain, "btw-transfer-action");
11513
11922
  transferButton.title = currentState?.isStreaming
11514
11923
  ? "Transfer this /btw question and answer as live steering after the next agent action"
11515
- : "Transfer this /btw question and answer into the main conversation context";
11516
- transferButton.append(makeBtwTransferIcon(), make("span", undefined, "Transfer Context"));
11517
- transferButton.disabled = !payload || !(payload.answer || payload.error || payload.question);
11924
+ : "Transfer this /btw question and answer as steering context in the main conversation";
11925
+ transferButton.append(makeBtwTransferIcon(), make("span", "btw-action-label", "Transfer Context"));
11926
+ transferButton.disabled = !hasTransferContent;
11927
+ const summaryTransferButton = btwWidgetActionButton("", (button) => transferBtwContextToMain(button, { transferMode: "summary" }), "btw-transfer-action btw-transfer-summary-action");
11928
+ summaryTransferButton.title = currentState?.isStreaming
11929
+ ? "Summarize this /btw side thread, then send the summary as live steering after the next agent action"
11930
+ : "Summarize this /btw side thread, then transfer the summary as steering context";
11931
+ summaryTransferButton.append(makeBtwTransferIcon(), make("span", "btw-action-label", "Summarize & Steer"));
11932
+ summaryTransferButton.disabled = !hasTransferContent;
11518
11933
  actions.append(
11519
11934
  transferButton,
11935
+ summaryTransferButton,
11520
11936
  btwWidgetActionButton("Copy", copyBtwWidgetAnswer),
11521
11937
  btwWidgetActionButton("Close", closeBtwOutputWidget),
11522
11938
  );
@@ -11533,7 +11949,7 @@ function renderBtwOutputWidget() {
11533
11949
 
11534
11950
  const note = payload?.status === "error"
11535
11951
  ? "The side request failed. The main conversation was not changed."
11536
- : "Ephemeral answer · every message in this input is sent as /btw · not appended to the main transcript.";
11952
+ : "Ephemeral answer · use Transfer Context for the full side thread or Summarize & Steer for a concise steering summary.";
11537
11953
  const controls = make("div", "release-npm-controls btw-controls", note);
11538
11954
  const outputDetails = renderReleaseNpmOutputDetails(`btw:${payload?.id || "composer"}`, streamHeader, terminal, controls);
11539
11955
  node.append(header, question, outputDetails, renderBtwComposerForm());
@@ -11693,11 +12109,35 @@ function isLocalWebuiBrowserOrigin() {
11693
12109
  return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
11694
12110
  }
11695
12111
 
12112
+ function remoteWebuiUniqueUrls(values = []) {
12113
+ const urls = [];
12114
+ const seen = new Set();
12115
+ const addUrl = (value) => {
12116
+ if (Array.isArray(value)) {
12117
+ for (const item of value) addUrl(item);
12118
+ return;
12119
+ }
12120
+ const href = remoteWebuiLineUrl(value);
12121
+ if (!href || seen.has(href)) return;
12122
+ seen.add(href);
12123
+ urls.push(href);
12124
+ };
12125
+ addUrl(values);
12126
+ return urls;
12127
+ }
12128
+
12129
+ function remoteWebuiQrUrlsFromData(data = {}) {
12130
+ const network = data.network || latestNetwork || {};
12131
+ const networkUrls = Array.isArray(network.networkUrls) ? network.networkUrls : [];
12132
+ const urls = remoteWebuiUniqueUrls([data.url, networkUrls]);
12133
+ return urls.length ? urls : remoteWebuiUniqueUrls([network.localUrl]);
12134
+ }
12135
+
11696
12136
  function remoteWebuiQrLinesFromData(data = {}) {
11697
12137
  const network = data.network || latestNetwork || {};
11698
12138
  const auth = network.auth || {};
11699
- const networkUrls = Array.isArray(network.networkUrls) ? network.networkUrls : [];
11700
- const displayUrl = data.url || networkUrls.find((candidate) => /^https?:\/\//i.test(String(candidate || ""))) || network.localUrl || "";
12139
+ const urls = remoteWebuiQrUrlsFromData(data);
12140
+ const displayUrl = urls[0] || "";
11701
12141
  const qrLines = Array.isArray(data.qrLines) ? data.qrLines.map((line) => String(line ?? "")) : [];
11702
12142
  const hasAutoAuthQr = !!(auth.enabled && auth.pin && data.qrUrl && displayUrl && data.qrUrl !== displayUrl);
11703
12143
  const authLine = auth.enabled ? `Remote PIN auth: on${auth.pin ? ` · PIN ${auth.pin}` : ""}` : "Remote PIN auth: off";
@@ -11714,6 +12154,7 @@ function remoteWebuiQrLinesFromData(data = {}) {
11714
12154
  ...qrLines,
11715
12155
  "",
11716
12156
  displayUrl,
12157
+ ...urls.slice(1),
11717
12158
  authLine,
11718
12159
  "",
11719
12160
  warningLine,
@@ -11806,11 +12247,12 @@ function openRemoteWebuiQrPopup(lines = []) {
11806
12247
  }
11807
12248
 
11808
12249
  const details = make("div", "remote-qr-details");
11809
- if (url) {
12250
+ const urls = remoteWebuiUniqueUrls([url, cleanLines]);
12251
+ for (const [index, href] of urls.entries()) {
11810
12252
  const urlRow = make("div", "remote-qr-url-row");
11811
- const urlLabel = make("span", "remote-qr-url-label", "URL");
11812
- const link = make("a", "remote-qr-url", url);
11813
- link.href = url;
12253
+ const urlLabel = make("span", "remote-qr-url-label", index === 0 ? "URL" : "LAN");
12254
+ const link = make("a", "remote-qr-url", href);
12255
+ link.href = href;
11814
12256
  link.target = "_blank";
11815
12257
  link.rel = "noopener noreferrer";
11816
12258
  urlRow.append(urlLabel, link);
@@ -11925,9 +12367,15 @@ function formatGitCommandResult(result) {
11925
12367
  return lines.join("\n");
11926
12368
  }
11927
12369
 
12370
+ function gitWorkflowMessagePreviewPath(message, key, fallback) {
12371
+ return normalizeDisplayPath(message?.[`${key}RelativePath`] || message?.[`${key}RepoRelativePath`] || fallback);
12372
+ }
12373
+
11928
12374
  function formatCommitMessagePreview(message) {
11929
12375
  if (!message) return "No commit message loaded yet.";
11930
- return [`=== SHORT ===`, message.short || "(empty)", "", "=== LONG ===", message.long || "(empty)"].join("\n");
12376
+ const shortPath = gitWorkflowMessagePreviewPath(message, "short", "dev/COMMIT/staged-commit-short.txt");
12377
+ const longPath = gitWorkflowMessagePreviewPath(message, "long", "dev/COMMIT/staged-commit-long.txt");
12378
+ return [`=== SHORT (${shortPath}) ===`, message.short || "(empty)", "", `=== LONG (${longPath}) ===`, message.long || "(empty)"].join("\n");
11931
12379
  }
11932
12380
 
11933
12381
  function formatInputCommitMessagePreview(message) {
@@ -16952,6 +17400,7 @@ function updateOptionalFeatureAvailability() {
16952
17400
  optionalFeatureAvailability.todoProgressWidget = hasAvailableCommand("todo-progress-status") || optionalFeatureAvailability.todoProgressWidget || widgets.has("todo-progress");
16953
17401
  optionalFeatureAvailability.tuiToolsCommand = hasLoadedRpcCommand("tools");
16954
17402
  optionalFeatureAvailability.remoteWebui = hasAvailableCommand("remote") || optionalFeatureAvailability.remoteWebui || statusEntries.has("pi-remote-webui") || statusEntries.has(REMOTE_WEBUI_CONTROLS_STATUS_KEY) || widgets.has("pi-remote-webui");
17403
+ optionalFeatureAvailability.naturalConversation = NATURAL_CONVERSATION_COMMAND_NAMES.some((name) => hasAvailableCommand(name)) || optionalFeatureAvailability.naturalConversation || statusEntries.has(NATURAL_CONVERSATION_STATUS_KEY) || activeConversationMode().available;
16955
17404
  optionalFeatureAvailability.themeBundle = availableThemes.length > 0;
16956
17405
  requestGitFooterWebuiPayload();
16957
17406
  renderOptionalFeatureControls();
@@ -17104,6 +17553,12 @@ function renderOptionalFeatureControls() {
17104
17553
  );
17105
17554
  }
17106
17555
 
17556
+ const hasNaturalConversation = isOptionalFeatureEnabled("naturalConversation") || activeConversationMode().enabled;
17557
+ if (elements.optionsConversationModeButton) {
17558
+ elements.optionsConversationModeButton.hidden = !hasNaturalConversation;
17559
+ }
17560
+ renderConversationModeControls();
17561
+
17107
17562
  const hasRemoteWebuiCommand = isOptionalFeatureEnabled("remoteWebui") && hasAvailableCommand("remote");
17108
17563
  if (elements.optionsRemoteButton) {
17109
17564
  elements.optionsRemoteButton.hidden = !hasRemoteWebuiCommand;
@@ -18770,6 +19225,11 @@ function renderNetworkStatus() {
18770
19225
  : "Off";
18771
19226
  elements.openNetworkButton.disabled = rebinding;
18772
19227
  elements.openNetworkButton.textContent = opening ? "Opening…" : closing ? "Closing…" : open ? "Close for network" : "Open to network";
19228
+ if (elements.showRemoteQrButton) {
19229
+ elements.showRemoteQrButton.hidden = !open;
19230
+ elements.showRemoteQrButton.disabled = rebinding || !open;
19231
+ elements.showRemoteQrButton.textContent = "Show QR code";
19232
+ }
18773
19233
  }
18774
19234
 
18775
19235
  async function refreshNetworkStatus() {
@@ -19702,6 +20162,7 @@ async function refreshAll(tabContext = activeTabContext()) {
19702
20162
  refreshMessages(tabContext),
19703
20163
  refreshModels(tabContext),
19704
20164
  refreshCommands(tabContext),
20165
+ refreshNaturalConversationMode(tabContext),
19705
20166
  refreshStats(tabContext),
19706
20167
  refreshWorkspace(tabContext),
19707
20168
  refreshAppRunners(tabContext),
@@ -20103,8 +20564,10 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
20103
20564
  }
20104
20565
 
20105
20566
  const targetWasStreaming = !!currentState?.isStreaming;
20567
+ const targetWasCompacting = !!currentState?.isCompacting;
20568
+ const targetWasBusy = targetWasStreaming || targetWasCompacting;
20106
20569
  const busyBehavior = normalizeBusyPromptBehavior(busyPromptBehavior);
20107
- const startsRun = kind === "prompt" && !targetWasStreaming;
20570
+ const startsRun = kind === "prompt" && !targetWasBusy;
20108
20571
  autoFollowChat = true;
20109
20572
  updateJumpToLatestButton();
20110
20573
  setComposerActionsOpen(false);
@@ -20133,7 +20596,7 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
20133
20596
  response = await api("/api/follow-up", { method: "POST", body: bodyBase, tabId: targetTabId });
20134
20597
  } else {
20135
20598
  const body = { ...bodyBase };
20136
- if (targetWasStreaming) body.streamingBehavior = streamingBehavior || busyBehavior;
20599
+ if (targetWasBusy) body.streamingBehavior = streamingBehavior || busyBehavior;
20137
20600
  response = await api("/api/prompt", { method: "POST", body, tabId: targetTabId });
20138
20601
  }
20139
20602
  applyResponseTab(response);
@@ -20142,6 +20605,9 @@ async function sendPrompt(kind = "prompt", explicitMessage, { targetTabId = acti
20142
20605
  if (startsRun && response?.command === "native_slash_command") {
20143
20606
  markTabIdleLocally(targetTabId);
20144
20607
  if (targetStillActive) clearRunIndicatorActivity();
20608
+ } else if (targetStillActive && response?.data?.queuedFor === "compaction") {
20609
+ setRunIndicatorActivity("Prompt queued; Pi will resume automatically after compaction…");
20610
+ addEvent("prompt queued until compaction finishes");
20145
20611
  } else if (targetStillActive && kind === "steer" && currentState?.isStreaming) {
20146
20612
  setRunIndicatorActivity("Steering sent; waiting for the next output or action…");
20147
20613
  } else if (targetStillActive && kind === "follow-up" && currentState?.isStreaming) {
@@ -20219,6 +20685,7 @@ function handleExtensionUiRequest(request) {
20219
20685
  }
20220
20686
  if (statusKey === STATS_WEBUI_STATUS_KEY) handleStatsWebuiStatus(request.statusText);
20221
20687
  if (statusKey === BTW_WEBUI_STATUS_KEY) handleBtwWebuiStatus(request.statusText);
20688
+ if (statusKey === NATURAL_CONVERSATION_STATUS_KEY) handleNaturalConversationStatus(request.statusText, request.tabId || activeTabId);
20222
20689
  if (statusKey === "pi-remote-webui") handleRemoteWebuiStatus(request.statusText);
20223
20690
  updateOptionalFeatureAvailability();
20224
20691
  if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) {
@@ -20501,6 +20968,23 @@ function handleEvent(event) {
20501
20968
  renderQueue(event);
20502
20969
  scheduleRefreshState();
20503
20970
  break;
20971
+ case "webui_compaction_queue_update":
20972
+ renderQueue(event);
20973
+ if (currentState) currentState = { ...currentState, pendingMessageCount: Number(event.pendingMessageCount ?? event.queueLength ?? currentState.pendingMessageCount ?? 0) };
20974
+ if (event.error) {
20975
+ addEvent(`queued compaction prompt resume failed: ${event.error}`, "error");
20976
+ } else if (event.drained) {
20977
+ addEvent("queued compaction prompt sent; Pi is resuming");
20978
+ } else if (event.draining) {
20979
+ setRunIndicatorActivity("Sending queued prompt after compaction…");
20980
+ addEvent("sending queued compaction prompt after compaction");
20981
+ } else if (event.queuedId) {
20982
+ setRunIndicatorActivity("Prompt queued; Pi will resume automatically after compaction…");
20983
+ addEvent("prompt queued until compaction finishes");
20984
+ }
20985
+ renderStatus();
20986
+ scheduleRefreshState();
20987
+ break;
20504
20988
  case "agent_start":
20505
20989
  if (currentState) currentState = { ...currentState, isStreaming: true };
20506
20990
  setRunIndicatorActivity("Agent run started; waiting for first output or action…");
@@ -20957,6 +21441,9 @@ elements.releaseAurButton.addEventListener("click", () => runPublishWorkflow("/r
20957
21441
  elements.nativeSkillsButton.addEventListener("click", () => runNativeCommandMenu("/skills"));
20958
21442
  elements.nativeToolsButton.addEventListener("click", () => runNativeCommandMenu("/tools"));
20959
21443
  elements.optionsCommandPaletteButton.addEventListener("click", () => openCommandPalette());
21444
+ elements.optionsConversationModeButton?.addEventListener("click", () => toggleNaturalConversationMode());
21445
+ elements.conversationModeChip?.addEventListener("click", () => toggleNaturalConversationMode());
21446
+ elements.conversationModeEndButton?.addEventListener("click", () => setNaturalConversationModeEnabled(false));
20960
21447
  elements.optionsResumeButton.addEventListener("click", () => runNativeCommandMenu("/resume"));
20961
21448
  elements.optionsReloadButton.addEventListener("click", () => runNativeCommandMenu("/reload"));
20962
21449
  elements.optionsRemoteButton.addEventListener("click", () => runNativeCommandMenu("/remote"));
@@ -21374,6 +21861,7 @@ if (elements.backgroundClearButton) {
21374
21861
  }
21375
21862
  elements.remoteAuthToggle.addEventListener("change", () => toggleRemoteAuth().catch((error) => addEvent(error.message || String(error), "error")));
21376
21863
  elements.openNetworkButton.addEventListener("click", openToNetwork);
21864
+ elements.showRemoteQrButton?.addEventListener("click", () => showRemoteWebuiQrPopupFromNetwork().catch((error) => addEvent(error.message || String(error), "error")));
21377
21865
  elements.remoteQrCopyButton?.addEventListener("click", () => copyRemoteWebuiQrUrl().catch((error) => addEvent(error.message || String(error), "error")));
21378
21866
  elements.remoteQrOpenButton?.addEventListener("click", openRemoteWebuiQrUrl);
21379
21867
  elements.remoteQrCloseButton?.addEventListener("click", closeRemoteWebuiQrPopup);