pi-web-ui 0.104.3 → 0.104.4
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/CHANGELOG.md +10 -0
- package/dist/server/agent-service.js +16 -6
- package/dist/server/client-state.js +13 -2
- package/dist/server/settings-service.js +11 -5
- package/package.json +1 -1
- package/web/dist/assets/{TerminalPanel-VjlOOAig.js → TerminalPanel-B7x99tkg.js} +1 -1
- package/web/dist/assets/index-DOrLcjLY.js +680 -0
- package/web/dist/assets/index-_H2BS7OX.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-5SITmQd_.js +0 -680
- package/web/dist/assets/index-D9wTa3O-.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
暂无未发布内容。
|
|
14
14
|
|
|
15
|
+
## [0.104.4] — 2026-10-12
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **流式输出跟手滚动与物理向上手势即时打断**:
|
|
20
|
+
- 重构 `MessageList` 滚动捕获与吸底总闸门:捕获用户滚轮向上、触控向上滑动、按住滚动条滑块拖动及 PageUp 物理手势时当场立即切断自动吸底并作废保护窗,绝不等异步 `onScroll` 事件,彻底避免浏览器平滑滚动第一帧被流式 MutationObserver 强行拉回底部;
|
|
21
|
+
- 流式渲染平滑收尾(`StreamMarkdown` draining):流式结束到转为静态 Markdown 之间引入缓冲排水状态,避免 DOM 瞬间跳变导致高度突变或文字闪烁;加固思考折叠块(`ThinkingBlock`)与工具卡片(`ToolCallBlock`)展开收起时的视口锚定与高度补偿。
|
|
22
|
+
- **内部基础设施扩展隔离与启停白名单保护** —— 将 codemode、tool-search、persona 等宿主注入的内部基础设施扩展标为 `hidden: true`,明确排除在扩展设置列表之外,避免污染设置项与幽灵扩展检测;在子代理白名单(`isExtensionEnabled`)及全局扩展禁用(`isExtensionDisabled`)判定中始终放行内部扩展,防止被意外拦截或被子代理模板白名单误剔除。
|
|
23
|
+
|
|
15
24
|
## [0.104.3] — 2026-10-12
|
|
16
25
|
|
|
17
26
|
### Added
|
|
@@ -1739,6 +1748,7 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
|
|
|
1739
1748
|
[0.64.4]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.64.4
|
|
1740
1749
|
[0.64.3]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.64.3
|
|
1741
1750
|
[0.64.2]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.64.2
|
|
1751
|
+
[0.104.4]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.104.4
|
|
1742
1752
|
[0.104.3]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.104.3
|
|
1743
1753
|
[0.104.2]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.104.2
|
|
1744
1754
|
[0.64.1]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.64.1
|
|
@@ -47,7 +47,7 @@ import { SlashCommandsService, parseSlash } from "./slash-commands.js";
|
|
|
47
47
|
import { ModelAdminService } from "./model-admin.js";
|
|
48
48
|
import { FilesService, MACHINE_ROOT, desktopDirWire, workspacePath } from "./files-service.js";
|
|
49
49
|
import { buildRemoteWorkspacePersona, createRemoteSdkOperations, formatCwdForPrompt, getGlobalRemoteSshService, isRemoteWorkspaceUri, RemoteSshService, resolveWorkspaceSessionDir, restoreWorkspaceUriFromSessionDir, setGlobalRemoteSshService, } from "./remote-ssh-service.js";
|
|
50
|
-
import { DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS, effectiveToolWatchdogMs, isExtensionDisabled, isExtensionEnabled, normalizeDisabledPluginTools, normalizePathKey, normalizeRetryMaxAttempts, normalizeSkillList, ClientStateStore, } from "./client-state.js";
|
|
50
|
+
import { DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS, effectiveToolWatchdogMs, isExtensionDisabled, isExtensionEnabled, isInternalExtension, normalizeDisabledPluginTools, normalizePathKey, normalizeRetryMaxAttempts, normalizeSkillList, ClientStateStore, } from "./client-state.js";
|
|
51
51
|
import { pick, resolveServerLang } from "./i18n.js";
|
|
52
52
|
import { SubagentTemplatesStore, pickTemplatePrompt } from "./subagent-templates.js";
|
|
53
53
|
import { ApprovalRulesStore, extractTargetPath } from "./approval-rules.js";
|
|
@@ -195,7 +195,7 @@ export class QuiesceRejectedError extends Error {
|
|
|
195
195
|
// /api/file HTTP endpoint instead of the WebSocket, so they are classified
|
|
196
196
|
// here but never read into the snapshot path.
|
|
197
197
|
// ---------------------------------------------------------------------------
|
|
198
|
-
import {
|
|
198
|
+
import { splitAgentStartPrompt, PI_DOC_PATHS, WINDOWS_PERSONA } from "./persona-chain.js";
|
|
199
199
|
export { splitAgentStartPrompt };
|
|
200
200
|
import { makeKillableBashTool, makeAdaptiveBashTool } from "./bash-tool.js";
|
|
201
201
|
export { makeKillableBashTool, makeAdaptiveBashTool };
|
|
@@ -2066,8 +2066,8 @@ export class ClientSession {
|
|
|
2066
2066
|
// 注意 SDK 在 extensionsOverride 之后才补 sourceInfo,包扩展此处只能靠路径
|
|
2067
2067
|
// 匹配 —— isExtensionDisabled / isExtensionEnabled 同时比对 npm:<pkg> 候选键。
|
|
2068
2068
|
extensionsOverride: (res) => {
|
|
2069
|
-
//
|
|
2070
|
-
const keepOwn = (e) =>
|
|
2069
|
+
// 内部基础设施扩展(codemode、tool-search、persona 等)不参与白名单/禁用过滤。
|
|
2070
|
+
const keepOwn = (e) => isInternalExtension(e);
|
|
2071
2071
|
if (apply && apply.enabledExtensions.length > 0) {
|
|
2072
2072
|
const set = new Set(apply.enabledExtensions);
|
|
2073
2073
|
return {
|
|
@@ -2085,8 +2085,18 @@ export class ClientSession {
|
|
|
2085
2085
|
// 覆盖,则用 composer 把 {{token}} 展开为各来源文本(工具列表/项目上下文/技能
|
|
2086
2086
|
// 等都取自本次 run 的 systemPromptOptions,永远最新)。
|
|
2087
2087
|
extensionFactories: [
|
|
2088
|
-
|
|
2089
|
-
|
|
2088
|
+
{
|
|
2089
|
+
name: "codemode",
|
|
2090
|
+
hidden: true,
|
|
2091
|
+
replaceable: true,
|
|
2092
|
+
factory: createCodemodeExtension(),
|
|
2093
|
+
},
|
|
2094
|
+
{
|
|
2095
|
+
name: "tool-search",
|
|
2096
|
+
hidden: true,
|
|
2097
|
+
replaceable: true,
|
|
2098
|
+
factory: createToolSearchExtension(),
|
|
2099
|
+
},
|
|
2090
2100
|
{
|
|
2091
2101
|
name: "pi-webui-persona",
|
|
2092
2102
|
hidden: true,
|
|
@@ -312,8 +312,16 @@ export function extensionKeyCandidates(e) {
|
|
|
312
312
|
}
|
|
313
313
|
return [...keys];
|
|
314
314
|
}
|
|
315
|
-
/**
|
|
315
|
+
/** 判断一个扩展是否为宿主或 SDK 内部注入的基础设施扩展(如 codemode、tool_search、persona 等),
|
|
316
|
+
* 这些扩展不属于用户安装的业务扩展,不应在设置面板显示,也不受用户启停配置控制。 */
|
|
317
|
+
export function isInternalExtension(e) {
|
|
318
|
+
return Boolean(e.hidden) || e.path.startsWith("<inline:") || e.path.startsWith("<builtin:");
|
|
319
|
+
}
|
|
320
|
+
/** Whether an extension is covered by the disabled list (any identity match).
|
|
321
|
+
* Internal / hidden infrastructure extensions are always exempt. */
|
|
316
322
|
export function isExtensionDisabled(e, disabled) {
|
|
323
|
+
if (isInternalExtension(e))
|
|
324
|
+
return false;
|
|
317
325
|
if (disabled.length === 0)
|
|
318
326
|
return false;
|
|
319
327
|
const keys = extensionKeyCandidates(e);
|
|
@@ -321,8 +329,11 @@ export function isExtensionDisabled(e, disabled) {
|
|
|
321
329
|
}
|
|
322
330
|
/** Whether an extension is covered by an ENABLED whitelist (any identity
|
|
323
331
|
* match). Empty whitelist = not whitelisting = everything allowed. Used by
|
|
324
|
-
* subagent templates(白名单语义:模板勾选 = 子代理只加载这些扩展)。
|
|
332
|
+
* subagent templates(白名单语义:模板勾选 = 子代理只加载这些扩展)。
|
|
333
|
+
* Internal / hidden infrastructure extensions are always kept. */
|
|
325
334
|
export function isExtensionEnabled(e, enabled) {
|
|
335
|
+
if (isInternalExtension(e))
|
|
336
|
+
return true;
|
|
326
337
|
if (enabled.length === 0)
|
|
327
338
|
return true;
|
|
328
339
|
const keys = extensionKeyCandidates(e);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
10
10
|
import { basename, dirname, join } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
-
import { extensionKey, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, settingsPresetToUi, } from "./client-state.js";
|
|
12
|
+
import { extensionKey, isInternalExtension, normalizeBgCleanupMinutes, normalizeDisabledPluginTools, normalizeRetryMaxAttempts, normalizeKeepRecentMessages, normalizeSkillList, normalizeToolWatchdogTimeoutMs, normalizeUiLayout, settingsPresetToUi, } from "./client-state.js";
|
|
13
13
|
import { normalizeSoftCapByModel, normalizeSoftCapTokens } from "./soft-cap.js";
|
|
14
14
|
import { findVisionModels, SYSTEM_PROMPT } from "./vision-bridge.js";
|
|
15
15
|
import { COMMITMSG_SYSTEM_PROMPT } from "./scm-commitmsg.js";
|
|
@@ -116,6 +116,8 @@ export class SettingsService {
|
|
|
116
116
|
extensionStillOnDisk(id) {
|
|
117
117
|
if (!id)
|
|
118
118
|
return false;
|
|
119
|
+
if (isInternalExtension({ path: id }))
|
|
120
|
+
return false;
|
|
119
121
|
if (id.startsWith("npm:")) {
|
|
120
122
|
const pkg = id.slice(4);
|
|
121
123
|
if (!pkg)
|
|
@@ -165,7 +167,8 @@ export class SettingsService {
|
|
|
165
167
|
let loadedExtNames = null;
|
|
166
168
|
try {
|
|
167
169
|
const loadedSkills = this.host.getSession().resourceLoader.getSkills().skills;
|
|
168
|
-
const
|
|
170
|
+
const allLoadedExts = this.host.getSession().resourceLoader.getExtensions().extensions;
|
|
171
|
+
const loadedExts = allLoadedExts.filter((e) => !isInternalExtension(e));
|
|
169
172
|
loadedSkillNames = new Set(loadedSkills.map((s) => s.name));
|
|
170
173
|
loadedExtNames = new Set(loadedExts.map((e) => extensionKey(e)));
|
|
171
174
|
// Prune entries that no longer exist on disk AND aren't disabled
|
|
@@ -174,7 +177,7 @@ export class SettingsService {
|
|
|
174
177
|
const keepSkills = new Set([...loadedSkills.map((s) => s.name), ...this.settings.disabledSkills]);
|
|
175
178
|
const keepExts = new Set([
|
|
176
179
|
...loadedExts.map((e) => extensionKey(e)),
|
|
177
|
-
...this.settings.disabledExtensions,
|
|
180
|
+
...this.settings.disabledExtensions.filter((id) => !isInternalExtension({ path: id })),
|
|
178
181
|
]);
|
|
179
182
|
// eslint-disable-next-line unicorn/no-useless-spread -- snapshot: handlers may unsubscribe mid-emit
|
|
180
183
|
for (const name of [...this.knownSkills.keys()]) {
|
|
@@ -183,7 +186,7 @@ export class SettingsService {
|
|
|
183
186
|
}
|
|
184
187
|
// eslint-disable-next-line unicorn/no-useless-spread -- snapshot: handlers may unsubscribe mid-emit
|
|
185
188
|
for (const id of [...this.knownExtensions.keys()]) {
|
|
186
|
-
if (!keepExts.has(id))
|
|
189
|
+
if (!keepExts.has(id) || isInternalExtension({ path: id }))
|
|
187
190
|
this.knownExtensions.delete(id);
|
|
188
191
|
}
|
|
189
192
|
for (const s of loadedSkills) {
|
|
@@ -237,7 +240,7 @@ export class SettingsService {
|
|
|
237
240
|
// 从禁用记录里剔除并持久化 —— 否则卸载过的扩展以“已禁用”灰条永生(issue #192)。
|
|
238
241
|
// loadedExtNames 非 null 即 session 就绪;取不到(catch 分支)时保守跳过。
|
|
239
242
|
if (loadedExtNames !== null) {
|
|
240
|
-
const staleExts = this.settings.disabledExtensions.filter((id) => !loadedExtNames.has(id) && !this.extensionStillOnDisk(id));
|
|
243
|
+
const staleExts = this.settings.disabledExtensions.filter((id) => isInternalExtension({ path: id }) || (!loadedExtNames.has(id) && !this.extensionStillOnDisk(id)));
|
|
241
244
|
if (staleExts.length > 0) {
|
|
242
245
|
this.settings.disabledExtensions = this.settings.disabledExtensions.filter((n) => !staleExts.includes(n));
|
|
243
246
|
this.host.stateStore.saveSettings(this.host.clientId, {
|
|
@@ -255,6 +258,8 @@ export class SettingsService {
|
|
|
255
258
|
// (上面的 stale 清理已把卸载项移出禁用记录;这里再按磁盘挡一次,
|
|
256
259
|
// session 未就绪跳过清理时也不复活幽灵。)
|
|
257
260
|
for (const id of this.settings.disabledExtensions) {
|
|
261
|
+
if (isInternalExtension({ path: id }))
|
|
262
|
+
continue;
|
|
258
263
|
if (!this.knownExtensions.has(id)) {
|
|
259
264
|
if (!this.extensionStillOnDisk(id))
|
|
260
265
|
continue;
|
|
@@ -273,6 +278,7 @@ export class SettingsService {
|
|
|
273
278
|
.map((s) => ({ ...s, enabled: !reviewDisabledSkills.has(s.name) }))
|
|
274
279
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
275
280
|
const extensions = [...this.knownExtensions.values()]
|
|
281
|
+
.filter((e) => !isInternalExtension({ path: e.id }) && !isInternalExtension({ path: e.path }))
|
|
276
282
|
.map((e) => ({ ...e, enabled: !disabledExts.has(e.id) }))
|
|
277
283
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
278
284
|
// 统一工具开关是单源(disabledAgentTools),遗留三开关推送时推导,保证面板一致。
|
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-CR5VJ85Q.js";import{n as r,t as i}from"./xterm-Cf5xxe4g.js";import{a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-CR5VJ85Q.js";import{n as r,t as i}from"./xterm-Cf5xxe4g.js";import{a,c as o,d as s,f as c,g as l,h as u,i as d,l as f,m as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./index-DOrLcjLY.js";var b=e(t(),1);function x(e,t){return Math.abs(t)>10&&Math.abs(t)>Math.abs(e)*1.2}function S(e,t){return e-t}var C=n();function w(e){let t=null;return{clean:e.replace(/\r?\n?\[pi-term-exit:(-?\d+)\]\r?\n?/g,(e,n)=>(t=Number(n),`\r
|
|
2
2
|
`)).replace(/\r?\n?\x1b\[90m\[(?:进程已退出,退出码 |Process exited with code )-?\d+\]\x1b\[0m\r?\n?/g,`\r
|
|
3
3
|
`),exitCode:t}}function T({conversationId:e,terminalId:t,command:n,cwd:o,title:s,agentBash:c,active:l,running:u,exitCode:f,register:p}){let h=(0,b.useRef)(null),_=(0,b.useRef)(null),{locale:v}=m(),y=(0,b.useRef)(v);y.current=v;let T=n?JSON.stringify(n):``,E=(0,b.useRef)(u===!1);(0,b.useEffect)(()=>{let u=h.current;if(!u)return;let f=new r({theme:d(),fontFamily:`"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace`,fontSize:13,cursorBlink:!0,scrollback:8e3}),m=new i;f.loadAddon(m),f.open(u),_.current={term:f,fit:m},l&&f.focus();let v=()=>{f.options.theme=d()};window.addEventListener(g,v),f.attachCustomKeyEventHandler(e=>{if(e.type!==`keydown`)return!0;let t=e.key?.toLowerCase();if((e.ctrlKey||e.metaKey)&&t===`v`)return!1;if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&t===`c`&&f.hasSelection()){let e=f.textarea;return e&&(e.value=f.getSelection(),e.select()),!1}return!0});let b=p(e,t,{write:e=>f.write(w(e).clean),dispose:()=>f.dispose()}),C=()=>{try{m.fit(),a({type:`terminal_resize`,terminalId:t,conversationId:e,cols:f.cols,rows:f.rows})}catch{}},T=requestAnimationFrame(()=>{try{m.fit()}catch{}E.current||a(n?{type:`run_command`,terminalId:t,conversationId:e,command:n,cols:f.cols,rows:f.rows}:{type:`terminal_create`,terminalId:t,title:s,locale:y.current,agentBash:c,conversationId:e,cwd:o,cols:f.cols,rows:f.rows})}),D=f.onData(n=>{a({type:`terminal_input`,terminalId:t,conversationId:e,data:n})}),O=f.element,k=null,A=0,j=0,M=0,N=!1,P=e=>{if(e.touches.length!==1){k=null,N=!1;return}let t=e.touches[0];k=t.identifier,A=t.clientX,j=t.clientY,M=t.clientY,N=!1},F=e=>{if(k===null||e.touches.length!==1)return;let t=e.touches[0];if(t.identifier!==k)return;if(!N){if(!x(t.clientX-A,t.clientY-j))return;N=!0}e.preventDefault();let n=S(M,t.clientY);M=t.clientY,n!==0&&typeof WheelEvent<`u`&&(u.querySelector(`.xterm-viewport`)??O)?.dispatchEvent(new WheelEvent(`wheel`,{bubbles:!0,cancelable:!0,deltaY:n,deltaMode:0,clientX:t.clientX,clientY:t.clientY}))},I=e=>{if(k!==null){if(e.touches.length>0){k=null,N=!1;return}k=null,N=!1}};O?.addEventListener(`touchstart`,P,{passive:!0}),O?.addEventListener(`touchmove`,F,{passive:!1}),O?.addEventListener(`touchend`,I),O?.addEventListener(`touchcancel`,I);let L=null;return typeof ResizeObserver<`u`&&(L=new ResizeObserver(()=>{u.offsetWidth>0&&u.offsetHeight>0&&C()}),L.observe(u)),()=>{cancelAnimationFrame(T),D.dispose(),O?.removeEventListener(`touchstart`,P),O?.removeEventListener(`touchmove`,F),O?.removeEventListener(`touchend`,I),O?.removeEventListener(`touchcancel`,I),window.removeEventListener(g,v),L?.disconnect(),b(),f.dispose(),_.current=null}},[e,t,T,p]),(0,b.useEffect)(()=>{if(!l)return;let n=requestAnimationFrame(()=>{let n=_.current;if(n){try{n.fit.fit(),a({type:`terminal_resize`,terminalId:t,conversationId:e,cols:n.term.cols,rows:n.term.rows})}catch{}n.term.focus()}});return()=>cancelAnimationFrame(n)},[l]);let{t:D}=m(),O=(0,b.useRef)(void 0);return(0,b.useEffect)(()=>{if(u===O.current||(O.current=u,u!==!1))return;let e=_.current;e&&e.term.write(`\r\n\x1b[90m${D(`exitBanner`,{code:f??``})}\x1b[0m\r\n`)},[u,t,f]),(0,C.jsx)(`div`,{ref:h,className:`term-xterm ${l?``:`hidden`}`})}var E={name:``,command:``,cwd:"${pwd}"};function D({chat:e,terminal:t,uiTerminalToolbar:n,onUiAction:r}){let i=_(),[d,m]=(0,b.useState)(null),[g,x]=(0,b.useState)(!1),[S,w]=(0,b.useState)(!1),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(E),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),[P,F]=(0,b.useState)(!0),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(``);(0,b.useEffect)(()=>{e.terminals.length===0?m(null):e.terminals.some(e=>e.id===d)||m(e.terminals[e.terminals.length-1].id)},[e.terminals,d]),(0,b.useEffect)(()=>{e.terminalActiveId&&(m(e.terminalActiveId),x(!1))},[e.terminalActiveId]),(0,b.useEffect)(()=>()=>{N.current&&clearTimeout(N.current)},[]);let B=e.terminals.filter(e=>!e.agentBash),V=e.terminals.filter(e=>e.agentBash),H=n=>{if(!e.ready)return;let r=o(),i=e.activeConversationId||e.state?.conversationId||``;t.create({...n,id:r,conversationId:i,cols:n.cols??80,rows:n.rows??24,running:!0,exitCode:null}),m(r),x(!1)},U=()=>H({title:i(`terminalTitle`,{n:B.length+1}),cwd:e.state?.cwd??``}),W=n=>{let r=n.name||n.command,i=e.terminals.find(e=>e.title===r);if(i){t.restart(i.id),m(i.id),a({type:`run_command`,terminalId:i.id,conversationId:i.conversationId,command:n,cols:80,rows:24});return}H({title:r,cwd:e.state?.cwd??``,command:n})},G=n=>{let r=e.terminals.find(e=>e.id===n);if(r&&a({type:`terminal_kill`,terminalId:n,conversationId:r.conversationId}),t.close(n),d===n){let t=e.terminals.filter(e=>e.id!==n);m(t.length>0?t[t.length-1].id:null)}},K=e=>(0,C.jsxs)(`div`,{className:`term-tab ${e.id===d?`active`:``}`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`term-tab-main`,title:`${e.cwd}${e.command?`\n> ${e.command.command}`:``}`,onClick:()=>{I||(m(e.id),x(!1))},children:[(0,C.jsx)(`span`,{className:`term-tab-dot ${e.running?`run`:`exit`}`}),(0,C.jsxs)(`span`,{className:`term-tab-title`,children:[I===e.id?(0,C.jsx)(`input`,{autoFocus:!0,className:`term-tab-rename-input`,value:R,placeholder:e.title,onClick:e=>e.stopPropagation(),onChange:e=>z(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=R.trim();t&&a({type:`rename_terminal`,terminalId:e.id,conversationId:e.conversationId,title:t}),L(null)}else t.key===`Escape`&&L(null)},onBlur:()=>L(null)}):e.title,!e.running&&(0,C.jsx)(`span`,{className:`term-tab-exit`,children:i(`exited`,{code:e.exitCode===null?``:` ${e.exitCode}`})})]})]}),(0,C.jsx)(`button`,{type:`button`,className:`term-tab-close term-tab-rename`,title:i(`renameTerminal`),onClick:t=>{t.stopPropagation(),z(e.title),L(e.id)},children:(0,C.jsx)(f,{})}),(0,C.jsx)(`button`,{type:`button`,className:`term-tab-close`,title:i(`closeTerminal`),onClick:()=>G(e.id),children:(0,C.jsx)(l,{})})]},e.id),q=()=>{w(!0),O(null),A(E)},ee=t=>{let n=e.commands[t];n&&(w(!1),O(t),A({name:n.name,command:n.command,cwd:n.cwd??``}))},J=()=>{w(!1),O(null)},Y=()=>{let t=k.name.trim(),n=k.command.trim();if(!t||!n)return;let r={name:t,command:n,cwd:k.cwd.trim()||void 0},i=S?[...e.commands,r]:D===null?e.commands:e.commands.map((e,t)=>t===D?r:e);a({type:`save_commands`,commands:i}),J()},te=t=>{if(j===t){let n=e.commands.filter((e,n)=>n!==t);a({type:`save_commands`,commands:n}),M(null),N.current&&clearTimeout(N.current)}else M(t),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>M(null),2500)},ne=S||D!==null,X=n===void 0?[`host:term-cmd-refresh`,`host:term-cmd-new`,`host:term-tab-new`].map(e=>({id:e,source:`host`})):n.filter(e=>!e.hidden),Z=(e,t)=>{let n=new Set(e);return X.filter(e=>n.has(e.id)||t&&e.source!==`host`)},Q=(e,t)=>{let n=X.find(t=>t.id===e);return n?.labelExplicit?n.label:t},$={"host:term-cmd-refresh":(0,C.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:Q(`host:term-cmd-refresh`,i(`rerun`)),onClick:()=>a({type:`list_commands`}),children:(0,C.jsx)(h,{})}),"host:term-cmd-new":(0,C.jsx)(`button`,{type:`button`,className:`panel-new`,title:Q(`host:term-cmd-new`,i(`newCommand`)),onClick:q,children:(0,C.jsx)(c,{})}),"host:term-tab-new":(0,C.jsx)(`button`,{type:`button`,className:`panel-new`,title:Q(`host:term-tab-new`,i(`newTerminal`)),onClick:U,children:(0,C.jsx)(c,{})})};return(0,C.jsxs)(`div`,{className:`terminal-view`,children:[(0,C.jsxs)(`aside`,{className:`term-side term-commands ${g?`open`:``}`,children:[(0,C.jsxs)(`div`,{className:`panel-header`,children:[(0,C.jsx)(`span`,{className:`panel-title`,children:i(`commands`)}),(0,C.jsx)(`div`,{className:`panel-header-actions`,children:v(Z([`host:term-cmd-refresh`,`host:term-cmd-new`],!1),$,r)})]}),(0,C.jsx)(`div`,{className:`panel-body`,children:ne?(0,C.jsxs)(`div`,{className:`cmd-form`,children:[(0,C.jsx)(`label`,{htmlFor:`cmd-name`,children:i(`name`)}),(0,C.jsx)(`input`,{id:`cmd-name`,className:`cmd-input`,value:k.name,placeholder:i(`exampleName`),autoFocus:!0,onChange:e=>A({...k,name:e.target.value})}),(0,C.jsx)(`label`,{htmlFor:`cmd-command`,children:i(`command`)}),(0,C.jsx)(`input`,{id:`cmd-command`,className:`cmd-input`,value:k.command,placeholder:i(`exampleCommand`),onChange:e=>A({...k,command:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Y()}}),(0,C.jsxs)(`label`,{htmlFor:`cmd-cwd`,children:[i(`directory`),` `,(0,C.jsx)(`span`,{className:`cmd-hint`,children:i(`cwdHint`)})]}),(0,C.jsx)(`input`,{id:`cmd-cwd`,className:`cmd-input`,value:k.cwd,placeholder:"${pwd}",onChange:e=>A({...k,cwd:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&Y()}}),(0,C.jsxs)(`div`,{className:`cmd-form-actions`,children:[(0,C.jsx)(`button`,{type:`button`,className:`btn`,onClick:J,children:i(`cancel`)}),(0,C.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!k.name.trim()||!k.command.trim(),onClick:Y,children:i(`save`)})]})]}):(0,C.jsxs)(C.Fragment,{children:[e.commands.length===0&&(0,C.jsx)(`div`,{className:`panel-empty`,children:i(`noCommands`)}),e.commands.map((e,t)=>(0,C.jsxs)(`div`,{className:`cmd-item`,children:[(0,C.jsx)(`button`,{type:`button`,className:`cmd-run`,title:i(`clickToRun`),onClick:()=>W(e),children:(0,C.jsx)(s,{})}),(0,C.jsxs)(`button`,{type:`button`,className:`cmd-main`,title:i(`clickToRun`),onClick:()=>W(e),children:[(0,C.jsx)(`span`,{className:`cmd-name`,children:e.name}),(0,C.jsx)(`span`,{className:`cmd-command`,children:e.command}),e.cwd&&(0,C.jsx)(`span`,{className:`cmd-cwd`,children:e.cwd})]}),(0,C.jsx)(`button`,{type:`button`,className:`cmd-act`,title:i(`edit`),onClick:()=>ee(t),children:(0,C.jsx)(f,{})}),(0,C.jsx)(`button`,{type:`button`,className:`cmd-act del ${j===t?`confirm`:``}`,title:i(`delete`),onClick:()=>te(t),children:j===t?i(`confirmQ`):(0,C.jsx)(u,{})})]},t))]})}),(0,C.jsxs)(`div`,{className:`term-tabs-block`,children:[(0,C.jsxs)(`div`,{className:`panel-header`,children:[(0,C.jsx)(`span`,{className:`panel-title`,children:i(`terminal`)}),v(Z([`host:term-tab-new`],!0),$,r)]}),(0,C.jsxs)(`div`,{className:`panel-body`,children:[e.terminals.length===0&&(0,C.jsx)(`div`,{className:`panel-empty`,children:i(`noTerminal`)}),B.map(K),V.length>0&&(0,C.jsxs)(`div`,{className:`term-folder`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`term-folder-header ${P?`open`:``}`,title:i(`aiBashGroup`),onClick:()=>F(e=>!e),children:[(0,C.jsx)(`span`,{className:`term-folder-caret`,children:P?`▾`:`▸`}),(0,C.jsx)(`span`,{className:`term-folder-title`,children:i(`aiBashGroup`)}),(0,C.jsx)(`span`,{className:`term-folder-count`,children:V.length})]}),P&&(0,C.jsx)(`div`,{className:`term-folder-body`,children:V.map(K)})]})]})]})]}),(0,C.jsxs)(`div`,{className:`term-main`,children:[g&&(0,C.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>x(!1)}),(0,C.jsx)(`button`,{type:`button`,className:`term-side-toggle`,title:i(`commands`),onClick:()=>x(e=>!e),children:(0,C.jsx)(y,{})}),e.terminals.length===0?(0,C.jsxs)(`div`,{className:`term-empty`,children:[(0,C.jsx)(p,{className:`term-empty-icon`}),(0,C.jsx)(`div`,{className:`term-empty-title`,children:i(`builtinTerminal`)}),(0,C.jsx)(`div`,{className:`term-empty-sub`,children:i(`termEmptySub`)})]}):e.terminals.map(e=>(0,C.jsx)(T,{conversationId:e.conversationId,terminalId:e.id,command:e.command,cwd:e.cwd,title:e.title,agentBash:e.agentBash,active:e.id===d,running:e.running,exitCode:e.exitCode,register:t.register},`${e.conversationId}:${e.id}`))]})]})}export{D as TerminalPanel};
|