Skip to content

Commit a2dcfbf

Browse files
committed
feat(web): show preview recording beside the thread title
1 parent 18f7254 commit a2dcfbf

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎apps/web/src/browser/browserRecording.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ const activeBrowserRecordingTabIdsAtom = Atom.make<ActiveBrowserRecordingIndex>(
141141
tabIds: new Set<string>(),
142142
}).pipe(Atom.keepAlive, Atom.withLabel("preview:active-browser-recording-tabs"));
143143

144-
export function useActiveBrowserRecordingTabIds(): ReadonlySet<string> {
145-
return useAtomValue(activeBrowserRecordingTabIdsAtom).tabIds;
144+
export function useActiveBrowserRecordingTabIds(threadRef?: ScopedThreadRef): ReadonlySet<string> {
145+
const tabIds = useAtomValue(activeBrowserRecordingTabIdsAtom).tabIds;
146+
return threadRef ? readActiveBrowserRecordingTabIds(threadRef) : tabIds;
146147
}
147148

148149
const activeRecordings = new Map<string, ActiveRecording>();

‎apps/web/src/components/chat/ChatHeader.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
WorkspaceBreadcrumbSeparator,
4848
} from "../WorkspaceBreadcrumb";
4949
import { cn } from "~/lib/utils";
50+
import { BrowserRecordingIndicator } from "../preview/BrowserRecordingIndicator";
5051

5152
interface ChatHeaderProps {
5253
activeThreadEnvironmentId: EnvironmentId;
@@ -347,7 +348,7 @@ export const ChatHeader = memo(function ChatHeader({
347348
<WorkspaceBreadcrumbSeparator />
348349
</>
349350
) : null}
350-
<WorkspaceBreadcrumbItem current className="min-w-10 flex-1">
351+
<WorkspaceBreadcrumbItem current className="min-w-10 flex-1 gap-2">
351352
{renamingTitle !== null ? (
352353
<input
353354
autoFocus
@@ -398,6 +399,9 @@ export const ChatHeader = memo(function ChatHeader({
398399
<TooltipPopup side="top">{activeThreadTitle}</TooltipPopup>
399400
</Tooltip>
400401
)}
402+
<BrowserRecordingIndicator
403+
threadRef={scopeThreadRef(activeThreadEnvironmentId, activeThreadId)}
404+
/>
401405
</WorkspaceBreadcrumbItem>
402406
</WorkspaceBreadcrumb>
403407
<div
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { ScopedThreadRef } from "@t3tools/contracts";
2+
3+
import { useActiveBrowserRecordingTabIds } from "~/browser/browserRecording";
4+
5+
export function BrowserRecordingIndicator({ threadRef }: { threadRef: ScopedThreadRef }) {
6+
const recordingTabIds = useActiveBrowserRecordingTabIds(threadRef);
7+
8+
if (recordingTabIds.size === 0) return null;
9+
10+
return (
11+
<span
12+
role="status"
13+
aria-label="Preview recording in progress"
14+
className="inline-flex shrink-0 items-center gap-1.5 text-xs font-normal text-muted-foreground"
15+
>
16+
<span
17+
aria-hidden
18+
className="size-2 shrink-0 rounded-full bg-red-500 motion-safe:animate-status-pulse"
19+
/>
20+
Recording
21+
</span>
22+
);
23+
}

0 commit comments

Comments
 (0)