MCPcopy Create free account
hub / github.com/experdot/pointer / navigateToMessage

Function navigateToMessage

src/renderer/src/services/navigationService.ts:27–60  ·  view source on GitHub ↗
(target: NavigationTarget)

Source from the content-addressed store, hash-verified

25 * 完整流程:打开页面 → (仅在需要时)切换分支 → 展开折叠的 Topic → 请求滚动
26 */
27export async function navigateToMessage(target: NavigationTarget): Promise<void> {
28 const { pageId, messageId, openPage = false, instant = true, requestScroll = true } = target
29
30 // Step 1: 打开页面(如果需要)
31 if (openPage) {
32 await pagesService.openPage(pageId, true)
33 }
34
35 // Step 2: 确保消息数据已加载
36 const record = await stores.message.load(pageId)
37
38 // Step 3: 检查消息是否在当前路径中
39 const currentPath = messagesService.getMessagePath(record.messages, record.leafMessageId)
40 const isInCurrentPath = currentPath.some((m) => m.id === messageId)
41
42 // Step 4: 仅当消息不在当前路径时才切换分支
43 // 如果消息已在当前路径,切换分支会导致分支被重置到第一个子分支
44 if (!isInCurrentPath) {
45 await messagesService.switchBranch(pageId, messageId)
46 }
47
48 // Step 5: 展开包含目标消息的折叠 Topic
49 await expandTopicsForMessage(pageId, messageId)
50
51 // Step 6: 请求 UI 执行滚动
52 if (requestScroll) {
53 navigationVersion++
54 stores.navigation.requestNavigation({
55 version: navigationVersion,
56 target: { pageId, messageId, instant },
57 timestamp: Date.now()
58 })
59 }
60}
61
62// ==================== Topic 展开逻辑 ====================
63

Callers

nothing calls this directly

Calls 3

expandTopicsForMessageFunction · 0.85
loadMethod · 0.80
requestNavigationMethod · 0.80

Tested by

no test coverage detected