Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
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.
2026-08-01 15:44:40 -07:00

237 lines
11 KiB
TypeScript

import { useValues } from 'kea'
import { useEffect, useState } from 'react'
import { IconArrowLeft, IconCalendar, IconPerson, IconSend, IconShare } from '@hanzo/icons'
import { Button, Skeleton, Tag, Widget } from '@hanzo/elements'
import api from 'lib/api'
import { NotFound } from 'lib/components/NotFound'
import { Markdown } from 'lib/elements/Markdown'
import { Link } from 'lib/elements/Link'
import { PersonDisplay } from 'scenes/persons/PersonDisplay'
import { SceneExport } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { PersonType } from '~/types'
import { userInterviewTopicsRetrieve, userInterviewTopicsIntervieweesList, userInterviewsList } from './generated/api'
import type { UserInterviewTopicApi, IntervieweeContextApi, UserInterviewApi } from './generated/api.schemas'
import { InterviewLinkCopyButton } from './InterviewLinkCopyButton'
import { TranscriptChat } from './TranscriptChat'
import { userInterviewLogic } from './userInterviewLogic'
export interface UserInterviewResponseProps {
topicId: string
responseId: string
}
export const scene: SceneExport<UserInterviewResponseProps> = {
component: UserInterviewResponse,
paramsToProps: ({ params: { topicId, responseId } }) => ({ topicId, responseId }),
}
export function UserInterviewResponse({ topicId, responseId }: UserInterviewResponseProps): JSX.Element {
const identifier = decodeURIComponent(responseId)
const { linkForIdentifier, linksLoading, linksLoadFailed } = useValues(userInterviewLogic({ id: topicId }))
const interviewUrl = linkForIdentifier(identifier)
const [loading, setLoading] = useState(true)
const [topic, setTopic] = useState<UserInterviewTopicApi | null>(null)
const [intervieweeContext, setIntervieweeContext] = useState<IntervieweeContextApi | null>(null)
const [interview, setInterview] = useState<UserInterviewApi | null>(null)
const [person, setPerson] = useState<PersonType | null>(null)
useEffect(() => {
const projectId = String(teamLogic.values.currentTeamId)
async function load(): Promise<void> {
setLoading(true)
try {
const [topicData, intervieweesData, interviewsData] = await Promise.all([
userInterviewTopicsRetrieve(projectId, topicId),
userInterviewTopicsIntervieweesList(projectId, topicId),
userInterviewsList(projectId),
])
setTopic(topicData)
const ctx = intervieweesData.results.find((c) => c.interviewee_identifier === identifier)
setIntervieweeContext(ctx || null)
const matchingInterviews = interviewsData.results.filter(
(i) => i.topic === topicId && i.interviewee_identifier === identifier
)
// Prefer the interview that has a transcript
const matchingInterview = matchingInterviews.find((i) => i.transcript) || matchingInterviews[0] || null
setInterview(matchingInterview)
// Look up person by email/distinct_id
try {
const personResponse = await api.persons.list({ search: identifier })
if (personResponse.results.length > 0) {
setPerson(personResponse.results[0])
}
} catch {
// Person lookup is best-effort
}
} catch {
setTopic(null)
} finally {
setLoading(false)
}
}
void load()
}, [topicId, identifier])
if (loading) {
return (
<SceneContent>
<div className="space-y-4">
<Skeleton.Text className="h-8 w-[40%]" />
<Skeleton.Text className="h-4 w-[30%]" />
<Skeleton className="h-48" />
</div>
</SceneContent>
)
}
if (!topic) {
return <NotFound object="interview response" />
}
const hasResponse = !!(interview?.transcript || interview?.summary)
const displayName = person?.properties?.name || person?.properties?.email || person?.name || identifier
return (
<SceneContent>
<Button
type="tertiary"
size="small"
icon={<IconArrowLeft />}
to={urls.userInterview(topicId)}
className="mb-1 -ml-2"
>
All responses
</Button>
<SceneTitleSection name={displayName} description={topic.topic} resourceType={{ type: 'user_interview' }} />
<div className="grid grid-cols-1 gap-4 @container @4xl:grid-cols-3">
{/* Left column — transcript + summary */}
<div className="col-span-2 flex flex-col gap-4">
{interview?.summary && (
<Widget title="Summary">
<div className="p-4">
<Markdown className="text-sm">{interview.summary}</Markdown>
</div>
</Widget>
)}
<Widget title="Transcript">
{interview?.transcript ? (
<div className="p-4">
<TranscriptChat
transcript={interview.transcript}
person={person}
identifier={identifier}
/>
</div>
) : (
<div className="p-4 text-muted text-center">
No transcript available yet. The interview may not have been completed.
</div>
)}
</Widget>
</div>
{/* Right column — metadata */}
<div className="col-span-1 flex flex-col gap-4">
{/* Person card */}
<Widget title="Person">
<div className="p-4 space-y-3">
{person ? (
<>
<PersonDisplay person={person} withIcon />
<div className="space-y-2 mt-2">
{person.properties?.email && (
<div className="flex items-center gap-2">
<IconSend className="text-muted shrink-0" />
<span className="text-sm">{person.properties.email}</span>
</div>
)}
{person.created_at && (
<div className="flex items-center gap-2">
<IconCalendar className="text-muted shrink-0" />
<span className="text-sm">
First seen {person.created_at.split('T')[0]}
</span>
</div>
)}
</div>
</>
) : (
<div className="flex items-center gap-2">
<IconPerson className="text-muted" />
<span className="font-medium">{identifier}</span>
</div>
)}
<div className="space-y-1">
<div className="flex items-center gap-2">
<IconShare className="text-muted shrink-0" />
<span className="text-sm">Interview link</span>
<InterviewLinkCopyButton identifier={identifier} topicId={topicId} />
</div>
{interviewUrl ? (
<Link
to={interviewUrl}
target="_blank"
className="block text-xs font-mono break-all pl-6"
>
{interviewUrl}
</Link>
) : (
<span className="block text-xs text-muted pl-6">
{linksLoadFailed
? "Couldn't generate link — refresh to retry"
: linksLoading
? 'Generating link…'
: 'No link available'}
</span>
)}
</div>
<div>
<Tag type={hasResponse ? 'success' : 'default'}>
{hasResponse ? 'Responded' : 'Awaiting response'}
</Tag>
</div>
</div>
</Widget>
{intervieweeContext && (
<Widget title="Interviewee context">
<div className="p-4">
<p className="text-sm mb-0">{intervieweeContext.agent_context}</p>
</div>
</Widget>
)}
<Widget title="Topic details">
<div className="p-4 space-y-2">
<DetailRow label="Topic" value={topic.topic} />
<DetailRow label="Created" value={topic.created_at.split('T')[0]} />
</div>
</Widget>
</div>
</div>
</SceneContent>
)
}
function DetailRow({ label, value }: { label: string; value: string }): JSX.Element {
return (
<div className="flex justify-between gap-2">
<span className="text-muted text-sm shrink-0">{label}</span>
<span className="text-sm font-medium text-right">{value}</span>
</div>
)
}