mirror of
https://github.com/hansjone/mind-map.git
synced 2026-10-08 23:33:24 +08:00
fix: manual mind-map open shows roster; only AI auto-enters canvas
Stop restoring last canvas from sessionStorage/sticky meta on open. Manual +/sidebar open clears live canvas and shows the list; AI pendingEnter / fresh meta.enter still jumps straight into the map. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b23959400d
commit
b336ad5a4c
1 changed files with 22 additions and 37 deletions
|
|
@ -77,7 +77,7 @@ window.__ModuleLoader__.load({
|
||||||
autoStart: '随 DSH 自动启动画布服务',
|
autoStart: '随 DSH 自动启动画布服务',
|
||||||
open: '打开思维导图 Tab',
|
open: '打开思维导图 Tab',
|
||||||
opening: '打开中…',
|
opening: '打开中…',
|
||||||
hint: '侧栏打开「思维导图」先看到画布名册;点名称进入。AI 新建、打开或查图时会自动展开右侧画布。',
|
hint: '侧栏打开「思维导图」先看到画布名册;点名称进入。AI 新建、打开或查图时会自动进入对应画布。',
|
||||||
save: '保存',
|
save: '保存',
|
||||||
saving: '保存中…',
|
saving: '保存中…',
|
||||||
discard: '放弃',
|
discard: '放弃',
|
||||||
|
|
@ -106,7 +106,7 @@ window.__ModuleLoader__.load({
|
||||||
autoStart: 'Start canvas server with DSH',
|
autoStart: 'Start canvas server with DSH',
|
||||||
open: 'Open mind-map tab',
|
open: 'Open mind-map tab',
|
||||||
opening: 'Opening…',
|
opening: 'Opening…',
|
||||||
hint: 'Open Mind Map from the sidebar to see the canvas roster first. AI create opens a new canvas and does not overwrite old ones.',
|
hint: 'Open Mind Map from the sidebar to see the canvas roster first. AI create/open/query jumps into that canvas automatically.',
|
||||||
save: 'Save',
|
save: 'Save',
|
||||||
saving: 'Saving…',
|
saving: 'Saving…',
|
||||||
discard: 'Discard',
|
discard: 'Discard',
|
||||||
|
|
@ -313,7 +313,10 @@ window.__ModuleLoader__.load({
|
||||||
const sessionId =
|
const sessionId =
|
||||||
props.scope && props.scope.sessionId != null ? String(props.scope.sessionId) : ''
|
props.scope && props.scope.sessionId != null ? String(props.scope.sessionId) : ''
|
||||||
const meta = props.tab && props.tab.meta && typeof props.tab.meta === 'object' ? props.tab.meta : {}
|
const meta = props.tab && props.tab.meta && typeof props.tab.meta === 'object' ? props.tab.meta : {}
|
||||||
// Restore: pending AI enter → fresh meta.enter → last canvas in sessionStorage → roster.
|
// Boot policy (manual vs AI):
|
||||||
|
// - AI pendingEnter / fresh meta.enter → open that canvas
|
||||||
|
// - liveCanvasId already set → panel remount while staying on a map (tab switch)
|
||||||
|
// - otherwise → roster (manual click on 思维导图 must NOT auto-open last map)
|
||||||
const boot = (() => {
|
const boot = (() => {
|
||||||
const p = pendingEnter
|
const p = pendingEnter
|
||||||
if (p && Date.now() - p.at < 30000) {
|
if (p && Date.now() - p.at < 30000) {
|
||||||
|
|
@ -337,23 +340,17 @@ window.__ModuleLoader__.load({
|
||||||
title: meta.title || 'Mind Map',
|
title: meta.title || 'Mind Map',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Tab meta often keeps canvasId with enter:false after enterCanvas — still restore.
|
// Remount while already viewing a canvas (tab strip focus) — keep it.
|
||||||
if (meta.canvasId) {
|
if (liveCanvasId) {
|
||||||
liveCanvasId = String(meta.canvasId)
|
const last = readLastCanvas()
|
||||||
writeLastCanvas(meta.canvasId, meta.title)
|
const title =
|
||||||
|
(last && last.canvasId === liveCanvasId && last.title) ||
|
||||||
|
meta.title ||
|
||||||
|
'Mind Map'
|
||||||
return {
|
return {
|
||||||
view: 'canvas',
|
view: 'canvas',
|
||||||
canvasId: String(meta.canvasId),
|
canvasId: String(liveCanvasId),
|
||||||
title: meta.title || 'Mind Map',
|
title: String(title),
|
||||||
}
|
|
||||||
}
|
|
||||||
const last = readLastCanvas()
|
|
||||||
if (last && last.canvasId) {
|
|
||||||
liveCanvasId = String(last.canvasId)
|
|
||||||
return {
|
|
||||||
view: 'canvas',
|
|
||||||
canvasId: String(last.canvasId),
|
|
||||||
title: last.title || 'Mind Map',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { view: 'roster', canvasId: '', title: '' }
|
return { view: 'roster', canvasId: '', title: '' }
|
||||||
|
|
@ -1133,28 +1130,16 @@ window.__ModuleLoader__.load({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
onOpen: () => {
|
onOpen: () => {
|
||||||
// AI jump in progress — leave panel alone.
|
// AI jump in progress — leave panel alone (auto-enter that canvas).
|
||||||
if (Date.now() < aiJumpUntil || pendingEnter) return
|
if (Date.now() < aiJumpUntil || pendingEnter) return
|
||||||
// Already inside a canvas (or restoring one) — never bounce to roster.
|
// Manual open from + / sidebar: always land on roster.
|
||||||
if (liveCanvasId) return
|
// (Do not restore sessionStorage / sticky meta — that fought AI auto-enter UX.)
|
||||||
const last = readLastCanvas()
|
liveCanvasId = ''
|
||||||
if (last && last.canvasId) {
|
clearLastCanvas()
|
||||||
markAiJump({ canvasId: last.canvasId, title: last.title })
|
|
||||||
window.dispatchEvent(
|
|
||||||
new CustomEvent('dsh-mind-map:open', {
|
|
||||||
detail: {
|
|
||||||
canvasId: last.canvasId,
|
|
||||||
title: last.title || zh.tabTitle,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// True first open from + menu with no prior canvas → roster.
|
|
||||||
window.dispatchEvent(new CustomEvent('dsh-mind-map:show-roster'))
|
window.dispatchEvent(new CustomEvent('dsh-mind-map:show-roster'))
|
||||||
},
|
},
|
||||||
// Do NOT roster on onActivate: tab-strip switch / single:true focus
|
// Do NOT roster on onActivate: tab-strip switch must keep the open canvas.
|
||||||
// must keep the open canvas. Use ← 列表 to leave a map.
|
// Use ← 列表 or open the feature again to see the roster.
|
||||||
component: (props) => h(MindmapTabPanel, props),
|
component: (props) => h(MindmapTabPanel, props),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue