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

Function tryNavigateToHistory

src/renderer/src/stores/tabsStore.ts:86–113  ·  view source on GitHub ↗
(
  history: TabHistoryEntry[],
  startIndex: number,
  direction: 1 | -1,
  tabs: Tab[],
  openTab: (tab: Tab, preview?: boolean) => void
)

Source from the content-addressed store, hash-verified

84}
85
86function tryNavigateToHistory(
87 history: TabHistoryEntry[],
88 startIndex: number,
89 direction: 1 | -1,
90 tabs: Tab[],
91 openTab: (tab: Tab, preview?: boolean) => void
92): { targetIndex: number; targetTabId: string } | null {
93 for (let i = startIndex; direction === -1 ? i >= 0 : i < history.length; i += direction) {
94 const entry = history[i]
95
96 if (tabs.some((t) => t.id === entry.tabId)) {
97 return { targetIndex: i, targetTabId: entry.tabId }
98 }
99
100 const restoredTab = tryRestoreTab(entry.type, entry.dataId)
101 if (restoredTab) {
102 isNavigating = true
103 try {
104 openTab({ ...restoredTab, preview: true }, true)
105 } finally {
106 isNavigating = false
107 }
108 return { targetIndex: i, targetTabId: restoredTab.id }
109 }
110 }
111
112 return null
113}
114
115const persist = (state: TabsState): void => {
116 const scope = tryGetCurrentWorkspaceScope()

Callers 1

tabsStore.tsFile · 0.85

Calls 1

tryRestoreTabFunction · 0.90

Tested by

no test coverage detected