: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
import { recentItemsModel } from '~/models/recentItemsModel'
import { FileSystemEntry } from '~/queries/schema/schema-general'
const NAV_RECENTS_LIMIT = 15
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface navRecentsLogicValues {
cachedRecents: FileSystemEntry[] // recentItemsModel
recentsHasLoaded: boolean // recentItemsModel
recentItems: FileSystemEntry[]
recentItemsLoading: boolean
recentsCollapsed: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface navRecentsLogicActions {
setRecentsCollapsed: (collapsed: boolean) => {
collapsed: boolean
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface navRecentsLogicMeta {
__keaTypeGenInternalSelectorTypes: {
recentItems: (cachedRecents: FileSystemEntry[]) => FileSystemEntry[]
recentItemsLoading: (recentsHasLoaded: boolean) => boolean
}
}
export type navRecentsLogicType = MakeLogicType<
navRecentsLogicValues,
navRecentsLogicActions,
Record<string, any>,
navRecentsLogicMeta
>
export const navRecentsLogic = kea<navRecentsLogicType>([
path(['layout', 'panel-layout', 'ai-first', 'tabs', 'navRecentsLogic']),
connect(() => ({
values: [recentItemsModel, ['recents as cachedRecents', 'recentsHasLoaded']],
})),
actions({ setRecentsCollapsed: (collapsed: boolean) => ({ collapsed }) }),
reducers({
recentsCollapsed: [true, { persist: true }, { setRecentsCollapsed: (_, { collapsed }) => collapsed }],
}),
selectors({
recentItems: [
(s) => [s.cachedRecents],
(cachedRecents: FileSystemEntry[]): FileSystemEntry[] => cachedRecents.slice(0, NAV_RECENTS_LIMIT),
],
recentItemsLoading: [(s) => [s.recentsHasLoaded], (recentsHasLoaded: boolean): boolean => !recentsHasLoaded],
}),
])