@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 53 lines 2.1 KB
Raw
1 import { useGT } from "gt-react";
2 import { useVoiceTranscriptionDestination } from "../../speech/useEnvironmentSpeechInput";
3 import {
4 useRetainedVoiceInputSession,
5 useVoiceInputSessionActivity,
6 useVoiceInputSessionSnapshot,
7 useVoiceOwnerPresented,
8 } from "../../speech/voiceInputSession";
9 import { Button } from "../ui/button";
10 import { ComposerSpeechRecordingPill } from "./ComposerSpeechButton";
11
12 /**
13 * Keeps the chosen destination's dictation alive across navigation and, while the draft it
14 * records into is off screen, shows it so it can be finished, cancelled, or returned to.
15 */
16 export function GlobalVoiceInputIndicator({ hidden = false }: { hidden?: boolean }) {
17 const gt = useGT();
18 const session = useRetainedVoiceInputSession(useVoiceTranscriptionDestination());
19 const { state, target, recordingStartedAt } = useVoiceInputSessionSnapshot(session);
20 const presented = useVoiceOwnerPresented(target?.ownerKey ?? null);
21 const { level } = useVoiceInputSessionActivity(
22 hidden || presented ? null : session,
23 target?.ownerKey ?? null,
24 );
25 if (hidden || !session || !target || state.phase === "idle" || presented) return null;
26
27 return (
28 <div className="pointer-events-none fixed inset-x-0 top-3 z-100 flex justify-center px-4">
29 <div className="pointer-events-auto flex max-w-full items-center gap-1 rounded-full bg-popover p-0.5 shadow-lg/5 [-webkit-app-region:no-drag]">
30 <Button
31 type="button"
32 size="sm-pill"
33 variant="ghost"
34 disabled={!target.open}
35 onClick={() => target.open?.()}
36 className="min-w-0 shrink"
37 >
38 <span className="truncate">{target.label ?? gt("Untitled thread")}</span>
39 </Button>
40 <ComposerSpeechRecordingPill
41 state={state}
42 progress={null}
43 level={level}
44 recordingStartedAt={recordingStartedAt}
45 onStart={() => void session.start(target)}
46 onStop={() => void session.stop()}
47 onCancel={() => session.cancel()}
48 onSkipPostProcessing={() => session.skipPostProcessing()}
49 />
50 </div>
51 </div>
52 );
53 }