fix(panel): allocate isolated UUIDs in session full-move mode to prevent cross-client mirror deletion

This commit is contained in:
fish
2026-11-22 03:24:10 +09:00
parent c6025704c1
commit 7df9108692
6 changed files with 303 additions and 94 deletions
+25 -41
View File
@@ -1827,7 +1827,7 @@ const I18N_MESSAGES_ZH_CN = Object.freeze({
'settings.oth.migModeLabel': '迁移方式',
'settings.oth.migModeMove': '完整迁移(推荐)',
'settings.oth.migModeClone': '克隆副本',
'settings.oth.migModeMoveHint': '保留原 ID 和全部历史步序明细,备份后移出源端(零重复计费)',
'settings.oth.migModeMoveHint': '分配目标端独立会话 ID 并完整保留全部历史步序明细,备份后移出源端(零重复计费;迁移前建议先关闭源端该会话)',
'settings.oth.migModeCloneHint': '保留源会话并生成新 ID,新副本仅统计迁入后的新步骤',
'settings.oth.migProjectLabel': '绑定目标项目',
'settings.oth.migProjectOutside': '独立会话(无所属项目)',
@@ -2624,7 +2624,7 @@ const I18N_MESSAGES_EN_US = Object.freeze({
'settings.oth.migModeLabel': 'Migration Mode',
'settings.oth.migModeMove': 'Full Move (Recommended)',
'settings.oth.migModeClone': 'Clone Copy',
'settings.oth.migModeMoveHint': 'Preserves original ID and full historical steps/details; archives source backup before moving',
'settings.oth.migModeMoveHint': 'Assigns an isolated target ID while preserving all historical steps/details; archives source backup before moving (close source session first)',
'settings.oth.migModeCloneHint': 'Keeps source intact with a fresh UUID; only counts new steps generated after cloning',
'settings.oth.migProjectLabel': 'Target Project',
'settings.oth.migProjectOutside': 'Standalone (No Project)',
@@ -21856,87 +21856,74 @@ function isSameList(a, b) {
return true;
}
function buildCliPreviewMiniBar(pct, width = 8, emptyChar = '⢕') {
const clamped = Math.max(0, Math.min(100, Number(pct)));
let filled = Math.round((clamped / 100) * width);
if (clamped > 0 && filled === 0) filled = 1;
if (clamped < 95 && filled >= width) filled = Math.max(0, width - 1);
return {
barFilled: '█'.repeat(filled),
barEmpty: emptyChar.repeat(Math.max(0, width - filled)),
};
}
function formatCliPreviewSlot(slotKey, isEn) {
switch (slotKey) {
case 'tps':
return { prefix: '', barFilled: '', barEmpty: '', text: '68.4 t/s', tone: 'good' };
return { prefix: '', text: '68.4 t/s', tone: 'good', pillPct: null };
case 'avg_tps':
return {
prefix: '',
barFilled: '',
barEmpty: '',
text: isEn ? 'avg 54.0' : '均 54.0',
tone: 'info',
pillPct: null,
};
case 'ttft':
return { prefix: '', barFilled: '', barEmpty: '', text: '1.1s', tone: 'good' };
return { prefix: '', text: '1.1s', tone: 'good', pillPct: null };
case 'cost':
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.040', tone: 'normal' };
return { prefix: '', text: '$0.040', tone: 'normal', pillPct: null };
case 'session_cost':
return { prefix: '', barFilled: '', barEmpty: '', text: '$0.42', tone: 'normal' };
return { prefix: '', text: '$0.42', tone: 'normal', pillPct: null };
case 'cache_hit':
return {
prefix: '',
barFilled: '',
barEmpty: '',
text: isEn ? 'cache 92%' : '缓 92%',
tone: 'good',
pillPct: null,
};
case 'session_tokens':
return { prefix: '', barFilled: '', barEmpty: '', text: '142K tok', tone: 'muted' };
return { prefix: '', text: '142K tok', tone: 'muted', pillPct: null };
case 'quota_auto':
return {
prefix: isEn ? '5h ' : '余 ',
...buildCliPreviewMiniBar(64, 8, '⣿'),
text: ' 64%',
text: '64%',
tone: 'good',
pillPct: 64,
};
case 'gemini_5h':
return {
prefix: 'G5h ',
...buildCliPreviewMiniBar(64, 8, '⣿'),
text: ' 64%',
text: '64%',
tone: 'good',
pillPct: 64,
};
case 'gemini_weekly':
return {
prefix: isEn ? 'Gw ' : 'G周 ',
...buildCliPreviewMiniBar(88, 8, '⣿'),
text: ' 88%',
text: '88%',
tone: 'good',
pillPct: 88,
};
case 'claude_5h':
return {
prefix: 'C5h ',
...buildCliPreviewMiniBar(96, 8, '⣿'),
text: ' 96%',
text: '96%',
tone: 'good',
pillPct: 96,
};
case 'claude_weekly':
return {
prefix: isEn ? 'Cw ' : 'C周 ',
...buildCliPreviewMiniBar(99, 8, '⣿'),
text: ' 99%',
text: '99%',
tone: 'good',
pillPct: 99,
};
case 'context':
default:
return {
prefix: isEn ? 'Ctx ' : '上下文 ',
...buildCliPreviewMiniBar(56),
text: ' 56%',
text: '56%',
tone: 'accent',
pillPct: 56,
};
}
}
@@ -22256,16 +22243,12 @@ const SettingsStructureTab = defineComponent({
cliPreviewChildren.push(sepEl);
}
const prefixEl = h('span', { className: 'cli-preview-prefix' });
const barFillEl = h('span', { className: 'cli-preview-bar-fill' });
const barEmptyEl = h('span', { className: 'cli-preview-bar-empty' });
const valueEl = h('span', { className: 'cli-preview-val' });
const slotEl = h('span', { className: 'cli-preview-slot' }, [
prefixEl,
barFillEl,
barEmptyEl,
valueEl,
]);
cliPreviewSlotParts.push({ slotEl, prefixEl, barFillEl, barEmptyEl, valueEl });
cliPreviewSlotParts.push({ slotEl, prefixEl, valueEl });
cliPreviewChildren.push(slotEl);
}
const cliPreviewEl = h('div', { className: 'cli-status-preview' }, cliPreviewChildren);
@@ -22398,12 +22381,13 @@ const SettingsStructureTab = defineComponent({
if (sepEl) patchAttr(sepEl, 'hidden', !visible);
if (visible) {
const item = formatCliPreviewSlot(key, isEn);
const isPill = Number.isFinite(item.pillPct);
patchAttr(parts.slotEl, 'data-metric', key);
patchText(parts.prefixEl, item.prefix || '');
patchText(parts.barFillEl, item.barFilled || '');
patchText(parts.barEmptyEl, item.barEmpty || '');
patchText(parts.valueEl, item.text || '');
patchStyleVar(parts.slotEl, '--cli-pill-pct', isPill ? `${item.pillPct}%` : '');
patchClasses(parts.slotEl, {
'is-pill': isPill,
'tone-good': item.tone === 'good',
'tone-info': item.tone === 'info',
'tone-accent': item.tone === 'accent',