evOo-local/apps/web/src/pages/ProjectSessionTimeline.tsx
cynarAI 63f96b6edd fix(ci): restore the web client and the failing product checks (#83)
* fix(ci): restore browser preview module and onboarding e2e

The web bundle imported a browser-preview store that was never added, so production builds and every Playwright signup failed before the shell rendered. Mobile check failed because Expo packages were a patch behind the SDK.

Restore the store, type the optional desktop bridge, and walk whichever onboarding step scripted CI actually opens.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stop the blank web client and the send 500

The core barrel pulled git checkout into the browser, so node:child_process crashed the page before sign-up. Serve that module from a node export instead.

Add the missing run tool-call budget columns that threads/send writes. Guard an indexed shell flag for typecheck, and expect the files key the desktop preload already exposes.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): isolate pnpm setup and the takeover membership

The Team Computer takeover journey inserted a space member the
default-space trigger had already created, so shared Postgres rejected
the unique pair. Self-hosted jobs now keep a per-job pnpm home and
store, and artifact uploads no longer fail a job that already passed.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): clear typecheck, lint, and unit failures

Inbound channel rosters can mark a participant list as authoritative.
Answered channel asks stay off the group, and clearing a thread waits
until delegated returns land. Lint, unit, and web e2e contracts follow
the current shell, composer, and settings.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align e2e with the shipped shell and onboarding

Web E2E still expected older focus buttons, nested project rows, and
settings that never opened MCP. Persist the signed-in space, list
non-default spaces under Projekte, and keep the quote control on screen.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): open group reply from a revealed hover rail

The first user row covered its Reply control until the rail accepted
pointer events. The group transcript now reveals that rail, then replies.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stop the shell render loop and settle computer and mention UI

A working bot rewrote preview state on every render, the computer menu never stayed still, and the mention picker did not expose its expanded state or option name.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stop idle probes hanging and accept a follow-up send

Background probes walked every process fd and timed out on the shared runner. Linux now tracks the marker with flock and /proc/locks. A new composer draft can send while an earlier send is still refreshing, and group members stay mentionable.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(adapters): detect background work when flock ids are padded

The idle probe compared /proc/locks with an unpadded device key, so majors
or minors under 16 never matched. It deleted the live marker and reported
idle while the command still held the lock. Probe by taking the lock, and
print the cancel key the way the kernel does.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(adapters): stabilize background-work probe tests on self-hosted CI

Clear stale marker files before each probe scenario and allow longer
polling so launch can acquire flock on busy persistent runners.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): do not block onboarding on spaces list

Render the first onboarding step from me and integration setup alone.
Resolve the optional skip-to-app redirect after that so Playwright
signups are not stuck on the loading shell when spaces.list is slow.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): restore green gates after second main rebase

Re-apply biome formatting on Shell/SortableGroup and strict TypeScript
assertions in computer-idle tests dropped when skipping the duplicate
conflict-resolution commit.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): wait for onboarding bootstrap before E2E proceeds

Expose data-onboarding-step on the onboarding shell and have Playwright
wait until loading finishes. Ignore ad-hoc screenshot scripts on
self-hosted runners so they do not fail lint.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): fall back when onboarding bootstrap stalls

Race me/integration setup against a timeout and promote loading to the
emoji step after 20s so Playwright is not blocked on a hung RPC.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): render onboarding immediately for E2E signups

Start on the emoji step instead of a loading shell that waits on RPC.
Bootstrap can still redirect once me and integration setup resolve.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(ci): stabilize web e2e on self-hosted runners

Per-job pnpm stores broke node_modules symlinks when setup-node restored
cached installs, so Vite could not resolve react during dependency
optimization. Keep a runner-scoped store, clear stale Vite caches, and pin
Playwright to one worker in CI to reduce onboarding RPC contention.

Add Vite resolve aliases for react/react-dom, wait for an interactive
onboarding step in E2E helpers, and include the React hook smoke spec from
main.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): resolve React aliases through pnpm package layout

Root node_modules/react does not exist under pnpm, so Vite aliases pointed
at missing paths and broke production builds and the Playwright webServer.
Resolve react and react-dom from the web package and map jsx-runtime to the
actual entry files.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(core): type the lazy child_process spawn cache

Main's lazy require left spawn typed as null after assignment, which broke
Typecheck on the rebased branch.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(db): mock git-checkout export path in unit tests

Vitest resolves vi.mock against package exports; the .js suffix is not
declared for @rakazo/core/git-checkout.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize E2E after main sidebar and onboarding changes

Use first() for duplicate transcript lines, wait for interactive onboarding
before model-required assertions, and allow project sidebar to settle after
create. Extend the Playwright job timeout so the single-worker suite can finish.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): restore Projekte sidebar and integrations MCP entry

