From e17a333d3f356526799cdb10c2db65fef9f50328 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Tue, 14 Jul 2026 02:56:04 -0700 Subject: [PATCH] Iterate sidebar v2 from live feedback: card islands, project scope, creation picker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Design iteration after testing the beta over Tailscale: - Settled is the only collapse rule. Reverted the "seen Ready threads render slim" heuristic — it silently turned settled back into a derived state. Every unsettled thread is a full card; density is earned by settling. - Cards are bordered islands (rounded-xl, state-colored border: amber approval / sky working / red failed), status dot replaces the favicon on stateful cards, live elapsed timer on working. Slim rows grew to 34px with 13px titles; a hairline divider separates cards from the settled tail. - Harness identity is the provider glyph only (model name in tooltip). The full-row harness tint experiment is removed. - Hover actions (Settle/Un-settle) are absolutely-positioned overlays that fade over the timestamp — no layout shift. - Project scope chips above the list (All / per-project / + add): filters the flat list and informs the new-thread default. Session-local. - New thread opens a project picker dialog: contextual default preselected and focused (Enter confirms), all projects with workspace paths, Add project row. Single-project setups skip the dialog. chat.new (mod+shift+o) routes through the picker via newThreadPickerBus since the shortcut is handled in the _chat route layout. Arrow/Home/End navigation in the list. - chat.newLocal still bypasses the picker as the explicit escape hatch. Co-Authored-By: Claude Fable 5 --- apps/web/src/components/SidebarV2.tsx | 515 +++++++++++++++++++++----- apps/web/src/newThreadPickerBus.ts | 14 + apps/web/src/routes/_chat.tsx | 14 + 3 files changed, 452 insertions(+), 91 deletions(-) create mode 100644 apps/web/src/newThreadPickerBus.ts diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx index 15ee72a2f1..c46cb39fc9 100644 --- a/apps/web/src/components/SidebarV2.tsx +++ b/apps/web/src/components/SidebarV2.tsx @@ -42,7 +42,14 @@ import { readLocalApi } from "../localApi"; import { useUiStateStore } from "../uiStateStore"; import { useThreadSelectionStore } from "../threadSelectionStore"; import { useThreadActions } from "../hooks/useThreadActions"; -import { useNewThreadHandler } from "../hooks/useHandleNewThread"; +import { useHandleNewThread } from "../hooks/useHandleNewThread"; +import { useOpenAddProjectCommandPalette } from "../commandPaletteContext"; +import { onOpenNewThreadPicker } from "../newThreadPickerBus"; +import { Dialog, DialogHeader, DialogPopup, DialogTitle } from "./ui/dialog"; +import { + startNewThreadFromContext, + startNewThreadInProjectFromContext, +} from "../lib/chatThreadActions"; import { useClientSettings } from "../hooks/useSettings"; import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments"; import { useProjects, useThreadShells } from "../state/entities"; @@ -82,7 +89,16 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; // Row heights are fixed per variant so the list only changes shape at // lifecycle transitions (settle/unsettle), never from streaming updates. -const RAIL_CLASS_BY_STATUS: Partial> = { +// Cards are bordered islands (the mock's language): the border carries the +// state color, faint enough to read as a glow rather than a box. +const CARD_BORDER_BY_STATUS: Record = { + approval: "border-amber-500/45 dark:border-amber-300/35", + working: "border-sky-500/40 dark:border-sky-300/30", + failed: "border-red-500/45 dark:border-red-400/35", + ready: "border-border", +}; + +const STATUS_DOT_BY_STATUS: Partial> = { approval: "bg-amber-500 dark:bg-amber-300/90", working: "bg-sky-500 dark:bg-sky-300/80 animate-pulse", failed: "bg-red-500 dark:bg-red-400/90", @@ -91,7 +107,7 @@ const RAIL_CLASS_BY_STATUS: Partial> = { const STATUS_WORD_BY_STATUS: Partial< Record > = { - approval: { label: "Approval", className: "text-amber-600 dark:text-amber-300/90" }, + approval: { label: "Needs approval", className: "text-amber-600 dark:text-amber-300/90" }, working: { label: "Working", className: "text-sky-600 dark:text-sky-300/80" }, failed: { label: "Failed", className: "text-red-600 dark:text-red-400/90" }, }; @@ -122,6 +138,13 @@ function threadTimeLabel(thread: SidebarThreadSummary, status: SidebarV2Status): const SidebarV2Row = memo(function SidebarV2Row(props: { thread: SidebarThreadSummary; variant: "card" | "slim"; + // Slim rows are either settled (action: un-settle) or merely quiet + // (seen Ready threads — action: settle). + variantAction: "settle" | "unsettle"; + // Draws a hairline above the first quiet row after the card block, so the + // active island and the history tail read as separate zones (mock's + // SETTLED rule) without a labeled section header. + showQuietDivider?: boolean; isActive: boolean; jumpLabel: string | null; currentEnvironmentId: string | null; @@ -142,6 +165,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: { onUnsettle, thread, variant, + variantAction, } = props; const threadRef = useMemo( () => scopeThreadRef(thread.environmentId, thread.id), @@ -253,135 +277,180 @@ const SidebarV2Row = memo(function SidebarV2Row(props: { return (
  • + {props.showQuietDivider ? ( +
    + ) : null}
    {favicon} - + {thread.title} {prBadge} - - - {props.jumpLabel ?? - formatRelativeTimeLabel(thread.latestUserMessageAt ?? thread.updatedAt)} + + + {props.jumpLabel ?? + formatRelativeTimeLabel(thread.latestUserMessageAt ?? thread.updatedAt)} + + {variantAction === "unsettle" ? ( + + ) : ( + + )}
  • ); } - const rail = RAIL_CLASS_BY_STATUS[status]; + const statusDot = STATUS_DOT_BY_STATUS[status]; const statusWord = STATUS_WORD_BY_STATUS[status]; const diff = latestTurnDiff(thread); + const workingTimer = + status === "working" && thread.latestTurn?.startedAt + ? formatElapsedDurationLabel(thread.latestTurn.startedAt) + : null; return (
  • - {rail ? ( - - ) : null} -
    - {favicon} +
    + {statusDot ? ( + + ) : ( + favicon + )} {thread.title} {diff ? ( - + +{diff.insertions}{" "} −{diff.deletions} ) : null} - - - {props.jumpLabel ?? threadTimeLabel(thread, status)} + + + {props.jumpLabel ?? workingTimer ?? threadTimeLabel(thread, status)} + +
    -
    +
    {statusWord ? ( - {statusWord.label} + + {statusWord.label} + ) : null} {status === "failed" && thread.session?.lastError ? ( {thread.session.lastError} - ) : null} - {thread.branch ? ( - {thread.branch} - ) : null} - {prBadge} - + ) : ( + <> + {thread.branch ? ( + + {thread.branch} + + ) : null} + {prBadge} + + )} + {driverKind ? ( - + + } + > + + + {thread.modelSelection.model} + + ) : null} + {isRemote ? ( + + + } + > + + + + Running on {props.environmentLabel ?? "a remote environment"} + + ) : null} - {thread.modelSelection.model} - {isRemote ? ( - - - } - > - - {props.environmentLabel ?? "Remote"} - - - Running on {props.environmentLabel ?? "a remote environment"} - - - ) : null}
  • @@ -406,7 +475,8 @@ export default function SidebarV2() { const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays); const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete); const { settleThread, unsettleThread, archiveThread, deleteThread } = useThreadActions(); - const handleNewThread = useNewThreadHandler(); + const newThreadContext = useHandleNewThread(); + const openAddProjectCommandPalette = useOpenAddProjectCommandPalette(); const { environments } = useEnvironments(); const primaryEnvironmentId = usePrimaryEnvironmentId(); const clearSelection = useThreadSelectionStore((s) => s.clearSelection); @@ -480,9 +550,29 @@ export default function SidebarV2() { [], ); + // Project scope: chips above the list. Scoping filters the list AND + // becomes the new-thread target — one visible control doing both jobs the + // old per-project headers did. + const [projectScopeKey, setProjectScopeKey] = useState(null); + const scopedProject = useMemo( + () => + projectScopeKey === null + ? null + : (projects.find( + (project) => `${project.environmentId}:${project.id}` === projectScopeKey, + ) ?? null), + [projectScopeKey, projects], + ); + const { activeThreads, settledThreads } = useMemo(() => { const now = `${nowMinute}:00.000Z`; - const visible = threads.filter((thread) => thread.archivedAt === null); + const visible = threads.filter( + (thread) => + thread.archivedAt === null && + (scopedProject === null || + (thread.environmentId === scopedProject.environmentId && + thread.projectId === scopedProject.id)), + ); const active: EnvironmentThreadShell[] = []; const settled: EnvironmentThreadShell[] = []; for (const thread of visible) { @@ -502,7 +592,7 @@ export default function SidebarV2() { Date.parse(left.latestUserMessageAt ?? left.updatedAt), ), }; - }, [autoSettleAfterDays, changeRequestStateByKey, nowMinute, threads]); + }, [autoSettleAfterDays, changeRequestStateByKey, nowMinute, scopedProject, threads]); const orderedThreads = useMemo( () => [...activeThreads, ...settledThreads], @@ -884,12 +974,77 @@ export default function SidebarV2() { autoAnimate(node, { duration: 150, easing: "ease-out" }); }, []); + // New thread defaults to the project you're in (active thread's project, + // falling back to the top project) — same resolution the command palette + // uses. The chevron menu is the explicit project picker the flat list no + // longer gets from per-project headers. + const [newThreadPickerOpen, setNewThreadPickerOpen] = useState(false); + // chat.new (mod+shift+o / mod+n) is handled by the _chat route layout; in + // v2 with multiple projects it opens this picker via the event bus. + useEffect(() => onOpenNewThreadPicker(() => setNewThreadPickerOpen(true)), []); const handleNewThreadClick = useCallback(() => { - const firstProject = projects[0]; - if (!firstProject) return; - if (isMobile) setOpenMobile(false); - void handleNewThread(scopeProjectRef(firstProject.environmentId, firstProject.id)); - }, [handleNewThread, isMobile, projects, setOpenMobile]); + // One project: nothing to pick, create immediately. + if (projects.length <= 1) { + if (isMobile) setOpenMobile(false); + void startNewThreadFromContext({ + activeDraftThread: newThreadContext.activeDraftThread, + activeThread: newThreadContext.activeThread ?? undefined, + defaultProjectRef: newThreadContext.defaultProjectRef, + handleNewThread: newThreadContext.handleNewThread, + }); + return; + } + setNewThreadPickerOpen(true); + }, [isMobile, newThreadContext, projects.length, setOpenMobile]); + const createThreadInProject = useCallback( + (environmentId: (typeof projects)[number]["environmentId"], projectId: string) => { + setNewThreadPickerOpen(false); + if (isMobile) setOpenMobile(false); + const project = projects.find( + (candidate) => candidate.environmentId === environmentId && candidate.id === projectId, + ); + if (!project) return; + void startNewThreadInProjectFromContext( + { + activeDraftThread: newThreadContext.activeDraftThread, + activeThread: newThreadContext.activeThread ?? undefined, + defaultProjectRef: newThreadContext.defaultProjectRef, + handleNewThread: newThreadContext.handleNewThread, + }, + scopeProjectRef(project.environmentId, project.id), + ); + }, + [isMobile, newThreadContext, projects, setOpenMobile], + ); + const activeProjectRef = (() => { + const activeThread = routeThreadKey ? threadByKey.get(routeThreadKey) : null; + return activeThread + ? scopeProjectRef(activeThread.environmentId, activeThread.projectId) + : null; + })(); + const newThreadTargetRef = scopedProject + ? scopeProjectRef(scopedProject.environmentId, scopedProject.id) + : (activeProjectRef ?? newThreadContext.defaultProjectRef); + const newThreadTargetProject = newThreadTargetRef + ? (projects.find( + (project) => + project.environmentId === newThreadTargetRef.environmentId && + project.id === newThreadTargetRef.projectId, + ) ?? null) + : null; + // Picker order: the contextual default first (preselected), everything else + // after — the common case is Enter/click on the top row. + const newThreadPickerProjects = useMemo(() => { + if (!newThreadTargetProject) return projects; + return [ + newThreadTargetProject, + ...projects.filter( + (project) => + project.environmentId !== newThreadTargetProject.environmentId || + project.id !== newThreadTargetProject.id, + ), + ]; + }, [newThreadTargetProject, projects]); const commandPaletteShortcutLabel = shortcutLabelForCommand(keybindings, "commandPalette.toggle"); const newThreadShortcutLabel = shortcutLabelForCommand(keybindings, "chat.new"); @@ -937,16 +1092,97 @@ export default function SidebarV2() { + {projects.length > 0 ? ( + +
    + {projects.length > 1 ? ( + + ) : null} + {projects.map((project) => { + const scopeKey = `${project.environmentId}:${project.id}`; + const isScoped = projectScopeKey === scopeKey; + return ( + + ); + })} + + + } + > + + + Add project + +
    +
    + ) : null} -
      - {orderedThreads.map((thread) => { +
        + {orderedThreads.map((thread, threadIndex) => { const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)); const isSettledRow = settledThreadKeys.has(threadKey); + // Settled is the ONLY thing that collapses a row: every + // not-settled thread is a full card. Density comes from users + // (or the auto rules) actually settling work, not from the + // sidebar second-guessing what still matters. + const isCard = !isSettledRow; + const previousThread = threadIndex > 0 ? orderedThreads[threadIndex - 1] : null; + const previousWasCard = + previousThread != null && + !settledThreadKeys.has( + scopedThreadKey(scopeThreadRef(previousThread.environmentId, previousThread.id)), + ); + const showQuietDivider = !isCard && previousWasCard; return ( {orderedThreads.length === 0 ? ( -
        - No threads yet +
        + {projects.length === 0 ? ( + <> + No projects yet + + + ) : scopedProject ? ( + `No threads in ${scopedProject.title} yet` + ) : ( + "No threads yet" + )}
        ) : null} + + + + New thread in… + +
        { + if ( + event.key !== "ArrowDown" && + event.key !== "ArrowUp" && + event.key !== "Home" && + event.key !== "End" + ) { + return; + } + const container = event.currentTarget; + const options = [...container.querySelectorAll("button")]; + if (options.length === 0) return; + const currentIndex = options.findIndex((option) => option === document.activeElement); + const nextIndex = + event.key === "Home" + ? 0 + : event.key === "End" + ? options.length - 1 + : event.key === "ArrowDown" + ? (currentIndex + 1) % options.length + : (currentIndex - 1 + options.length) % options.length; + event.preventDefault(); + options[nextIndex]?.focus(); + }} + > + {newThreadPickerProjects.map((project, index) => { + const isDefault = index === 0 && newThreadTargetProject !== null; + return ( + + ); + })} + +
        +
        +
        ); } diff --git a/apps/web/src/newThreadPickerBus.ts b/apps/web/src/newThreadPickerBus.ts new file mode 100644 index 0000000000..a1cc7560e2 --- /dev/null +++ b/apps/web/src/newThreadPickerBus.ts @@ -0,0 +1,14 @@ +// Tiny event bus connecting the global chat.new shortcut (handled in the +// _chat route layout) to SidebarV2's project picker dialog. The route layer +// can't render the picker itself — it lives with the sidebar — and the +// sidebar can't own the window keydown handler without racing the layout's. +const NEW_THREAD_PICKER_EVENT = "t3code:open-new-thread-picker"; + +export function openNewThreadPicker(): void { + window.dispatchEvent(new CustomEvent(NEW_THREAD_PICKER_EVENT)); +} + +export function onOpenNewThreadPicker(listener: () => void): () => void { + window.addEventListener(NEW_THREAD_PICKER_EVENT, listener); + return () => window.removeEventListener(NEW_THREAD_PICKER_EVENT, listener); +} diff --git a/apps/web/src/routes/_chat.tsx b/apps/web/src/routes/_chat.tsx index 9fb1eae721..b590c59ed9 100644 --- a/apps/web/src/routes/_chat.tsx +++ b/apps/web/src/routes/_chat.tsx @@ -3,6 +3,9 @@ import { useAtomValue } from "@effect/atom-react"; import { useEffect } from "react"; import { isCommandPaletteOpen } from "../commandPaletteContext"; +import { useClientSettings } from "../hooks/useSettings"; +import { openNewThreadPicker } from "../newThreadPickerBus"; +import { useProjects } from "../state/entities"; import { dispatchPreviewAction } from "../components/preview/previewActionBus"; import { useHandleNewThread } from "../hooks/useHandleNewThread"; import { @@ -25,6 +28,8 @@ function ChatRouteGlobalShortcuts() { const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } = useHandleNewThread(); const keybindings = useAtomValue(primaryServerKeybindingsAtom); + const sidebarV2Enabled = useClientSettings((settings) => settings.sidebarV2Enabled); + const projectCount = useProjects().length; const terminalOpen = useTerminalUiStateStore((state) => routeThreadRef ? selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef).terminalOpen @@ -75,6 +80,13 @@ function ChatRouteGlobalShortcuts() { if (command === "chat.new") { event.preventDefault(); event.stopPropagation(); + // Sidebar v2 routes creation through its project picker whenever + // there is a real choice to make; v1 (and single-project setups) + // keep the immediate contextual create. + if (sidebarV2Enabled && projectCount > 1) { + openNewThreadPicker(); + return; + } void startNewThreadFromContext({ activeDraftThread, activeThread: activeThread ?? undefined, @@ -140,8 +152,10 @@ function ChatRouteGlobalShortcuts() { keybindings, defaultProjectRef, previewOpen, + projectCount, routeThreadRef, selectedThreadKeysSize, + sidebarV2Enabled, terminalOpen, ]);