refactor(panel): extract sqlite/wire primitives, localize charts & structured status, and unify overlay/mock-dom (P2)

This commit is contained in:
fish
2026-11-18 18:46:53 +09:00
parent 1459240751
commit a954a98080
26 changed files with 3393 additions and 3418 deletions
@@ -13,7 +13,7 @@ import {
patchKeyedList,
patchText,
} from '../../core/domPatch.js';
import { getEffectiveLocale, isEnglishLocale, t } from '../../i18n/index.js';
import { getEffectiveLocale, t } from '../../i18n/index.js';
import {
DEFAULT_STEP_COLUMN_KEYS,
STEP_COLUMN_REGISTRY,
@@ -25,14 +25,11 @@ import {
normalizeClientStepTokenComboFormat,
} from '../../store/telemetryStore.js';
export function formatTurnPromptText(rawPrompt) {
export function formatTurnPromptText(rawPrompt, { hasMedia = false, mediaOnly = false } = {}) {
const text = String(rawPrompt || '').trim();
if (!text || !isEnglishLocale()) return text;
if (text === '[图片/附件提问]') return t('steps.turnMediaOnly');
if (text.endsWith(' [附图]')) {
return `${text.slice(0, -5)} ${t('steps.turnMediaSuffix')}`;
}
return text;
if (mediaOnly || (!text && hasMedia)) return t('steps.turnMediaOnly');
if (!text) return '';
return hasMedia ? `${text} ${t('steps.turnMediaSuffix')}` : text;
}
export const StepTableWidget = defineComponent({
@@ -212,7 +209,13 @@ export const StepTableWidget = defineComponent({
const getStepIsLatest = (st) =>
Boolean(useRootTurn ? (st?.isRootLatestTurn ?? st?.isLatestTurn) : st?.isLatestTurn);
const getStepPrompt = (st) =>
(useRootTurn ? (st?.rootTurnPrompt ?? st?.turnPrompt) : st?.turnPrompt) || '';
(useRootTurn
? (st?.rootTurnPromptClean ?? st?.rootTurnPrompt ?? st?.turnPromptClean ?? st?.turnPrompt)
: (st?.turnPromptClean ?? st?.turnPrompt)) || '';
const getStepHasMedia = (st) =>
Boolean(useRootTurn ? (st?.rootTurnHasMedia ?? st?.turnHasMedia) : st?.turnHasMedia);
const getStepMediaOnly = (st) =>
Boolean(useRootTurn ? (st?.rootTurnMediaOnly ?? st?.turnMediaOnly) : st?.turnMediaOnly);
const turnKeys = showStepTurnRail ? tableSteps.map((st) => {
const tIdx = getStepTurnIdx(st);
if (!Number.isInteger(tIdx) || tIdx <= 0) return '';
@@ -221,8 +224,13 @@ export const StepTableWidget = defineComponent({
const formattedPrompts = new Map();
function formattedTurnPrompt(st) {
const raw = getStepPrompt(st);
if (!formattedPrompts.has(raw)) formattedPrompts.set(raw, formatTurnPromptText(raw));
return formattedPrompts.get(raw);
const hasMedia = getStepHasMedia(st);
const mediaOnly = getStepMediaOnly(st);
const cacheKey = `${mediaOnly ? 2 : hasMedia ? 1 : 0}:${raw}`;
if (!formattedPrompts.has(cacheKey)) {
formattedPrompts.set(cacheKey, formatTurnPromptText(raw, { hasMedia, mediaOnly }));
}
return formattedPrompts.get(cacheKey);
}
const decoratedSteps = tableSteps.map((st, idx) => {
@@ -344,28 +352,38 @@ export const StepTableWidget = defineComponent({
const badgeCls = getAgentBadgeClass(st.agentIndex || 0, !st.isSubagent);
const clickableCls = interactiveBadges && onSelectAgentScopes ? ' is-clickable' : '';
patchAttr(refs.agentBadgeEl, 'class', `agent-badge${clickableCls} ${badgeCls}`);
const badgeText = isEnglishLocale()
? formatAgentBadgeText({
isMain: !st.isSubagent,
isSideQuestion: Boolean(st.isSideQuestion),
sideIndex: st.sideIndex || 0,
index: st.agentIndex || 0,
badgeText: st.agentBadge,
})
: st.agentBadge || (st.isSideQuestion ? '旁' : st.isSubagent ? '子' : '主');
const badgeText = formatAgentBadgeText({
agentKind:
st.agentKind ||
(!st.isSubagent ? 'main' : st.isSideQuestion ? 'side_question' : 'subagent'),
agentOrdinal:
st.agentOrdinal || (st.isSideQuestion ? st.sideIndex || 0 : st.agentIndex || 0),
isMain: !st.isSubagent,
isSideQuestion: Boolean(st.isSideQuestion),
sideIndex: st.sideIndex || 0,
index: st.agentIndex || 0,
badgeText: st.agentBadge,
});
patchText(refs.agentBadgeEl, badgeText);
if (interactiveBadges && onSelectAgentScopes) {
const targetScope = st.agentId || 'main';
const isSoleTarget =
effectiveScopes.length === 1 && effectiveScopes[0] === targetScope;
const agentName = isEnglishLocale()
? formatAgentLabel({
isMain: !st.isSubagent,
index: st.agentIndex || 0,
role: st.agentRole || '',
})
: st.agentLabel || t('steps.unitAgent');
const agentName = formatAgentLabel({
agentKind:
st.agentKind ||
(!st.isSubagent ? 'main' : st.isSideQuestion ? 'side_question' : 'subagent'),
agentOrdinal:
st.agentOrdinal || (st.isSideQuestion ? st.sideIndex || 0 : st.agentIndex || 0),
customRole: st.agentCustomRole,
isMain: !st.isSubagent,
isSideQuestion: Boolean(st.isSideQuestion),
sideIndex: st.sideIndex || 0,
index: st.agentIndex || 0,
role: st.agentRole || '',
shortLabel: st.agentLabel || '',
});
patchAttr(
refs.agentBadgeEl,
'title',