Use the default space for Unterhaltungen/Projekte separation instead of the
active space header, persist the bootstrapped space in localStorage, wire
SettingsOverlay to MCP management, and compare hover tones on inactive rows.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): satisfy biome format on homeSpaceId line

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align sidebar E2E with nested Projekte shell layout

Scope Unterhaltungen assertions to conversation rows only, target project-space
Chief actions under .sidebar-projekte, and stabilize hover-tone polling.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix: satisfy lint after main merge (format and unused var)

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): show project-space 1:1 bots in Projekte sidebar

Include lone bots in projectSidebarGroups, render bot rows in Projekte,
and stabilize E2E for nested sidebar layout and duplicate group entries.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): disambiguate duplicate group sidebar buttons in E2E

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): align spaces and group-chats E2E with Projekte sidebar IA

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): dedupe Projekte sidebar rows and stabilize E2E specs

- Deduplicate project space and group-chat entries in projectSidebarGroups
- Scope group-chats/spaces E2E clicks to first Projekte match after IA split
- Wait for shell ready before mention-picker keyboard test; restore main locators
- Fix PrivacySettingsOverlay lint and align biome schema with CLI 2.5.13

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): restrict project drag handle and stabilize space E2E

- Move SortableGroup drag listeners to ProjectDragGrip only so sidebar clicks work
- Scope space delete actions to project-space rows; wait for menu in E2E
- Switch group settings E2E via direct navigation after unsaved draft check
- Merge main (DataTrustPanel) and fix Shell import order for CI lint

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize message hover Escape assertion in E2E

Assert the More menu closes and the hover rail stays visible instead of
requiring focus restoration, which is flaky across Chromium builds.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* chore: format apps/api/src/app.ts after main merge

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): stabilize team-computer E2E send after bot switch

Wait for shell ready and use the Send button instead of Enter after
switching bots and closing the computer overlay. The prior run timed
out on threads/send with only an apps/api format commit in between.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-23 22:09:49 +02:00

392 lines
15 KiB
TypeScript

