pi-web-ui 0.114.2 → 0.114.3
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 +22 -0
- package/dist/server/agent-service.js +29 -5
- package/dist/server/context-usage.js +105 -0
- package/dist/server/protocol-version.js +1 -1
- package/package.json +1 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BIlQ89vr.js → BgTasksModal-BvnUHjFe.js} +1 -1
- package/web/dist/assets/{BgTasksModal-Ck2sjlPM.js → BgTasksModal-DSC8ncW3.js} +1 -1
- package/web/dist/assets/{CanvasStudio-B3W6b_rA.js → CanvasStudio-BSg9ghPV.js} +2 -2
- package/web/dist/assets/{CanvasStudio-Csv1Sj1-.js → CanvasStudio-DxW7C3Sz.js} +2 -2
- package/web/dist/assets/{DeviceCenter-BQdDcO8A.js → DeviceCenter-Bmgr-Bwm.js} +1 -1
- package/web/dist/assets/{DeviceCenter-CHRKL0Vy.js → DeviceCenter-Cl9MBXaH.js} +1 -1
- package/web/dist/assets/{DeviceGroups-D2rogxEN.js → DeviceGroups-aeLD2msl.js} +1 -1
- package/web/dist/assets/{Dropdown-ZLS04O8p.js → Dropdown-D1Jl35dw.js} +1 -1
- package/web/dist/assets/{FilePreview-B9xoU6ON.js → FilePreview-6CqoDF_P.js} +1 -1
- package/web/dist/assets/{FilePreview-DUQpVZkH.js → FilePreview-CJa27G_Q.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-BXEGvUZq.js → GlobalSearchModal-CJX35rZL.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-CnVPmfOI.js → GlobalSearchModal-CMW0xz0P.js} +1 -1
- package/web/dist/assets/{GroupConversation-CyIpQzDd.js → GroupConversation-Cq4daBFb.js} +1 -1
- package/web/dist/assets/{GroupConversation-DgYV3uYS.js → GroupConversation-DoELa83U.js} +1 -1
- package/web/dist/assets/{ModelConfigModal-DDZccDYt.js → ModelConfigModal-Bp7tfKYh.js} +1 -1
- package/web/dist/assets/{PiSetupModal-DHbqfx8T.js → PiSetupModal-DD8srwBJ.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-C-MK36Dk.js → ProviderOAuthControls-C6tfXb88.js} +1 -1
- package/web/dist/assets/{SCMPanel-sVZcV7dR.js → SCMPanel-CghgsyBN.js} +1 -1
- package/web/dist/assets/{SCMPanel-imYI2Ecw.js → SCMPanel-D8-8aqwC.js} +1 -1
- package/web/dist/assets/{SettingsModal-Xw1Yoi3_.js → SettingsModal-BbBe2rYo.js} +1 -1
- package/web/dist/assets/{SettingsModal-mb4e34-0.js → SettingsModal-qETiVPKj.js} +1 -1
- package/web/dist/assets/{TerminalPanel-CLkJJvxg.js → TerminalPanel-Da-Xs4Wk.js} +1 -1
- package/web/dist/assets/{TerminalPanel-DpcIellm.js → TerminalPanel-DnS4tFQO.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-4-fFAZe7.js → TuiOverlayModal-CGyGkKYl.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-DCu01lks.js → TuiOverlayModal-CpBKjG6x.js} +1 -1
- package/web/dist/assets/{desktop-YguLbrX1.js → desktop-7EvUHhKQ.js} +1 -1
- package/web/dist/assets/{fi-DaSO0Q-m.js → fi-NyN-ZrgD.js} +2 -2
- package/web/dist/assets/{index-Cdh3sibd.js → index-DK3F5ZJo.js} +50 -50
- package/web/dist/assets/{index-DWw_SxRq.js → index-DQMii2he.js} +50 -50
- package/web/dist/assets/index-vwBnwzkr.css +1 -0
- package/web/dist/assets/{plugin-host-BRBg6zmQ.js → plugin-host-BCnX3P8U.js} +1 -1
- package/web/dist/assets/{theme-DDl-Oy1b.js → theme-D2DMH6tH.js} +1 -1
- package/web/dist/index.html +8 -8
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-DDZMv6LO.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,28 @@
|
|
|
12
12
|
|
|
13
13
|
暂无未发布内容。
|
|
14
14
|
|
|
15
|
+
## [0.114.3] — 2026-10-31
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **上下文分类明细(#805)**:点击顶栏、底栏或侧栏的上下文徽标,查看系统提示词、记忆文件、工具、技能、工具调用与结果、消息和剩余空间。支持浅深主题、窄屏、软上限,以及仅有总量的引擎。
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **分类缓存更新**:SDK 消息结束后的异步扩展可原地替换末条消息;末条与流式消息重新估算,截断后旧缓存也会失效,避免分类停留在旧内容。
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- 分类明确标注为会话内容估算;实际请求的去重、证据外置和扩展转换可能改变比例。分类校准不改变上下文总量或压缩阈值。新增真实服务浏览器和请求变换回归,协议版本同步为 40。
|
|
28
|
+
|
|
29
|
+
<!-- auto-i18n:start -->
|
|
30
|
+
|
|
31
|
+
### i18n
|
|
32
|
+
|
|
33
|
+
- 前端新增 key(14):`contextPercent`、`contextTokens`、`contextTokensEstimated`、`contextMemoryFiles`、`contextTools`、`contextSkills`、`contextToolResults`、`contextOther`、`contextUsed`、`contextFree`、`contextBreakdownUnavailable`、`contextBreakdownEstimate`、`contextUsageUnavailable`、`contextSoftCap`
|
|
34
|
+
|
|
35
|
+
<!-- auto-i18n:end -->
|
|
36
|
+
|
|
15
37
|
## [0.114.2] — 2026-10-31
|
|
16
38
|
|
|
17
39
|
### Added
|
|
@@ -141,7 +141,8 @@ import { scanAtMentions } from "./universal/universal-attachments.js";
|
|
|
141
141
|
import { extractStreamingPayload, formatQuotedPrompt, formatStreamingPrompt, readTextQuote, splitQuotedPrompt, } from "./text-quote.js";
|
|
142
142
|
import { buildVisionBridgePrompt, findVisionModels, transcribeImages } from "./vision-bridge.js";
|
|
143
143
|
import { generateScmCommitMessage } from "./scm-commitmsg.js";
|
|
144
|
-
import {
|
|
144
|
+
import { estimateBaseContext, estimateContextWeights, reconcileContextCategories, } from "./context-usage.js";
|
|
145
|
+
import { BUILTIN_SOUL, DEFAULT_PROMPT_TEMPLATE, buildToolsSchemaText, renderPromptTemplate, resolveSectionTexts, } from "./prompt-composer.js";
|
|
145
146
|
import { listAllMcpServers, checkMcpServer, installMcpServer, saveMcpServer as saveMcpServerFile, deleteMcpServer as deleteMcpServerFile, toggleMcpServer as toggleMcpServerFile, } from "./mcp-manager.js";
|
|
146
147
|
import { fetchRemoteMcpMarket, fetchRemoteSkillMarket, fetchRemoteSkillContent } from "./market-service.js";
|
|
147
148
|
import { McpOAuthUi } from "./mcp-oauth-ui.js";
|
|
@@ -2090,6 +2091,8 @@ export class ClientSession {
|
|
|
2090
2091
|
}
|
|
2091
2092
|
/** 会话级 Base Tokens 缓存(避免在节流快照热路径上重复计算正则)。 */
|
|
2092
2093
|
cachedBaseTokens = null;
|
|
2094
|
+
cachedContextWeights = null;
|
|
2095
|
+
contextMessageWeights = new WeakMap();
|
|
2093
2096
|
/** 指定会话(缺省 = 活跃会话)系统提示词 + 工具 schema 的基础 token 开销
|
|
2094
2097
|
* (与设置面板中的「合计」完全一致)。会话未就绪返回 null——调用方必须区分
|
|
2095
2098
|
* null 与 0:把 0 写进 lastTurnBaseTokens 会让后续轮次双计全额 base。 */
|
|
@@ -2106,12 +2109,30 @@ export class ClientSession {
|
|
|
2106
2109
|
const snap = this.sessionPromptSnapshot(conv);
|
|
2107
2110
|
if (!snap)
|
|
2108
2111
|
return null;
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2111
|
-
const tokens = prompt + schema;
|
|
2112
|
-
this.cachedBaseTokens = { at: now, convId: conv.id, tokens };
|
|
2112
|
+
const { tokens, weights } = estimateBaseContext(snap, this.settingsSvc.current);
|
|
2113
|
+
this.cachedBaseTokens = { at: now, convId: conv.id, tokens, weights };
|
|
2113
2114
|
return tokens;
|
|
2114
2115
|
}
|
|
2116
|
+
/** Classification is best-effort and must never affect totals or compaction. */
|
|
2117
|
+
contextCategories(conv, tokens) {
|
|
2118
|
+
try {
|
|
2119
|
+
const base = this.cachedBaseTokens;
|
|
2120
|
+
if (!base || base.convId !== conv.id)
|
|
2121
|
+
return undefined;
|
|
2122
|
+
const now = Date.now();
|
|
2123
|
+
if (!this.cachedContextWeights ||
|
|
2124
|
+
this.cachedContextWeights.base !== base.weights ||
|
|
2125
|
+
now - this.cachedContextWeights.at >= STATS_CACHE_MS) {
|
|
2126
|
+
const state = conv.session.agent.state;
|
|
2127
|
+
const weights = estimateContextWeights(base.weights, state.messages, state.streamingMessage, this.contextMessageWeights);
|
|
2128
|
+
this.cachedContextWeights = { base: base.weights, at: now, weights };
|
|
2129
|
+
}
|
|
2130
|
+
return reconcileContextCategories(this.cachedContextWeights.weights, tokens);
|
|
2131
|
+
}
|
|
2132
|
+
catch {
|
|
2133
|
+
return undefined;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2115
2136
|
/** 判断会话中是否已有大模型返回过有效 usage(input/output/totalTokens > 0)的定稿助手消息。 */
|
|
2116
2137
|
hasSettledAssistantUsage(conv) {
|
|
2117
2138
|
try {
|
|
@@ -5287,6 +5308,8 @@ export class ClientSession {
|
|
|
5287
5308
|
const cu = s.contextUsage;
|
|
5288
5309
|
if (!cu || cu.contextWindow <= 0)
|
|
5289
5310
|
return stats.contextUsage;
|
|
5311
|
+
// Refresh category weights even when compaction supplies the total directly.
|
|
5312
|
+
this.currentBaseTokens(conv);
|
|
5290
5313
|
const effectiveTokens = this.getEffectiveContextTokens(conv);
|
|
5291
5314
|
const isEstimated = cu.tokens != null &&
|
|
5292
5315
|
(conv.lastTurnBaseTokens == null || !this.hasSettledAssistantUsage(conv)) &&
|
|
@@ -5297,6 +5320,7 @@ export class ClientSession {
|
|
|
5297
5320
|
percent: (effectiveTokens / cu.contextWindow) * 100,
|
|
5298
5321
|
estimated: isEstimated,
|
|
5299
5322
|
softCap: this.activeSoftCap(cu.contextWindow),
|
|
5323
|
+
categories: this.contextCategories(conv, effectiveTokens),
|
|
5300
5324
|
};
|
|
5301
5325
|
})(),
|
|
5302
5326
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { estimateTokens } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { effectiveTemplate, estimatePromptTokens, overrideOf } from "./prompt-composer.js";
|
|
3
|
+
function emptyWeights() {
|
|
4
|
+
return { systemPrompt: 0, memoryFiles: 0, tools: 0, skills: 0, toolResults: 0, messages: 0, other: 0 };
|
|
5
|
+
}
|
|
6
|
+
/** Uses the same rendered prompt and token estimator as the settings preview. */
|
|
7
|
+
export function estimateBaseContext(snapshot, options) {
|
|
8
|
+
const weights = emptyWeights();
|
|
9
|
+
const disabled = new Set(options.promptDisabled ?? []);
|
|
10
|
+
const template = effectiveTemplate(options.promptTemplate ?? "");
|
|
11
|
+
// Count only sections actually present in the template, including repeated placeholders.
|
|
12
|
+
for (const match of template.matchAll(/\{\{\s*(context|skills|tools)\s*\}\}/g)) {
|
|
13
|
+
const name = match[1];
|
|
14
|
+
if (disabled.has(name))
|
|
15
|
+
continue;
|
|
16
|
+
const text = overrideOf(options.promptOverrides, name) || snapshot.texts[name] || "";
|
|
17
|
+
const category = name === "context" ? "memoryFiles" : name === "skills" ? "skills" : "tools";
|
|
18
|
+
weights[category] += estimatePromptTokens(text);
|
|
19
|
+
}
|
|
20
|
+
const prompt = estimatePromptTokens(snapshot.full);
|
|
21
|
+
const schema = estimatePromptTokens(snapshot.toolsSchema);
|
|
22
|
+
// Rounding individual sections can exceed the full prompt by a few tokens.
|
|
23
|
+
const sections = weights.memoryFiles + weights.skills + weights.tools;
|
|
24
|
+
if (sections > prompt) {
|
|
25
|
+
for (const category of ["memoryFiles", "skills", "tools"]) {
|
|
26
|
+
weights[category] = sections > 0 ? (weights[category] * prompt) / sections : 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
weights.systemPrompt = Math.max(0, prompt - Math.min(prompt, sections));
|
|
30
|
+
weights.tools += schema;
|
|
31
|
+
return { tokens: prompt + schema, weights };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Estimate proportions from live session messages, excluding compacted/branched-away entries.
|
|
35
|
+
* These are transcript weights, not an exact breakdown of a provider request: request-local
|
|
36
|
+
* deduplication, evidence externalization and extensions can change the submitted messages.
|
|
37
|
+
*/
|
|
38
|
+
export function estimateContextWeights(base, messages, streamingMessage, cache) {
|
|
39
|
+
const weights = { ...base };
|
|
40
|
+
const add = (value, settled = false) => {
|
|
41
|
+
if (!value || typeof value !== "object")
|
|
42
|
+
return;
|
|
43
|
+
// A former prefix may become the mutable tail after truncation; discard its old estimate.
|
|
44
|
+
if (!settled)
|
|
45
|
+
cache?.delete(value);
|
|
46
|
+
const cached = settled ? cache?.get(value) : undefined;
|
|
47
|
+
if (cached) {
|
|
48
|
+
for (const category of Object.keys(weights))
|
|
49
|
+
weights[category] += cached[category];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const contribution = emptyWeights();
|
|
53
|
+
const message = value;
|
|
54
|
+
if (message.role === "system")
|
|
55
|
+
return;
|
|
56
|
+
if (message.role === "toolResult") {
|
|
57
|
+
contribution[message.toolName === "skill" ? "skills" : "toolResults"] += estimateTokens(message);
|
|
58
|
+
}
|
|
59
|
+
else if (message.role === "bashExecution") {
|
|
60
|
+
contribution.toolResults += estimateTokens(message);
|
|
61
|
+
}
|
|
62
|
+
else if (message.role === "assistant" && Array.isArray(message.content)) {
|
|
63
|
+
const calls = message.content.filter((block) => block.type === "toolCall");
|
|
64
|
+
const prose = message.content.filter((block) => block.type !== "toolCall");
|
|
65
|
+
if (calls.length)
|
|
66
|
+
contribution.toolResults += estimateTokens({ ...message, content: calls });
|
|
67
|
+
if (prose.length)
|
|
68
|
+
contribution.messages += estimateTokens({ ...message, content: prose });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
contribution[message.role === "user" ? "messages" : "other"] += estimateTokens(message);
|
|
72
|
+
}
|
|
73
|
+
if (settled)
|
|
74
|
+
cache?.set(value, contribution);
|
|
75
|
+
for (const category of Object.keys(weights))
|
|
76
|
+
weights[category] += contribution[category];
|
|
77
|
+
};
|
|
78
|
+
// Agent-core appends message_end and clears streamingMessage before AgentSession awaits
|
|
79
|
+
// extensions, which may replace the final message in place. Cache only the earlier prefix.
|
|
80
|
+
const lastMessage = messages[messages.length - 1];
|
|
81
|
+
for (const message of messages)
|
|
82
|
+
add(message, message !== streamingMessage && message !== lastMessage);
|
|
83
|
+
if (streamingMessage && !messages.includes(streamingMessage))
|
|
84
|
+
add(streamingMessage);
|
|
85
|
+
return weights;
|
|
86
|
+
}
|
|
87
|
+
/** Keep the provider's total authoritative; integer allocation does not make the estimated proportions exact. */
|
|
88
|
+
export function reconcileContextCategories(weights, usedTokens) {
|
|
89
|
+
const total = Math.max(0, Math.round(Number.isFinite(usedTokens) ? usedTokens : 0));
|
|
90
|
+
const entries = Object.keys(weights).map((category) => ({
|
|
91
|
+
category,
|
|
92
|
+
tokens: Number.isFinite(weights[category]) ? Math.max(0, weights[category]) : 0,
|
|
93
|
+
}));
|
|
94
|
+
const sum = entries.reduce((n, row) => n + row.tokens, 0);
|
|
95
|
+
if (sum < total)
|
|
96
|
+
entries.find((row) => row.category === "other").tokens += total - sum;
|
|
97
|
+
const scale = sum > total ? total / sum : 1;
|
|
98
|
+
let assigned = 0;
|
|
99
|
+
const rows = entries.map((row) => {
|
|
100
|
+
const previous = assigned;
|
|
101
|
+
assigned += row.tokens * scale;
|
|
102
|
+
return { category: row.category, tokens: Math.round(assigned) - Math.round(previous) };
|
|
103
|
+
});
|
|
104
|
+
return rows.filter((row) => row.tokens > 0);
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
["index-
|
|
1
|
+
["index-DK3F5ZJo.js","BgTasksModal-BvnUHjFe.js","CanvasStudio-BSg9ghPV.js","DeviceCenter-Cl9MBXaH.js","DeviceGroups-aeLD2msl.js","Dropdown-D1Jl35dw.js","FilePreview-6CqoDF_P.js","GlobalSearchModal-CJX35rZL.js","GroupConversation-Cq4daBFb.js","ModelConfigModal-Bp7tfKYh.js","PiSetupModal-DD8srwBJ.js","ProviderOAuthControls-C6tfXb88.js","SCMPanel-D8-8aqwC.js","SettingsModal-qETiVPKj.js","TerminalPanel-DnS4tFQO.js","TuiOverlayModal-CGyGkKYl.js","app-globals-DcyO0UPi.js","desktop-7EvUHhKQ.js","es-DWMIuDU2.js","fi-NyN-ZrgD.js","markdown-BggnuQ4H.js","math-1uRJCsA9.js","plugin-host-BCnX3P8U.js","react-CR5VJ85Q.js","rolldown-runtime-hePW80VL.js","shortcut-stack-hhrDyRBn.js","theme-D2DMH6tH.js","uuid-BzDIGCwP.js","xterm-Cf5xxe4g.js","KaTeX_AMS-Regular-BQhdFMY1.woff2","KaTeX_AMS-Regular-DMm9YOAa.woff","KaTeX_AMS-Regular-DRggAlZN.ttf","KaTeX_Caligraphic-Bold-ATXxdsX0.ttf","KaTeX_Caligraphic-Bold-BEiXGLvX.woff","KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2","KaTeX_Caligraphic-Regular-CTRA-rTL.woff","KaTeX_Caligraphic-Regular-Di6jR-x-.woff2","KaTeX_Caligraphic-Regular-wX97UBjC.ttf","KaTeX_Fraktur-Bold-BdnERNNW.ttf","KaTeX_Fraktur-Bold-BsDP51OF.woff","KaTeX_Fraktur-Bold-CL6g_b3V.woff2","KaTeX_Fraktur-Regular-CB_wures.ttf","KaTeX_Fraktur-Regular-CTYiF6lA.woff2","KaTeX_Fraktur-Regular-Dxdc4cR9.woff","KaTeX_Main-Bold-Cx986IdX.woff2","KaTeX_Main-Bold-Jm3AIy58.woff","KaTeX_Main-Bold-waoOVXN0.ttf","KaTeX_Main-BoldItalic-DxDJ3AOS.woff2","KaTeX_Main-BoldItalic-DzxPMmG6.ttf","KaTeX_Main-BoldItalic-SpSLRI95.woff","KaTeX_Main-Italic-3WenGoN9.ttf","KaTeX_Main-Italic-BMLOBm91.woff","KaTeX_Main-Italic-NWA7e6Wa.woff2","KaTeX_Main-Regular-B22Nviop.woff2","KaTeX_Main-Regular-Dr94JaBh.woff","KaTeX_Main-Regular-ypZvNtVU.ttf","KaTeX_Math-BoldItalic-B3XSjfu4.ttf","KaTeX_Math-BoldItalic-CZnvNsCZ.woff2","KaTeX_Math-BoldItalic-iY-2wyZ7.woff","KaTeX_Math-Italic-DA0__PXp.woff","KaTeX_Math-Italic-flOr_0UB.ttf","KaTeX_Math-Italic-t53AETM-.woff2","KaTeX_SansSerif-Bold-CFMepnvq.ttf","KaTeX_SansSerif-Bold-D1sUS0GD.woff2","KaTeX_SansSerif-Bold-DbIhKOiC.woff","KaTeX_SansSerif-Italic-C3H0VqGB.woff2","KaTeX_SansSerif-Italic-DN2j7dab.woff","KaTeX_SansSerif-Italic-YYjJ1zSn.ttf","KaTeX_SansSerif-Regular-BNo7hRIc.ttf","KaTeX_SansSerif-Regular-CS6fqUqJ.woff","KaTeX_SansSerif-Regular-DDBCnlJ7.woff2","KaTeX_Script-Regular-C5JkGWo-.ttf","KaTeX_Script-Regular-D3wIWfF6.woff2","KaTeX_Script-Regular-D5yQViql.woff","KaTeX_Size1-Regular-C195tn64.woff","KaTeX_Size1-Regular-Dbsnue_I.ttf","KaTeX_Size1-Regular-mCD8mA8B.woff2","KaTeX_Size2-Regular-B7gKUWhC.ttf","KaTeX_Size2-Regular-Dy4dx90m.woff2","KaTeX_Size2-Regular-oD1tc_U0.woff","KaTeX_Size3-Regular-CTq5MqoE.woff","KaTeX_Size3-Regular-DgpXs0kz.ttf","KaTeX_Size4-Regular-BF-4gkZK.woff","KaTeX_Size4-Regular-DWFBv043.ttf","KaTeX_Size4-Regular-Dl5lxZxV.woff2","KaTeX_Typewriter-Regular-C0xS9mPB.woff","KaTeX_Typewriter-Regular-CO6r4hn1.woff2","KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf","index-vwBnwzkr.css","markdown-C8LL_u4z.css","math-BorAY7qD.css","xterm-B1njb2Cr.css"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n,Lt as r,Tt as i,Yt as a,an as o,at as s,rn as c}from"./fi-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n,Lt as r,Tt as i,Yt as a,an as o,at as s,rn as c}from"./fi-NyN-ZrgD.js";import{i as l,t as u}from"./react-CR5VJ85Q.js";import{t as d}from"./app-globals-DcyO0UPi.js";import{Ct as f,G as p,Ot as m,jt as h}from"./index-DK3F5ZJo.js";var g=e(l(),1),_=u();function v(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/6e4);if(r<1)return t(`bgTaskJustNow`);if(r<60)return t(`bgTaskMinutes`,{n:r});let i=Math.floor(r/60);return i<24?t(`bgTaskHours`,{n:i}):t(`bgTaskDays`,{n:Math.floor(i/24)})}function y({servers:e,onClose:l,plugins:u=[],epoch:y=0,send:b,onUiAction:x,autoCleanupMin:S=0}){let C=o(),{locale:w}=c(),[T,E]=(0,g.useState)(new Set),D=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});(0,g.useEffect)(()=>{d({type:`list_bg_servers`})},[]);let O=(0,g.useMemo)(()=>(m(h(u),{locale:w,t:e=>C(e)})[`tasks.panel`]??[]).filter(e=>!e.hidden&&e.source!==`host`&&e.kind!==`divider`),[u,w,C]);return(0,_.jsxs)(f,{className:`bg-task-modal`,onClose:l,showCloseButton:!1,children:[(0,_.jsxs)(`div`,{className:`bg-task-head`,children:[(0,_.jsxs)(`span`,{className:`bg-task-title`,children:[(0,_.jsx)(s,{}),` `,C(`bgTasks`),e.length>0&&(0,_.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,_.jsxs)(`div`,{className:`bg-task-head-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-head-btn`,title:C(`bgTaskRefresh`),onClick:()=>d({type:`list_bg_servers`}),children:(0,_.jsx)(i,{})}),(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-head-btn`,title:C(`close`),onClick:l,children:(0,_.jsx)(a,{})})]})]}),e.length===0?(0,_.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,_.jsx)(s,{}),(0,_.jsx)(`span`,{children:C(`bgTasksEmpty`)}),(0,_.jsx)(`small`,{children:C(`bgTasksDesc`)})]}):(0,_.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let n=!!e.taskId,i=e.taskId??String(e.port);return(0,_.jsxs)(`li`,{className:`bg-task-item`,children:[(0,_.jsx)(`span`,{className:`bg-task-icon`,title:n?e.plugin:C(`bgTaskPort`)}),(0,_.jsxs)(`div`,{className:`bg-task-info`,children:[(0,_.jsxs)(`div`,{className:`bg-task-line1`,children:[n?(0,_.jsxs)(`span`,{className:`bg-task-port`,title:e.taskId,children:[`🧩 `,e.plugin]}):(0,_.jsxs)(`span`,{className:`bg-task-port`,children:[`:`,e.port]}),e.name&&(0,_.jsx)(`span`,{className:`bg-task-name`,children:e.name})]}),(0,_.jsxs)(`div`,{className:`bg-task-line2`,children:[!n&&(0,_.jsxs)(`span`,{children:[C(`bgTaskPid`),` `,e.pid]}),(0,_.jsxs)(`span`,{children:[C(`bgTaskSince`),` `,v(e.since,C)]}),n&&e.status&&(0,_.jsx)(`span`,{className:`bg-task-status`,children:e.status})]}),e.command&&(0,_.jsxs)(`button`,{type:`button`,className:`bg-task-cmd ${T.has(i)?`open`:``}`,title:`${C(`bgTaskCommand`)}: ${e.command}`,onClick:()=>D(i),children:[(0,_.jsx)(t,{}),(0,_.jsx)(`code`,{children:e.command})]})]}),!n&&(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-keep`,title:e.keep?C(`bgTaskKeepOn`):C(`bgTaskKeep`),"aria-pressed":!!e.keep,onClick:()=>d({type:`set_bg_keep`,port:e.port??0,keep:!e.keep}),children:e.keep?`📌`:`📍`}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:C(`bgTaskStop`),onClick:()=>d(n?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,_.jsx)(r,{}),(0,_.jsx)(`span`,{children:C(`bgTaskStop`)})]})]},i)})}),O.map(e=>{let t=u.find(t=>t.id===e.source.slice(7));return e.kind===`view`?t?(0,_.jsx)(`div`,{children:(0,_.jsx)(p,{plugin:t,epoch:y,send:b??(()=>{})})},e.id):null:(0,_.jsx)(`button`,{type:`button`,className:`btn`,title:e.hint??e.label,onClick:()=>x?.(e),children:e.label},e.id)}),(0,_.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,_.jsxs)(`div`,{className:`bg-task-cleanup-bar`,children:[(0,_.jsxs)(`label`,{className:`bg-task-cleanup-field`,title:C(`bgTaskCleanupHint`),children:[(0,_.jsx)(`span`,{className:`bg-task-cleanup-label`,children:C(`bgTaskCleanup`)}),(0,_.jsxs)(`select`,{className:`bg-task-cleanup-select`,value:String(S),onChange:e=>d({type:`set_settings`,bgAutoCleanupMin:Number(e.target.value)}),children:[(0,_.jsx)(`option`,{value:`0`,children:C(`bgTaskCleanupOff`)}),[15,30,60,120].map(e=>(0,_.jsx)(`option`,{value:String(e),children:C(`bgTaskCleanupMinutes`,{n:e})},e))]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-clean-btn`,title:C(`bgTaskCleanNowHint`),onClick:()=>d({type:`clean_bg_leftovers`}),children:[(0,_.jsx)(n,{}),(0,_.jsx)(`span`,{children:C(`bgTaskCleanNow`)})]})]}),(0,_.jsxs)(`div`,{className:`bg-task-actions-bar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-refresh-btn`,title:C(`bgTaskRefresh`),onClick:()=>d({type:`list_bg_servers`}),children:[(0,_.jsx)(i,{}),(0,_.jsx)(`span`,{children:C(`bgTaskRefresh`)})]}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:C(`bgTaskStopAll`),onClick:()=>d({type:`kill_background_servers`}),children:[(0,_.jsx)(r,{}),(0,_.jsx)(`span`,{children:C(`bgTaskStopAll`)})]})]})]})]})}export{y as BgTasksModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n,Lt as r,Tt as i,Yt as a,an as o,at as s,rn as c}from"./fi-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n,Lt as r,Tt as i,Yt as a,an as o,at as s,rn as c}from"./fi-NyN-ZrgD.js";import{i as l,t as u}from"./react-CR5VJ85Q.js";import{t as d}from"./app-globals-DcyO0UPi.js";import{Ct as f,G as p,Ot as m,jt as h}from"./index-DQMii2he.js";var g=e(l(),1),_=u();function v(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/6e4);if(r<1)return t(`bgTaskJustNow`);if(r<60)return t(`bgTaskMinutes`,{n:r});let i=Math.floor(r/60);return i<24?t(`bgTaskHours`,{n:i}):t(`bgTaskDays`,{n:Math.floor(i/24)})}function y({servers:e,onClose:l,plugins:u=[],epoch:y=0,send:b,onUiAction:x,autoCleanupMin:S=0}){let C=o(),{locale:w}=c(),[T,E]=(0,g.useState)(new Set),D=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});(0,g.useEffect)(()=>{d({type:`list_bg_servers`})},[]);let O=(0,g.useMemo)(()=>(m(h(u),{locale:w,t:e=>C(e)})[`tasks.panel`]??[]).filter(e=>!e.hidden&&e.source!==`host`&&e.kind!==`divider`),[u,w,C]);return(0,_.jsxs)(f,{className:`bg-task-modal`,onClose:l,showCloseButton:!1,children:[(0,_.jsxs)(`div`,{className:`bg-task-head`,children:[(0,_.jsxs)(`span`,{className:`bg-task-title`,children:[(0,_.jsx)(s,{}),` `,C(`bgTasks`),e.length>0&&(0,_.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,_.jsxs)(`div`,{className:`bg-task-head-actions`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-head-btn`,title:C(`bgTaskRefresh`),onClick:()=>d({type:`list_bg_servers`}),children:(0,_.jsx)(i,{})}),(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-head-btn`,title:C(`close`),onClick:l,children:(0,_.jsx)(a,{})})]})]}),e.length===0?(0,_.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,_.jsx)(s,{}),(0,_.jsx)(`span`,{children:C(`bgTasksEmpty`)}),(0,_.jsx)(`small`,{children:C(`bgTasksDesc`)})]}):(0,_.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let n=!!e.taskId,i=e.taskId??String(e.port);return(0,_.jsxs)(`li`,{className:`bg-task-item`,children:[(0,_.jsx)(`span`,{className:`bg-task-icon`,title:n?e.plugin:C(`bgTaskPort`)}),(0,_.jsxs)(`div`,{className:`bg-task-info`,children:[(0,_.jsxs)(`div`,{className:`bg-task-line1`,children:[n?(0,_.jsxs)(`span`,{className:`bg-task-port`,title:e.taskId,children:[`🧩 `,e.plugin]}):(0,_.jsxs)(`span`,{className:`bg-task-port`,children:[`:`,e.port]}),e.name&&(0,_.jsx)(`span`,{className:`bg-task-name`,children:e.name})]}),(0,_.jsxs)(`div`,{className:`bg-task-line2`,children:[!n&&(0,_.jsxs)(`span`,{children:[C(`bgTaskPid`),` `,e.pid]}),(0,_.jsxs)(`span`,{children:[C(`bgTaskSince`),` `,v(e.since,C)]}),n&&e.status&&(0,_.jsx)(`span`,{className:`bg-task-status`,children:e.status})]}),e.command&&(0,_.jsxs)(`button`,{type:`button`,className:`bg-task-cmd ${T.has(i)?`open`:``}`,title:`${C(`bgTaskCommand`)}: ${e.command}`,onClick:()=>D(i),children:[(0,_.jsx)(t,{}),(0,_.jsx)(`code`,{children:e.command})]})]}),!n&&(0,_.jsx)(`button`,{type:`button`,className:`btn bg-task-keep`,title:e.keep?C(`bgTaskKeepOn`):C(`bgTaskKeep`),"aria-pressed":!!e.keep,onClick:()=>d({type:`set_bg_keep`,port:e.port??0,keep:!e.keep}),children:e.keep?`📌`:`📍`}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:C(`bgTaskStop`),onClick:()=>d(n?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,_.jsx)(r,{}),(0,_.jsx)(`span`,{children:C(`bgTaskStop`)})]})]},i)})}),O.map(e=>{let t=u.find(t=>t.id===e.source.slice(7));return e.kind===`view`?t?(0,_.jsx)(`div`,{children:(0,_.jsx)(p,{plugin:t,epoch:y,send:b??(()=>{})})},e.id):null:(0,_.jsx)(`button`,{type:`button`,className:`btn`,title:e.hint??e.label,onClick:()=>x?.(e),children:e.label},e.id)}),(0,_.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,_.jsxs)(`div`,{className:`bg-task-cleanup-bar`,children:[(0,_.jsxs)(`label`,{className:`bg-task-cleanup-field`,title:C(`bgTaskCleanupHint`),children:[(0,_.jsx)(`span`,{className:`bg-task-cleanup-label`,children:C(`bgTaskCleanup`)}),(0,_.jsxs)(`select`,{className:`bg-task-cleanup-select`,value:String(S),onChange:e=>d({type:`set_settings`,bgAutoCleanupMin:Number(e.target.value)}),children:[(0,_.jsx)(`option`,{value:`0`,children:C(`bgTaskCleanupOff`)}),[15,30,60,120].map(e=>(0,_.jsx)(`option`,{value:String(e),children:C(`bgTaskCleanupMinutes`,{n:e})},e))]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-clean-btn`,title:C(`bgTaskCleanNowHint`),onClick:()=>d({type:`clean_bg_leftovers`}),children:[(0,_.jsx)(n,{}),(0,_.jsx)(`span`,{children:C(`bgTaskCleanNow`)})]})]}),(0,_.jsxs)(`div`,{className:`bg-task-actions-bar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-refresh-btn`,title:C(`bgTaskRefresh`),onClick:()=>d({type:`list_bg_servers`}),children:[(0,_.jsx)(i,{}),(0,_.jsx)(`span`,{children:C(`bgTaskRefresh`)})]}),(0,_.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:C(`bgTaskStopAll`),onClick:()=>d({type:`kill_background_servers`}),children:[(0,_.jsx)(r,{}),(0,_.jsx)(`span`,{children:C(`bgTaskStopAll`)})]})]})]})]})}export{y as BgTasksModal};
|