mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
230 lines
7.9 KiB
TypeScript
230 lines
7.9 KiB
TypeScript
import { MakeLogicType, actions, afterMount, kea, key, path, props, reducers, selectors } from 'kea'
|
|
import { loaders } from 'kea-loaders'
|
|
import { actionToUrl, router, urlToAction } from 'kea-router'
|
|
|
|
import api from 'lib/api'
|
|
import { Scene } from 'scenes/sceneTypes'
|
|
import { urls } from 'scenes/urls'
|
|
|
|
import { Breadcrumb } from '~/types'
|
|
|
|
import {
|
|
EnrichedSessionGroupSummaryPatternsList,
|
|
PatternAssignedEventSegmentContext,
|
|
SessionGroupSummaryType,
|
|
} from './types'
|
|
|
|
export interface SessionGroupSummarySceneLogicProps {
|
|
id: string
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface sessionGroupSummarySceneLogicValues {
|
|
accessDeniedToSessionGroupSummary: boolean
|
|
breadcrumbs: Breadcrumb[]
|
|
selectedEvent: PatternAssignedEventSegmentContext | null
|
|
selectedEventUuid: string | null
|
|
selectedPatternId: number | null
|
|
sessionGroupSummary: SessionGroupSummaryType | null
|
|
sessionGroupSummaryLoading: boolean
|
|
sessionGroupSummaryMissing: boolean
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface sessionGroupSummarySceneLogicActions {
|
|
closeSessionDetails: () => {
|
|
value: true
|
|
}
|
|
loadSessionGroupSummary: () => {
|
|
value: true
|
|
}
|
|
loadSessionGroupSummaryFailure: (
|
|
error: string,
|
|
errorObject?: any
|
|
) => {
|
|
error: string
|
|
errorObject?: any
|
|
}
|
|
loadSessionGroupSummarySuccess: (
|
|
sessionGroupSummary: SessionGroupSummaryType | null,
|
|
payload?: {
|
|
value: true
|
|
}
|
|
) => {
|
|
sessionGroupSummary: SessionGroupSummaryType | null
|
|
payload?: {
|
|
value: true
|
|
}
|
|
}
|
|
openSessionDetails: (
|
|
patternId: number,
|
|
targetEventUuid: string
|
|
) => {
|
|
patternId: number
|
|
targetEventUuid: string
|
|
}
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface sessionGroupSummarySceneLogicMeta {
|
|
key: string
|
|
__keaTypeGenInternalSelectorTypes: {
|
|
sessionGroupSummaryMissing: (
|
|
sessionGroupSummary: SessionGroupSummaryType | null,
|
|
sessionGroupSummaryLoading: boolean
|
|
) => boolean
|
|
selectedEvent: (
|
|
sessionGroupSummary: SessionGroupSummaryType | null,
|
|
selectedPatternId: number | null,
|
|
selectedEventUuid: string | null
|
|
) => PatternAssignedEventSegmentContext | null
|
|
breadcrumbs: (sessionGroupSummary: SessionGroupSummaryType | null) => Breadcrumb[]
|
|
}
|
|
}
|
|
|
|
export type sessionGroupSummarySceneLogicType = MakeLogicType<
|
|
sessionGroupSummarySceneLogicValues,
|
|
sessionGroupSummarySceneLogicActions,
|
|
SessionGroupSummarySceneLogicProps,
|
|
sessionGroupSummarySceneLogicMeta
|
|
>
|
|
|
|
export const sessionGroupSummarySceneLogic = kea<sessionGroupSummarySceneLogicType>([
|
|
path(['products', 'session_summaries', 'frontend', 'sessionGroupSummarySceneLogic']),
|
|
props({} as SessionGroupSummarySceneLogicProps),
|
|
key((props) => props.id),
|
|
|
|
actions({
|
|
loadSessionGroupSummary: true,
|
|
openSessionDetails: (patternId: number, targetEventUuid: string) => ({ patternId, targetEventUuid }),
|
|
closeSessionDetails: true,
|
|
}),
|
|
|
|
reducers({
|
|
accessDeniedToSessionGroupSummary: [
|
|
false,
|
|
{
|
|
loadSessionGroupSummaryFailure: (_, { error }) =>
|
|
(error as any)?.status === 403 || (error as any)?.statusCode === 403,
|
|
},
|
|
],
|
|
selectedPatternId: [
|
|
null as number | null,
|
|
{
|
|
openSessionDetails: (_, { patternId }) => patternId,
|
|
closeSessionDetails: () => null,
|
|
},
|
|
],
|
|
selectedEventUuid: [
|
|
null as string | null,
|
|
{
|
|
openSessionDetails: (_, { targetEventUuid }) => targetEventUuid,
|
|
closeSessionDetails: () => null,
|
|
},
|
|
],
|
|
}),
|
|
|
|
loaders(({ props }) => ({
|
|
sessionGroupSummary: [
|
|
null as SessionGroupSummaryType | null,
|
|
{
|
|
loadSessionGroupSummary: async () => {
|
|
try {
|
|
return await api.sessionGroupSummaries.get(props.id)
|
|
} catch (error: any) {
|
|
if (error.status === 404) {
|
|
return null
|
|
}
|
|
throw error
|
|
}
|
|
},
|
|
},
|
|
],
|
|
})),
|
|
|
|
selectors({
|
|
sessionGroupSummaryMissing: [
|
|
(s) => [s.sessionGroupSummary, s.sessionGroupSummaryLoading],
|
|
(sessionGroupSummary: SessionGroupSummaryType | null, sessionGroupSummaryLoading: boolean): boolean => {
|
|
return !sessionGroupSummary && !sessionGroupSummaryLoading
|
|
},
|
|
],
|
|
selectedEvent: [
|
|
(s) => [s.sessionGroupSummary, s.selectedPatternId, s.selectedEventUuid],
|
|
(
|
|
sessionGroupSummary: SessionGroupSummaryType | null,
|
|
selectedPatternId: number | null,
|
|
selectedEventUuid: string | null
|
|
): PatternAssignedEventSegmentContext | null => {
|
|
if (!sessionGroupSummary || selectedPatternId === null || !selectedEventUuid) {
|
|
return null
|
|
}
|
|
const summary = JSON.parse(
|
|
sessionGroupSummary.summary || '{}'
|
|
) as EnrichedSessionGroupSummaryPatternsList
|
|
const pattern = summary.patterns?.find((p) => p.pattern_id === selectedPatternId)
|
|
if (!pattern) {
|
|
return null
|
|
}
|
|
return pattern.events.find((e) => e.target_event.event_uuid === selectedEventUuid) || null
|
|
},
|
|
],
|
|
breadcrumbs: [
|
|
(s) => [s.sessionGroupSummary],
|
|
(sessionGroupSummary: SessionGroupSummaryType | null): Breadcrumb[] => [
|
|
{
|
|
key: Scene.SessionGroupSummariesTable,
|
|
name: 'Session summaries',
|
|
path: urls.sessionSummaries(),
|
|
},
|
|
{
|
|
key: Scene.SessionGroupSummary,
|
|
name: sessionGroupSummary?.title || 'Group summary',
|
|
},
|
|
],
|
|
],
|
|
}),
|
|
|
|
actionToUrl(({ values }) => {
|
|
const buildURL = (): [string, Record<string, any>, Record<string, any>, { replace: boolean }] => {
|
|
const hashParams: Record<string, any> = { ...router.values.hashParams }
|
|
|
|
if (values.selectedPatternId !== null && values.selectedEventUuid) {
|
|
hashParams.patternId = values.selectedPatternId
|
|
hashParams.targetEventId = values.selectedEventUuid
|
|
} else {
|
|
delete hashParams.patternId
|
|
delete hashParams.targetEventId
|
|
}
|
|
|
|
return [router.values.location.pathname, router.values.searchParams, hashParams, { replace: true }]
|
|
}
|
|
|
|
return {
|
|
openSessionDetails: () => buildURL(),
|
|
closeSessionDetails: () => buildURL(),
|
|
}
|
|
}),
|
|
|
|
urlToAction(({ actions, values }) => ({
|
|
'*': (_: any, _searchParams: any, hashParams: Record<string, any>) => {
|
|
const patternId = hashParams.patternId ? Number(hashParams.patternId) : null
|
|
const targetEventId = hashParams.targetEventId || null
|
|
|
|
if (
|
|
patternId !== null &&
|
|
targetEventId &&
|
|
(values.selectedEventUuid !== targetEventId || values.selectedPatternId !== patternId)
|
|
) {
|
|
actions.openSessionDetails(patternId, targetEventId)
|
|
} else if (!patternId && !targetEventId && values.selectedEventUuid) {
|
|
actions.closeSessionDetails()
|
|
}
|
|
},
|
|
})),
|
|
|
|
afterMount(({ actions }) => {
|
|
actions.loadSessionGroupSummary()
|
|
}),
|
|
])
|