Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

refactor(frontend): remove dead interactive tab actions from sceneLogic (#61980)

Paul D'Ambra8088c8699d60
diff --git a/frontend/src/scenes/max/Max.tsx b/frontend/src/scenes/max/Max.tsx
index e26ce60013bf..b17a95167af0 100644
--- a/frontend/src/scenes/max/Max.tsx
+++ b/frontend/src/scenes/max/Max.tsx
@@ -17,7 +17,6 @@ import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { cn } from 'lib/utils/css-classes'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
-import { sceneLogic } from 'scenes/sceneLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
@@ -91,7 +90,6 @@ export const MaxInstance = React.memo(function MaxInstance({ sidePanel, tabId }:
} = useValues(maxLogic({ tabId }))
const { startNewConversation, goBack } = useActions(maxLogic({ tabId }))
const { openSidePanelMax } = useActions(maxGlobalLogic)
- const { closeTabId } = useActions(sceneLogic)
const threadProps: MaxThreadLogicProps = {
tabId,
@@ -247,7 +245,6 @@ export const MaxInstance = React.memo(function MaxInstance({ sidePanel, tabId }:
sideIcon={<IconOpenSidebar />}
onClick={() => {
openSidePanelMax(conversationId ?? undefined)
- closeTabId(tabId, { source: 'open_in_side_panel' })
}}
>
Open in context panel
diff --git a/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx b/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
index e806dbd63176..463846a38d32 100644
--- a/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
+++ b/frontend/src/scenes/max/components/AiFirstMaxInstance.tsx
@@ -6,7 +6,6 @@ import { LemonBanner } from '@posthog/lemon-ui'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { cn } from 'lib/utils/css-classes'
-import { sceneLogic } from 'scenes/sceneLogic'
import { urls } from 'scenes/urls'
import { SceneName } from '~/layout/scenes/components/SceneTitleSection'
@@ -33,7 +32,6 @@ export function ChatHeader({
}): JSX.Element {
const { openSidePanelMax } = useActions(maxGlobalLogic)
const { chatTitle } = useValues(maxLogic)
- const { closeTabId } = useActions(sceneLogic)
const isTitleLoading = chatTitle === 'New chat'
return (
@@ -76,7 +74,6 @@ export function ChatHeader({
sideIcon={<IconOpenSidebar />}
onClick={() => {
openSidePanelMax(conversationId ?? undefined)
- closeTabId(tabId, { source: 'open_in_side_panel' })
}}
>
Open in context panel
diff --git a/frontend/src/scenes/sceneLogic.test.tsx b/frontend/src/scenes/sceneLogic.test.tsx
index 265f6dd3ae66..000eb6a9400e 100644
--- a/frontend/src/scenes/sceneLogic.test.tsx
+++ b/frontend/src/scenes/sceneLogic.test.tsx
@@ -1,4 +1,4 @@
-import { afterMount, beforeUnmount, kea, key, path, props } from 'kea'
+import { kea, path } from 'kea'
import { router } from 'kea-router'
import { expectLogic, partial, truth } from 'kea-test-utils'
@@ -12,8 +12,8 @@ import { urls } from 'scenes/urls'
import { initKeaTests } from '~/test/init'
import type { AppContext } from '~/types'
-import { mergePinnedTabs, sceneLogic } from './sceneLogic'
-import type { testLogicType, tabAwareTestLogicType } from './sceneLogic.testType'
+import { sceneLogic } from './sceneLogic'
+import type { testLogicType } from './sceneLogic.testType'
jest.mock('lib/api', () => ({
__esModule: true,
@@ -26,19 +26,6 @@ jest.mock('lib/api', () => ({
const Component = (): JSX.Element => <div />
const testLogic = kea<testLogicType>([path(['scenes', 'sceneLogic', 'test'])])
const sceneImport = (): any => ({ scene: { component: Component, logic: testLogic } })
-let mountedTabIds: (string | undefined)[] = []
-let unmountedTabIds: (string | undefined)[] = []
-const tabAwareTestLogic = kea<tabAwareTestLogicType>([
- path(['scenes', 'sceneLogic', 'tabAwareTestLogic']),
- props({} as { tabId?: string }),
- key(({ tabId }) => tabId ?? 'missing'),
- afterMount(({ props }) => {
- mountedTabIds.push(props.tabId)
- }),
- beforeUnmount(({ props }) => {
- unmountedTabIds.push(props.tabId)
- }),
-])
const testScenes: Record<string, () => any> = {
[Scene.DataManagement]: sceneImport,
@@ -58,8 +45,6 @@ describe('sceneLogic', () => {
await expectLogic(teamLogic).toDispatchActions(['loadCurrentTeamSuccess'])
featureFlagLogic.mount()
router.actions.push(urls.eventDefinitions())
- mountedTabIds = []
- unmountedTabIds = []
logic = sceneLogic.build({ scenes: testScenes })
// Simulate a fresh mount so that stored tabs are read from localStorage.
logic.cache.tabsLoaded = false
@@ -112,117 +97,6 @@ describe('sceneLogic', () => {
})
})
- it('keeps tab scene logic mounted when switching away and back to the same tab', async () => {
- const sceneParams = { params: {}, searchParams: {}, hashParams: {} }
- const dataManagementScene = { component: Component, logic: tabAwareTestLogic }
- const settingsScene = { component: Component, logic: testLogic }
-
- logic.actions.setTabs([
- {
- id: 'tab-1',
- active: true,
- pathname: '/data-management/events',
- search: '',
- hash: '',
- title: 'Data management',
- iconType: 'blank',
- sceneId: Scene.DataManagement,
- },
- {
- id: 'tab-2',
- active: false,
- pathname: '/settings/user',
- search: '',
- hash: '',
- title: 'Settings',
- iconType: 'blank',
- sceneId: Scene.Settings,
- },
- ])
-
- logic.actions.setScene(Scene.DataManagement, undefined, 'tab-1', sceneParams, false, dataManagementScene)
- expect(mountedTabIds.filter((tabId) => tabId === 'tab-1')).toHaveLength(1)
-
- logic.actions.activateTab(logic.values.tabs[1])
- logic.actions.setScene(Scene.Settings, undefined, 'tab-2', sceneParams, false, settingsScene)
- expect(unmountedTabIds).not.toContain('tab-1')
-
- logic.actions.activateTab(logic.values.tabs[0])
- logic.actions.setScene(Scene.DataManagement, undefined, 'tab-1', sceneParams, false, dataManagementScene)
-
- expect(mountedTabIds.filter((tabId) => tabId === 'tab-1')).toHaveLength(1)
- expect(unmountedTabIds).not.toContain('tab-1')
- })
-
- it('does not duplicate pinned tab when unpinning after reordering', async () => {
- logic.actions.setTabs([
- {
- id: 'tab-1',
- active: true,
- pathname: '/a',
- search: '',
- hash: '',
- title: 'Tab A',
- iconType: 'blank',
- },
- {
- id: 'tab-2',
- active: false,
- pathname: '/b',
- search: '',
- hash: '',
- title: 'Tab B',
- iconType: 'blank',
- },
- {
- id: 'tab-3',
- active: false,
- pathname: '/c',
- search: '',
- hash: '',
- title: 'Tab C',
- iconType: 'blank',
- },
- ])
-
- logic.actions.pinTab('tab-2')
- logic.actions.pinTab('tab-3')
-
- await expectLogic(logic).toMatchValues({
- tabs: expect.arrayContaining([
- expect.objectContaining({ id: 'tab-2', pinned: true }),
- expect.objectContaining({ id: 'tab-3', pinned: true }),
- expect.objectContaining({ id: 'tab-1', pinned: false }),
- ]),
- })
-
- logic.actions.reorderTabs('tab-3', 'tab-2')
-
- await expectLogic(logic).toMatchValues({
- tabs: expect.arrayContaining([
- expect.objectContaining({ id: 'tab-3', pinned: true }),
- expect.objectContaining({ id: 'tab-2', pinned: true }),
- expect.objectContaining({ id: 'tab-1', pinned: false }),
- ]),
- })
-
- logic.actions.unpinTab('tab-3')
-
- await expectLogic(logic).toMatchValues({
- tabs: expect.arrayContaining([
- expect.objectContaining({ id: 'tab-2', pinned: true }),
- expect.objectContaining({ id: 'tab-1', pinned: false }),
- expect.objectContaining({ id: 'tab-3', pinned: false }),
- ]),
- })
-
- const tab3Instances = logic.values.tabs.filter((tab) => tab.id === 'tab-3')
- const pinnedTabs = logic.values.tabs.filter((tab) => tab.pinned)
-
- expect(tab3Instances).toHaveLength(1)
- expect(tab3Instances[0].pinned).toBe(false)
- expect(pinnedTabs.map((tab) => tab.id)).not.toContain('tab-3')
- })
describe('/home honors the configured homepage', () => {
const dashboardHomepage = {
id: 'homepage-dashboard-42',
@@ -306,38 +180,4 @@ describe('sceneLogic', () => {
expect(router.values.searchParams).toEqual({ modal: 'feature' })
})
})
- describe('mergePinnedTabs', () => {
- const tabBase = { search: '', hash: '', title: '', iconType: 'blank' as const }
-
- it('restores in-memory sceneParams when stored tab is stripped', () => {
- const inMemory = [
- {
- ...tabBase,
- id: 'tab-dashboard',
- pathname: '/dashboard/42',
- active: true,
- sceneParams: { params: { id: '42' }, searchParams: {}, hashParams: {} },
- },
- ]
- const stored = {
- tabs: [{ ...tabBase, id: 'tab-dashboard', pathname: '/dashboard/42', pinned: true, active: false }],
- homepage: null,
- }
-
- const merged = mergePinnedTabs(stored, inMemory)
-
- expect(merged).toHaveLength(1)
- expect(merged[0]).toMatchObject({
- id: 'tab-dashboard',
- pinned: true,
- active: true,
- sceneParams: { params: { id: '42' } },
- })
- })
-
- it('returns fallback when storedPinned is null', () => {
- const fallback = [{ ...tabBase, id: 'a', pathname: '/x', active: false }]
- expect(mergePinnedTabs(null, fallback)).toMatchObject([{ id: 'a', pinned: true }])
- })
- })
})
diff --git a/frontend/src/scenes/sceneLogic.tsx b/frontend/src/scenes/sceneLogic.tsx
index 4f2c20663df2..6ea352613ad1 100644
--- a/frontend/src/scenes/sceneLogic.tsx
+++ b/frontend/src/scenes/sceneLogic.tsx
@@ -1,4 +1,3 @@
-import { arrayMove } from '@dnd-kit/sortable'
import equal from 'fast-deep-equal'
import { BuiltLogic, actions, afterMount, connect, kea, listeners, path, props, reducers, selectors } from 'kea'
import { combineUrl, router, urlToAction } from 'kea-router'
@@ -11,7 +10,6 @@ import { TeamMembershipLevel } from 'lib/constants'
import { trackFileSystemLogView } from 'lib/hooks/useFileSystemLogView'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { Spinner } from 'lib/lemon-ui/Spinner'
-import { tabUiStateLogic } from 'lib/logic/tabUiStateLogic'
import { getRelativeNextPath, identifierToHuman } from 'lib/utils'
import { getAppContext } from 'lib/utils/getAppContext'
import { isChunkLoadError } from 'lib/utils/isChunkLoadError'
@@ -52,20 +50,6 @@ import { inviteLogic } from './settings/organization/inviteLogic'
import { teamLogic } from './teamLogic'
import { userLogic } from './userLogic'
-export type TabOpenSource = 'internal_link' | 'keyboard_shortcut' | 'new_tab_button' | 'unknown'
-export type TabCloseSource =
- | 'close_button'
- | 'context_menu'
- | 'keyboard_shortcut'
- | 'middle_click'
- | 'open_in_side_panel'
- | 'unknown'
-
-export interface PersistedPinnedState {
- tabs: SceneTab[]
- homepage: SceneTab | null
-}
-
interface MountedTabLogic {
logic: SceneExport['logic']
logicProps: Record<string, any>
@@ -104,10 +88,6 @@ const getBootstrappedHomepage = (): SceneTab | null => {
return homepage ? sanitizeTabForPersistence(homepage) : null
}
-const persistTabs = (_tabs: SceneTab[], _homepage: SceneTab | null): void => {
- // PostHog tabs were removed — no longer persist tab state to storage.
-}
-
const partitionTabs = (tabs: SceneTab[]): { pinned: SceneTab[]; unpinned: SceneTab[] } => {
const pinned: SceneTab[] = []
const unpinned: SceneTab[] = []
@@ -126,21 +106,6 @@ const sortTabsPinnedFirst = (tabs: SceneTab[]): SceneTab[] => {
return [...pinned, ...unpinned]
}
-const updateTabPinnedState = (tabs: SceneTab[], tabId: string, pinned: boolean): SceneTab[] => {
- const index = tabs.findIndex((tab) => tab.id === tabId)
- if (index === -1) {
- return tabs
- }
-
- const newTabs = [...tabs]
- newTabs[index] = {
- ...tabs[index],
- pinned,
- }
-
- return ensureActiveTab(sortTabsPinnedFirst(newTabs))
-}
-
const ensureActiveTab = (tabs: SceneTab[]): SceneTab[] => {
if (!tabs.some((tab) => tab.active)) {
if (tabs.length > 0) {
@@ -150,33 +115,6 @@ const ensureActiveTab = (tabs: SceneTab[]): SceneTab[] => {
return tabs
}
-export const mergePinnedTabs = (storedPinned: PersistedPinnedState | null, fallbackPinned: SceneTab[]): SceneTab[] => {
- if (!storedPinned) {
- return fallbackPinned.map((tab) => ({ ...tab, pinned: true }))
- }
-
- const storedTabs = storedPinned.tabs ?? []
-
- // sceneParams is stripped during persistence (see tabToPersistableSnapshot) because it can be
- // deep/cyclic. Restore it from in-memory tabs so `paramsToProps` doesn't run against an empty bag.
- const fallbackById = new Map<string, SceneTab>()
- for (const tab of fallbackPinned) {
- fallbackById.set(tab.id, tab)
- }
-
- return storedTabs.map((tab) => {
- const id = tab.id || generateTabId()
- const fallback = fallbackById.get(id)
- return {
- ...tab,
- id,
- pinned: true,
- active: fallback?.active ?? false,
- sceneParams: fallback?.sceneParams ?? tab.sceneParams,
- }
- })
-}
-
const pathPrefixesOnboardingNotRequiredFor = [
urls.onboarding(),
'/settings',
@@ -247,7 +185,6 @@ export const sceneLogic = kea<sceneLogicType>([
cache.mountedTabLogic = {} as Record<string, MountedTabLogic>
cache.lastTrackedSceneByTab = {} as Record<string, { sceneId?: string; sceneKey?: string }>
cache.initialNavigationTabCreated = false
- cache.lastRegisteredTabCount = null as number | null
}),
actions({
/* 1. Prepares to open the scene, as the listener may override and do something
@@ -310,10 +247,7 @@ export const sceneLogic = kea<sceneLogicType>([
}),
reloadBrowserDueToImportError: true,
- newTab: (
- href?: string | null,
- options?: { activate?: boolean; skipNavigate?: boolean; id?: string; source?: TabOpenSource }
- ) => {
+ newTab: (href?: string | null, options?: { activate?: boolean; skipNavigate?: boolean; id?: string }) => {
const tabId = options?.id ?? generateTabId()
return {
href,
@@ -327,22 +261,7 @@ export const sceneLogic = kea<sceneLogicType>([
iconType,
}),
setHomepage: (tab: SceneTab | null) => ({ tab }),
- closeTabId: (tabId: string, options?: { source?: TabCloseSource }) => ({ tabId, options }),
- removeTab: (tab: SceneTab, options?: { source?: TabCloseSource }) => ({ tab, options }),
- activateTab: (tab: SceneTab) => ({ tab }),
- clickOnTab: (tab: SceneTab) => ({ tab }),
- reorderTabs: (activeId: string, overId: string) => ({ activeId, overId }),
- duplicateTab: (tab: SceneTab) => ({ tab }),
- renameTab: (tab: SceneTab) => ({ tab }),
- startTabEdit: (tab: SceneTab) => ({ tab }),
- endTabEdit: true,
- saveTabEdit: (tab: SceneTab, name: string) => ({ tab, name }),
- pinTab: (tabId: string) => ({ tabId }),
- unpinTab: (tabId: string) => ({ tabId }),
setTabScrollDepth: (tabId: string, scrollTop: number) => ({ tabId, scrollTop }),
- setFrozenWidths: (widths: Record<string, number> | null) => ({ widths }),
- clearFrozenWidths: true,
- freezeTabWidths: true,
}),
reducers({
// We store all state in "tabs". This allows us to have multiple tabs open, each with its own scene and parameters.
@@ -368,133 +287,6 @@ export const sceneLogic = kea<sceneLogicType>([
}
return sortTabsPinnedFirst([...baseTabs, newTab])
},
- removeTab: (state, { tab }) => {
- let index = state.findIndex((t) => t === tab)
- if (index === -1) {
- console.error('Tab to remove not found', tab)
- return state
- }
- let newState = state.filter((_, i) => i !== index)
- if (!newState.find((t) => t.active)) {
- const newActiveIndex = Math.max(index - 1, 0)
- newState = newState.map((tab, i) => (i === newActiveIndex ? { ...tab, active: true } : tab))
- }
- if (newState.length === 0) {
- newState.push({
- id: generateTabId(),
- active: true,
- pathname: '/new',
- search: '',
- hash: '',
- title: 'Search',
- iconType: 'search',
- pinned: false,
- })
- }
- return ensureActiveTab(sortTabsPinnedFirst(newState))
- },
- activateTab: (state, { tab }) => {
- const newState = state.map((t) =>
- t === tab
- ? !t.active
- ? { ...t, active: true, badge: false }
- : t
- : t.active
- ? {
- ...t,
- active: false,
- }
- : t
- )
- return sortTabsPinnedFirst(newState)
- },
- reorderTabs: (state, { activeId, overId }) => {
- const activeIndex = state.findIndex((t) => t.id === activeId)
- const overIndex = state.findIndex((t) => t.id === overId)
- if (activeIndex === -1 || overIndex === -1 || activeIndex === overIndex) {
- return state
- }
-
- const activeTab = state[activeIndex]
- const overTab = state[overIndex]
- if (!!activeTab?.pinned !== !!overTab?.pinned) {
- return state
- }
-
- const { pinned, unpinned } = partitionTabs(state)
-
- if (activeTab?.pinned && overTab?.pinned) {
- const from = pinned.findIndex((tab) => tab.id === activeId)
- const to = pinned.findIndex((tab) => tab.id === overId)
- if (from === -1 || to === -1 || from === to) {
- return state
- }
- const reordered = arrayMove(pinned, from, to)
- return [...reordered, ...unpinned]
- }
-
- const from = unpinned.findIndex((tab) => tab.id === activeId)
- const to = unpinned.findIndex((tab) => tab.id === overId)
- if (from === -1 || to === -1 || from === to) {
- return state
- }
- const newUnpinned = arrayMove(unpinned, from, to)
- return [...pinned, ...newUnpinned]
- },
- duplicateTab: (state, { tab }) => {
- const idx = state.findIndex((t) => t === tab || t.id === tab.id)
- const source = idx !== -1 ? state[idx] : tab
-
- const cloned: SceneTab = {
- id: generateTabId(),
- pathname: source.pathname,
- search: source.search,
- hash: source.hash,
- title: source.title,
- customTitle: source.customTitle,
- iconType: source.iconType,
- active: false,
- pinned: !!source.pinned,
- }
-
- const { pinned, unpinned } = partitionTabs(state)
-
- if (cloned.pinned) {
- const sourceIndex = pinned.findIndex((t) => t.id === source.id)
- const sanitizedCloned = { ...cloned, pinned: true }
- const updated =
- sourceIndex === -1
- ? [...pinned, sanitizedCloned]
- : [
- ...pinned.slice(0, sourceIndex + 1),
- sanitizedCloned,
- ...pinned.slice(sourceIndex + 1),
- ]
- return [...updated, ...unpinned]
- }
-
- const sourceIndex = unpinned.findIndex((t) => t.id === source.id)
- const sanitizedCloned = { ...cloned, pinned: false }
- const newUnpinned =
- sourceIndex === -1
- ? [...unpinned, sanitizedCloned]
- : [
- ...unpinned.slice(0, sourceIndex + 1),
- sanitizedCloned,
- ...unpinned.slice(sourceIndex + 1),
- ]
- return [...pinned, ...newUnpinned]
- },
- saveTabEdit: (state, { tab, name }) => {
- return state.map((t) =>
- t.id === tab.id
- ? {
- ...t,
- customTitle: name.trim() === '' ? undefined : name.trim(),
- }
- : t
- )
- },
setScene: (state, { sceneId, sceneKey, tabId, params }) => {
return state.map((tab) =>
tab.id === tabId
@@ -519,16 +311,6 @@ export const sceneLogic = kea<sceneLogicType>([
: tab
)
},
- pinTab: (state, { tabId }) => updateTabPinnedState(state, tabId, true),
- unpinTab: (state, { tabId }) => updateTabPinnedState(state, tabId, false),
- },
- ],
- editingTabId: [
- null as string | null,
- {
- startTabEdit: (_, { tab }) => tab.id,
- endTabEdit: () => null,
- saveTabEdit: () => null,
},
],
exportedScenes: [
@@ -572,10 +354,6 @@ export const sceneLogic = kea<sceneLogicType>([
...state,
[tabId]: scrollTop,
}),
- removeTab: (state, { tab }) => {
- const { [tab.id]: removed, ...rest } = state
- return rest
- },
setTabs: (state, { tabs }) => {
// remove those no longer present
return tabs.reduce(
@@ -590,13 +368,6 @@ export const sceneLogic = kea<sceneLogicType>([
},
},
],
- frozenWidths: [
- null as Record<string, number> | null,
- {
- setFrozenWidths: (_, { widths }) => widths,
- clearFrozenWidths: () => null,
- },
- ],
}),
// Function form so the bootstrapped default is read at build time (per kea context),
// not once at module import — production sets APP_CONTEXT before the bundle loads either way.
@@ -813,56 +584,11 @@ export const sceneLogic = kea<sceneLogicType>([
window.setTimeout(() => router.actions.refreshRouterState(), 1)
}
},
- freezeTabWidths: () => {
- const tabRow = document.querySelector('.scene-tab-row')
- if (!tabRow) {
- return
- }
- const widths: Record<string, number> = {}
- tabRow.querySelectorAll<HTMLElement>('[data-tab-id]').forEach((el) => {
- const id = el.getAttribute('data-tab-id')
- if (id) {
- widths[id] = el.getBoundingClientRect().width
- }
- })
- actions.setFrozenWidths(widths)
- },
- newTab: ({ href, options, tabId }) => {
- const newTab = values.tabs.find((tab) => tab.id === tabId)
- const fallbackUrl = combineUrl(href || '/new')
- const openSource = options?.source ?? 'unknown'
- posthog.capture('tab opened', {
- tab_id: tabId,
- pathname: newTab?.pathname ?? fallbackUrl.pathname,
- search: newTab?.search ?? fallbackUrl.search,
- hash: newTab?.hash ?? fallbackUrl.hash,
- pinned: newTab?.pinned ?? false,
- active: newTab?.active ?? options?.activate ?? true,
- scene_id: newTab?.sceneId,
- scene_key: newTab?.sceneKey,
- open_source: openSource,
- })
- persistTabs(values.tabs, values.homepage)
+ newTab: ({ href, options }) => {
if (!(options?.skipNavigate ?? false)) {
router.actions.push(href || urls.newTab())
}
},
- setTabs: () => persistTabs(values.tabs, values.homepage),
- activateTab: () => {
- persistTabs(values.tabs, values.homepage)
- },
- duplicateTab: () => persistTabs(values.tabs, values.homepage),
- renameTab: ({ tab }) => {
- actions.startTabEdit(tab)
- },
- pinTab: () => persistTabs(values.tabs, values.homepage),
- unpinTab: ({ tabId }) => {
- if (values.homepage?.id === tabId) {
- actions.setHomepage(null)
- } else {
- persistTabs(values.tabs, values.homepage)
- }
- },
setHomepage: ({ tab }) => {
if (isSharedView()) {
return
@@ -873,53 +599,6 @@ export const sceneLogic = kea<sceneLogicType>([
console.error('Failed to persist homepage', error)
})
},
- closeTabId: ({ tabId, options }) => {
- const tab = values.tabs.find(({ id }) => id === tabId)
- if (tab) {
- actions.removeTab(tab, { source: options?.source })
- }
- },
- removeTab: ({ tab, options }) => {
- tabUiStateLogic.findMounted()?.actions.clearTabUiState(tab.id)
- const closeSource = options?.source ?? 'unknown'
- posthog.capture('tab closed', {
- tab_id: tab.id,
- pathname: tab.pathname,
- search: tab.search,
- hash: tab.hash,
- pinned: tab.pinned,
- active: tab.active,
- scene_id: tab.sceneId,
- scene_key: tab.sceneKey,
- close_source: closeSource,
- })
- const isHomepageTab = values.homepage?.id === tab.id
- if (tab.active) {
- // values.activeTab will already be the new active tab from the reducer
- const { activeTab } = values
- if (activeTab) {
- router.actions.push(activeTab.pathname, activeTab.search, activeTab.hash)
- } else if (!isHomepageTab) {
- persistTabs(values.tabs, values.homepage)
- }
- } else if (!isHomepageTab) {
- persistTabs(values.tabs, values.homepage)
- }
-
- if (isHomepageTab) {
- actions.setHomepage(null)
- }
- },
- clickOnTab: ({ tab }) => {
- if (!tab.active) {
- actions.activateTab(tab)
- }
- router.actions.push(tab.pathname, tab.search, tab.hash)
- persistTabs(values.tabs, values.homepage)
- },
- reorderTabs: () => {
- persistTabs(values.tabs, values.homepage)
- },
push: ({ url, hashInput, searchInput }) => {
let { pathname, search, hash } = combineUrl(url, searchInput, hashInput)
pathname = addProjectIdIfMissing(pathname)
@@ -952,7 +631,6 @@ export const sceneLogic = kea<sceneLogicType>([
},
])
}
- persistTabs(values.tabs, values.homepage)
},
locationChanged: ({ pathname, search, hash, routerState, method }) => {
pathname = addProjectIdIfMissing(pathname)
@@ -989,7 +667,6 @@ export const sceneLogic = kea<sceneLogicType>([
},
])
}
- persistTabs(values.tabs, values.homepage)
// Remove trailing slash from the address bar. Route matching itself is handled
// upstream via `pathFromWindowToRoutes` in initKea.ts so the scene loads even
@@ -1451,11 +1128,6 @@ export const sceneLogic = kea<sceneLogicType>([
tabs: () => {
cache.initialNavigationTabCreated =
cache.initialNavigationTabCreated || values.tabs.some((tab) => !tab.pinned)
- const tabCount = values.tabs.length
- if (cache.lastRegisteredTabCount !== tabCount) {
- posthog.register({ tab_count: tabCount })
- cache.lastRegisteredTabCount = tabCount
- }
const { tabIds } = values
for (const id of Object.keys(cache.mountedTabLogic)) {
if (!tabIds[id]) {