import { t } from "@lingui/core/macro";
import { Trans, useLingui } from "@lingui/react/macro";
import type { ProjectGoal, ProjectGoalStatus, ProjectSession } from "@rakazo/contracts";
import { useCallback, useEffect, useState } from "react";
import { rpc } from "../lib/rpc";
const INITIAL_VISIBLE = 4;
function goalStatusTone(status: ProjectGoalStatus): string {
if (status === "done") return "text-success";
if (status === "doing") return "text-warning";
return "text-foreground";
}
function goalStatusLabel(status: ProjectGoalStatus): string {
switch (status) {
case "open":
return t`Offen`;
case "doing":
return t`In Arbeit`;
case "done":
return t`Erledigt`;
default: {
const _exhaustive: never = status;
return _exhaustive;
}
}
}
function sessionStatusTone(status: ProjectSession["status"]): string {
if (status === "failed") return "text-destructive";
if (status === "cancelled") return "text-muted-foreground";
if (status === "completed") return "text-success";
if (status === "waiting_input" || status === "waiting_takeover") return "text-warning";
return "text-foreground";
}
function sessionStatusLabel(status: ProjectSession["status"]): string {
switch (status) {
case "queued":
return t`Queued`;
case "leased":
case "running":
return t`Running`;
case "waiting_input":
return t`Waiting`;
case "waiting_takeover":
return t`Takeover`;
case "completed":
return t`Done`;
case "failed":
return t`Failed`;
case "cancelled":
return t`Cancelled`;
default: {
const _exhaustive: never = status;
return _exhaustive;
}
}
}
function formatRelativeTime(iso: string): string {
const delta = Date.now() - new Date(iso).getTime();
const minutes = Math.round(delta / 60_000);
if (minutes < 1) return t`gerade eben`;
if (minutes < 60) return t`vor ${minutes} Min.`;
const hours = Math.round(minutes / 60);
if (hours < 24) return t`vor ${hours} Std.`;
const days = Math.round(hours / 24);
return t`vor ${days} T.`;
}
type ProjectSessionTimelineProps = {
sectionId: string;
sectionName: string;
groupId: string;
groupName: string;
onOpenSession: (sourceMessageId: string) => void;
onStartSession: () => void;
onOpenGroupChat: (groupId: string) => void;
onStartVoiceFirst: (groupId: string) => void;
};
export function ProjectSessionTimeline({
sectionId,
sectionName,
groupId,
groupName,
onOpenSession,
onStartSession,
onOpenGroupChat,
onStartVoiceFirst,
}: ProjectSessionTimelineProps) {
const { t } = useLingui();
const [goals, setGoals] = useState<ProjectGoal[]>([]);
const [sessions, setSessions] = useState<ProjectSession[]>([]);
const [loadingGoals, setLoadingGoals] = useState(true);
const [loadingSessions, setLoadingSessions] = useState(true);
const [sessionsExpanded, setSessionsExpanded] = useState(false);
const [creatingGoal, setCreatingGoal] = useState(false);
const [newGoalTitle, setNewGoalTitle] = useState("");
const reloadGoals = useCallback(async () => {
const result = await rpc.projectGoals.list({
sectionId,
groupId,
seedDefaults: true,
});
setGoals(result);
}, [groupId, sectionId]);
useEffect(() => {
let cancelled = false;
void reloadGoals()
.catch(() => {
if (!cancelled) setGoals([]);
})
.finally(() => {
if (!cancelled) setLoadingGoals(false);
});
return () => {
cancelled = true;
};
}, [reloadGoals]);
useEffect(() => {
let cancelled = false;
void rpc.groups
.listSessions({ groupId })
.then((result) => {
if (!cancelled) setSessions(result.sessions);
})
.catch(() => {
if (!cancelled) setSessions([]);
})
.finally(() => {
if (!cancelled) setLoadingSessions(false);
});
return () => {
cancelled = true;
};
}, [groupId]);
const visibleSessions = sessionsExpanded ? sessions : sessions.slice(0, INITIAL_VISIBLE);
const hiddenSessionCount = Math.max(0, sessions.length - INITIAL_VISIBLE);
const handleCreateGoal = async () => {
const title = newGoalTitle.trim();
if (!title) return;
setCreatingGoal(true);
try {
await rpc.projectGoals.create({
sectionId,
title,
groupId,
});
setNewGoalTitle("");
await reloadGoals();
} finally {
setCreatingGoal(false);
}
};
return (
<div className="flex flex-1 flex-col overflow-hidden">
<div className="border-b border-border/60 px-4 py-4 md:px-8 md:py-5 lg:px-10">
<p className="text-ui-label font-medium uppercase tracking-wide text-muted-foreground">
<Trans>Projekt</Trans>
</p>
<h2 className="text-ui-body font-semibold tracking-tight text-foreground">{sectionName}</h2>
<p className="mt-1 text-ui-body-sm text-muted-foreground">
<Trans>
Goals für dieses Projekt — unabhängig von Chat-Nachrichten. Unterhaltungen findest du
weiter unten.
</Trans>
</p>
</div>
<div className="flex-1 overflow-y-auto px-4 py-4 md:px-8 lg:px-10">
<div className="mx-auto flex w-full max-w-2xl flex-col gap-8">
<section aria-labelledby="project-goals-heading">
<div className="mb-3 flex items-center justify-between gap-3">
<h3
id="project-goals-heading"
className="text-ui-body-sm font-semibold text-foreground"
>
<Trans>Goals</Trans>
</h3>
<span className="rounded-full border border-primary/25 bg-primary/10 px-2 py-0.5 text-ui-label font-medium text-primary">
Goal
</span>
</div>
{loadingGoals ? (
<p className="text-ui-body-sm text-muted-foreground">
<Trans>Goals werden geladen…</Trans>
</p>
) : goals.length === 0 ? (
<div className="rounded-[16px] border border-dashed border-border/70 bg-card/40 px-4 py-6 text-center">
<p className="text-ui-body-sm text-muted-foreground">
<Trans>Noch keine Goals in diesem Projekt.</Trans>
</p>
</div>
) : (
<div className="flex flex-col gap-2">
{goals.map((goal) => {
const tone = goalStatusTone(goal.status);
const label = goalStatusLabel(goal.status);
const linkedGroupId = goal.groupId ?? groupId;
return (
<article
key={goal.id}
data-testid="project-goal-row"
className="rounded-[16px] border border-primary/20 bg-card/80 px-4 py-3.5 shadow-xs"
>
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
<span className="rounded-full border border-primary/30 bg-primary/10 px-2 py-0.5 text-ui-label font-semibold uppercase tracking-wide text-primary">
Goal
</span>
<p className="truncate text-ui-body font-medium text-foreground">
{goal.title}
</p>
</div>
{goal.description ? (
<p className="mt-1.5 line-clamp-2 text-ui-body-sm text-muted-foreground">
{goal.description}
</p>
) : null}
</div>
<div className="flex shrink-0 flex-col items-end gap-1">
<span className="text-ui-label text-muted-foreground">
{formatRelativeTime(goal.updatedAt)}
</span>
<span
className={`flex items-center gap-1 text-ui-label font-medium ${tone}`}
>
<span
className="h-1.5 w-1.5 rounded-full bg-current"
aria-hidden="true"
/>
{label}
</span>
</div>
</div>
<div className="mt-3 flex flex-wrap gap-2">
{/voice\s*first/i.test(goal.title) ? (
<button
type="button"
data-testid="voice-first-start"
onClick={() => onStartVoiceFirst(linkedGroupId)}
className="rounded-lg border border-emerald-500/40 bg-emerald-500/15 px-3 py-1.5 text-ui-label font-semibold text-emerald-200 transition-colors hover:bg-emerald-500/25"
>
<Trans>Voice First starten</Trans>
</button>
) : null}
<button
type="button"
onClick={() => onOpenGroupChat(linkedGroupId)}
className="rounded-lg border border-border bg-background px-3 py-1.5 text-ui-label font-medium text-foreground transition-colors hover:bg-accent"
>
<Trans>Unterhaltung öffnen</Trans>
</button>
</div>
</article>
);
})}
</div>
)}
<div className="mt-4 flex flex-col gap-2 sm:flex-row">
<input
type="text"
value={newGoalTitle}
onChange={(event) => setNewGoalTitle(event.target.value)}
placeholder={t`Neues Goal…`}
className="min-w-0 flex-1 rounded-xl border border-border bg-background px-3 py-2 text-ui-body-sm text-foreground"
onKeyDown={(event) => {
if (event.key === "Enter") void handleCreateGoal();
}}
/>
<button
type="button"
disabled={creatingGoal || !newGoalTitle.trim()}
onClick={() => void handleCreateGoal()}
className="rounded-xl border border-border bg-background px-4 py-2 text-ui-body-sm font-medium text-foreground transition-colors hover:bg-accent disabled:opacity-50"
>
<Trans>Goal anlegen</Trans>
</button>
</div>
</section>
<section aria-labelledby="project-chats-heading">
<div className="mb-3 flex items-center justify-between gap-3">
<h3
id="project-chats-heading"
className="text-ui-body-sm font-semibold text-foreground"
>
<Trans>Unterhaltungen</Trans>
</h3>
<span className="text-ui-label text-muted-foreground">{groupName}</span>
</div>
{loadingSessions ? (
<p className="text-ui-body-sm text-muted-foreground">
<Trans>Unterhaltungen werden geladen…</Trans>
</p>
) : sessions.length === 0 ? (
<div className="rounded-[16px] border border-border/70 bg-card/50 px-4 py-6 text-center">
<p className="text-ui-body-sm text-muted-foreground">
<Trans>Noch keine Unterhaltung in diesem Projekt-Chat.</Trans>
</p>
<button
type="button"
onClick={onStartSession}
className="mt-4 rounded-xl border border-border bg-background px-4 py-2 text-ui-body-sm font-medium text-foreground transition-colors hover:bg-accent"
>
<Trans>Chat starten</Trans>
</button>
</div>
) : (
<div className="flex flex-col gap-2">
{visibleSessions.map((session) => {
const tone = sessionStatusTone(session.status);
const label = sessionStatusLabel(session.status);
const participants =
session.botNames.length > 0 ? session.botNames.join(", ") : t`Team`;
return (
<button
key={session.sessionId}
type="button"
data-testid="project-session-row"
aria-label={t`${session.promptSnippet}, ${label}`}
onClick={() => onOpenSession(session.sourceMessageId)}
className="rounded-[14px] border border-border/60 bg-muted/20 px-4 py-3 text-left transition-all hover:border-border hover:bg-muted/35"
>
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 flex-1">
<p className="text-ui-label font-medium uppercase tracking-wide text-muted-foreground">
<Trans>Chat</Trans>
</p>
<p className="truncate text-ui-body-sm font-medium text-foreground">
{session.promptSnippet}
</p>
<p className="mt-0.5 truncate text-ui-label text-muted-foreground">
{participants}
</p>
</div>
<div className="flex shrink-0 flex-col items-end gap-1">
<span className="text-ui-label text-muted-foreground">
{formatRelativeTime(session.startedAt)}
</span>
<span
className={`flex items-center gap-1 text-ui-label font-medium ${tone}`}
>
<span
className="h-1.5 w-1.5 rounded-full bg-current"
aria-hidden="true"
/>
{label}
</span>
</div>
</div>
</button>
);
})}
{!sessionsExpanded && hiddenSessionCount > 0 ? (
<button
type="button"
onClick={() => setSessionsExpanded(true)}
className="self-start px-1 py-1 text-ui-body-sm font-medium text-primary hover:underline"
>
<Trans>Mehr Unterhaltungen… ({hiddenSessionCount})</Trans>
</button>
) : null}
<button
type="button"
onClick={onStartSession}
className="mt-1 self-start rounded-lg border border-border/70 px-3 py-1.5 text-ui-label font-medium text-foreground transition-colors hover:bg-accent"
>
<Trans>Neue Unterhaltung</Trans>
</button>
</div>
)}
</section>
</div>
</div>
</div>
);
}