@wendongfly/myhi 1.3.108 → 1.3.109
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/dist/grid.html +16 -2
- package/package.json +1 -1
package/dist/grid.html
CHANGED
|
@@ -83,12 +83,24 @@
|
|
|
83
83
|
return { layout: 'auto', panes: [] };
|
|
84
84
|
}
|
|
85
85
|
function saveState() {
|
|
86
|
-
|
|
86
|
+
// 存【稳定标识】而不是易变 id——myhi 会话 id 每次重启都重新 randomUUID,存 id 重启后必失效
|
|
87
|
+
state.panes = paneEls.map(p => p._key || null);
|
|
87
88
|
localStorage.setItem(LS_KEY, JSON.stringify(state));
|
|
88
89
|
}
|
|
89
90
|
function esc(s){ return String(s==null?'':s).replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); }
|
|
90
91
|
function sName(s){ return s.title || s.name || s.summary || (s.id||s.sessionId||'').slice(0,12) || '未命名'; }
|
|
91
92
|
function sId(s){ return s.id || s.sessionId; }
|
|
93
|
+
function sessById(id){ return sessions.find(s => sId(s) === id); }
|
|
94
|
+
// 稳定标识:claudeSessionId(agent 会话,--resume 用,重启不变) / createdAt(持久化,稳定)
|
|
95
|
+
function keyOf(s){ return s ? { cid: s.claudeSessionId || null, createdAt: s.createdAt || null, cwd: s.cwd || null } : null; }
|
|
96
|
+
// 把稳定标识映射回【当前】会话 id(重启后 id 变了也能找回同一个会话);找不到返回 ''
|
|
97
|
+
function resolveKey(key){
|
|
98
|
+
if (!key) return '';
|
|
99
|
+
if (typeof key === 'string') return sessById(key) ? key : ''; // 兼容旧格式(曾直接存 id)
|
|
100
|
+
for (const s of sessions) if (key.cid && s.claudeSessionId && s.claudeSessionId === key.cid) return sId(s);
|
|
101
|
+
for (const s of sessions) if (key.createdAt && s.createdAt === key.createdAt && (!key.cwd || s.cwd === key.cwd)) return sId(s);
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
92
104
|
|
|
93
105
|
// ── 布局 ──
|
|
94
106
|
function applyLayout() {
|
|
@@ -142,6 +154,7 @@
|
|
|
142
154
|
}
|
|
143
155
|
function setPaneSession(pane, sid, keepSelect) {
|
|
144
156
|
pane._sid = sid || '';
|
|
157
|
+
pane._key = sid ? keyOf(sessById(sid)) : null; // 记住稳定标识,供重启后找回
|
|
145
158
|
if (!keepSelect) pane._sel.value = sid || '';
|
|
146
159
|
// 只重建这一格的 iframe,其它格不受影响
|
|
147
160
|
if (pane._iframe) { pane._iframe.remove(); pane._iframe = null; }
|
|
@@ -181,7 +194,8 @@
|
|
|
181
194
|
(async function init() {
|
|
182
195
|
await refreshSessions(false);
|
|
183
196
|
const initial = (state.panes && state.panes.length) ? state.panes : [];
|
|
184
|
-
|
|
197
|
+
// 用稳定标识映射回当前 id;找不到→空格(可下拉重选),不再加载死会话报「未找到」
|
|
198
|
+
for (const key of initial) addPane(resolveKey(key), true);
|
|
185
199
|
applyLayout();
|
|
186
200
|
})();
|
|
187
201
|
</script>
|
package/package.json
CHANGED