Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 81 additions & 44 deletions src/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6045,30 +6045,10 @@ export default function ChatPage() {
setIsDragOver(false);
if (event.dataTransfer.files.length) addFiles(event.dataTransfer.files);
}}
agentPanel={voiceMode === "agent" && !activeThread ? (
agentPanel={voiceMode === "agent" && !activeThread && agentOverlayMode !== "immersive" ? (
<div
className={agentOverlayMode === "immersive"
? "fixed inset-0 z-[90] flex items-center justify-center overflow-hidden px-4 pb-3 sm:px-6"
: "relative max-h-[min(10.75rem,28dvh)] overflow-hidden rounded-[24px] border border-[var(--voice-shell-border)] bg-[var(--bg-surface)]/88 px-3 py-2 shadow-[var(--theme-shadow)] backdrop-blur-xl sm:max-h-none"}
style={agentOverlayMode === "immersive"
? {
color: "var(--text-primary)",
background: "linear-gradient(180deg, color-mix(in srgb, var(--bg-primary) 97%, transparent), color-mix(in srgb, var(--bg-primary) 93%, var(--bg-secondary) 7%))",
}
: undefined}
className="relative max-h-[min(10.75rem,28dvh)] overflow-hidden rounded-[24px] border border-[var(--voice-shell-border)] bg-[var(--bg-surface)]/88 px-3 py-2 shadow-[var(--theme-shadow)] backdrop-blur-xl sm:max-h-none"
>
{agentOverlayMode === "immersive" && (
<div
className="absolute inset-0 opacity-60"
style={{
backgroundImage: [
"linear-gradient(var(--voice-overlay-grid) 1px, transparent 1px)",
"linear-gradient(90deg, var(--voice-overlay-grid-soft) 1px, transparent 1px)",
].join(", "),
backgroundSize: "44px 44px",
}}
/>
)}
<VoiceAgent
onTranscript={(text) => sendMessage(text, { forceVoiceResponse: true })}
onRealtimeTranscript={(event) => persistRealtimeTranscript(event, {
Expand All @@ -6081,8 +6061,7 @@ export default function ChatPage() {
isLoading={isLoading}
accentColor={resolvedVisualAccentColor}
autoActivate
compact={agentOverlayMode !== "immersive"}
immersive={agentOverlayMode === "immersive"}
compact
isMicMuted={agentMicMuted}
isAgentMuted={agentAudioMuted}
onMicMutedChange={setAgentMicMuted}
Expand All @@ -6097,36 +6076,25 @@ export default function ChatPage() {
voiceSettings={resolvedVoiceSettings}
visualSettings={resolvedVisualSettings}
/>
<div className={agentOverlayMode === "immersive"
? "absolute right-4 top-[max(var(--mobile-safe-top),1rem)] z-10 flex gap-2 sm:right-6"
: "absolute right-2 top-2 flex items-center gap-1"}
>
<div className="absolute right-2 top-2 flex items-center gap-1">
<button
type="button"
onClick={() => setVoicePickerOpen(true)}
title="Choose style"
aria-label="Choose style"
className={agentOverlayMode === "immersive"
? `flex h-10 w-10 items-center justify-center rounded-full border shadow-[var(--theme-shadow)] transition ${sessionVoiceOverride || sessionVisualOverride ? "border-[#00f0ff]/45 bg-[#00f0ff]/15 text-[#00f0ff]" : "border-[var(--border-medium)] bg-[var(--bg-surface)]/85 text-[var(--text-secondary)] hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"}`
: `flex h-8 w-8 items-center justify-center rounded-full border transition ${sessionVoiceOverride || sessionVisualOverride ? "border-[#00f0ff]/45 bg-[#00f0ff]/15 text-[#00f0ff]" : "border-[var(--border-medium)] bg-[var(--bg-primary)]/70 text-[var(--text-secondary)] hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"}`}
className={`flex h-8 w-8 items-center justify-center rounded-full border transition ${sessionVoiceOverride || sessionVisualOverride ? "border-[#00f0ff]/45 bg-[#00f0ff]/15 text-[#00f0ff]" : "border-[var(--border-medium)] bg-[var(--bg-primary)]/70 text-[var(--text-secondary)] hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"}`}
>
<VoicePersonIcon className={agentOverlayMode === "immersive" ? undefined : "h-3.5 w-3.5"} />
<VoicePersonIcon className="h-3.5 w-3.5" />
</button>
<button
type="button"
onClick={() => setAgentOverlayMode(agentOverlayMode === "immersive" ? "transcript" : "immersive")}
title={agentOverlayMode === "immersive" ? "Return to chat" : "Enter fullscreen visual mode"}
aria-label={agentOverlayMode === "immersive" ? "Return to chat" : "Enter fullscreen visual mode"}
className={agentOverlayMode === "immersive"
? "flex h-10 w-10 items-center justify-center rounded-full border border-[var(--border-medium)] bg-[var(--bg-surface)]/85 text-[var(--text-secondary)] shadow-[var(--theme-shadow)] transition hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"
: "flex h-8 w-8 items-center justify-center rounded-full border border-[var(--border-medium)] bg-[var(--bg-primary)]/70 text-[var(--text-secondary)] transition hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"}
onClick={() => setAgentOverlayMode("immersive")}
title="Enter fullscreen visual mode"
aria-label="Enter fullscreen visual mode"
className="flex h-8 w-8 items-center justify-center rounded-full border border-[var(--border-medium)] bg-[var(--bg-primary)]/70 text-[var(--text-secondary)] transition hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"
>
<svg className={agentOverlayMode === "immersive" ? "h-4 w-4" : "h-3.5 w-3.5"} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.75}>
{agentOverlayMode === "immersive" ? (
<path strokeLinecap="round" strokeLinejoin="round" d="M9 4.5H5.25A.75.75 0 0 0 4.5 5.25V9m10.5-4.5h3.75a.75.75 0 0 1 .75.75V9M9 19.5H5.25a.75.75 0 0 1-.75-.75V15m10.5 4.5h3.75a.75.75 0 0 0 .75-.75V15M8.25 8.25l-3.75-3.75m15 0-3.75 3.75m-7.5 7.5-3.75 3.75m15 0-3.75-3.75" />
) : (
<path strokeLinecap="round" strokeLinejoin="round" d="M3.75 9V5.25A1.5 1.5 0 0 1 5.25 3.75H9m6 0h3.75A1.5 1.5 0 0 1 20.25 5.25V9m0 6v3.75a1.5 1.5 0 0 1-1.5 1.5H15m-6 0H5.25a1.5 1.5 0 0 1-1.5-1.5V15" />
)}
<svg className="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.75}>
<path strokeLinecap="round" strokeLinejoin="round" d="M3.75 9V5.25A1.5 1.5 0 0 1 5.25 3.75H9m6 0h3.75A1.5 1.5 0 0 1 20.25 5.25V9m0 6v3.75a1.5 1.5 0 0 1-1.5 1.5H15m-6 0H5.25a1.5 1.5 0 0 1-1.5-1.5V15" />
</svg>
</button>
</div>
Expand All @@ -6135,6 +6103,75 @@ export default function ChatPage() {
/>
</div>
</div>
{voiceMode === "agent" && !activeThread && agentOverlayMode === "immersive" ? (
<div
className="fixed inset-0 z-[90] flex items-center justify-center overflow-hidden px-4 pb-3 sm:px-6"
style={{
color: "var(--text-primary)",
background: "linear-gradient(180deg, color-mix(in srgb, var(--bg-primary) 97%, transparent), color-mix(in srgb, var(--bg-primary) 93%, var(--bg-secondary) 7%))",
}}
>
<div
className="absolute inset-0 opacity-60"
style={{
backgroundImage: [
"linear-gradient(var(--voice-overlay-grid) 1px, transparent 1px)",
"linear-gradient(90deg, var(--voice-overlay-grid-soft) 1px, transparent 1px)",
].join(", "),
backgroundSize: "44px 44px",
}}
/>
<VoiceAgent
onTranscript={(text) => sendMessage(text, { forceVoiceResponse: true })}
onRealtimeTranscript={(event) => persistRealtimeTranscript(event, {
sessionKey: activeVoiceSessionKey,
storeKey: activeVoiceStoreKey,
setVisibleMessages: setMessages,
})}
isPlayingAudio={isPlayingAudio}
onInterrupt={interruptAudio}
isLoading={isLoading}
accentColor={resolvedVisualAccentColor}
autoActivate
immersive
isMicMuted={agentMicMuted}
isAgentMuted={agentAudioMuted}
onMicMutedChange={setAgentMicMuted}
onAgentMutedChange={handleAgentAudioMutedChange}
agent={selectedAgent?.callsign}
gatewayAgent={delegatedViaAgent?.callsign ?? selectedAgent?.callsign}
companyId={company?.id}
sessionKey={selectedSessionBelongsToAgent(selectedSessionKey, selectedAgent?.callsign)
? selectedSessionKey ?? gatewaySessionKeyForAgent(selectedAgent)
: gatewaySessionKeyForAgent(selectedAgent)}
realtimeRuntimeId={selectedAgent?.runtimeId ?? undefined}
voiceSettings={resolvedVoiceSettings}
visualSettings={resolvedVisualSettings}
/>
<div className="absolute right-4 top-[max(var(--mobile-safe-top),1rem)] z-10 flex gap-2 sm:right-6">
<button
type="button"
onClick={() => setVoicePickerOpen(true)}
title="Choose style"
aria-label="Choose style"
className={`flex h-10 w-10 items-center justify-center rounded-full border shadow-[var(--theme-shadow)] transition ${sessionVoiceOverride || sessionVisualOverride ? "border-[#00f0ff]/45 bg-[#00f0ff]/15 text-[#00f0ff]" : "border-[var(--border-medium)] bg-[var(--bg-surface)]/85 text-[var(--text-secondary)] hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"}`}
>
<VoicePersonIcon />
</button>
<button
type="button"
onClick={() => setAgentOverlayMode("transcript")}
title="Return to chat"
aria-label="Return to chat"
className="flex h-10 w-10 items-center justify-center rounded-full border border-[var(--border-medium)] bg-[var(--bg-surface)]/85 text-[var(--text-secondary)] shadow-[var(--theme-shadow)] transition hover:bg-[var(--bg-surface-hover)] hover:text-[var(--text-primary)]"
>
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.75}>
<path strokeLinecap="round" strokeLinejoin="round" d="M9 4.5H5.25A.75.75 0 0 0 4.5 5.25V9m10.5-4.5h3.75a.75.75 0 0 1 .75.75V9M9 19.5H5.25a.75.75 0 0 1-.75-.75V15m10.5 4.5h3.75a.75.75 0 0 0 .75-.75V15M8.25 8.25l-3.75-3.75m15 0-3.75 3.75m-7.5 7.5-3.75 3.75m15 0-3.75-3.75" />
</svg>
</button>
</div>
</div>
) : null}
</div>
</div>
</div>
Expand Down
23 changes: 12 additions & 11 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
.voice-agent-visual-layer {
position: absolute;
inset: 0;
z-index: 1;
border-radius: 999px;
overflow: hidden;
}
Expand All @@ -354,7 +355,7 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
.voice-visual-hologram,
.voice-visual-command {
position: absolute;
inset: 4%;
inset: 2%;
border-radius: 999px;
pointer-events: none;
}
Expand All @@ -364,9 +365,9 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
inset: 8%;
border-radius: 999px;
background:
radial-gradient(circle, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.08 + var(--voice-volume, 0) * 0.12)) 0%, transparent 58%),
radial-gradient(circle, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.14 + var(--voice-volume, 0) * 0.18)) 0%, transparent 58%),
repeating-radial-gradient(circle, var(--voice-shell-grid-soft) 0 1px, transparent 1px 28px);
opacity: calc(0.28 + var(--voice-motion, 0) * 0.3);
opacity: calc(0.48 + var(--voice-motion, 0) * 0.34);
filter: blur(0.2px);
animation: voice-agent-breathe calc(5.8s / var(--voice-intensity, 1)) ease-in-out infinite;
}
Expand All @@ -380,7 +381,7 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
linear-gradient(24deg, transparent 18%, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.08 + var(--voice-motion, 0) * 0.18)) 18.5%, transparent 20% 46%, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.1 + var(--voice-volume, 0) * 0.16)) 47%, transparent 48.5%),
linear-gradient(144deg, transparent 24%, var(--voice-shell-grid) 25%, transparent 26% 62%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.18) 63%, transparent 64%),
linear-gradient(82deg, transparent 32%, var(--voice-shell-grid-soft) 33%, transparent 34% 72%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.12) 73%, transparent 74%);
opacity: calc(0.38 + var(--voice-motion, 0) * 0.34);
opacity: calc(0.58 + var(--voice-motion, 0) * 0.36);
animation: voice-agent-drift calc(13s / var(--voice-intensity, 1)) ease-in-out infinite;
}

Expand All @@ -400,23 +401,23 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
margin-left: calc(var(--node-size) / -2);
margin-top: calc(var(--node-size) / -2);
border-radius: 999px;
background: rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.62 + var(--voice-motion, 0) * 0.32));
background: rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.78 + var(--voice-motion, 0) * 0.2));
box-shadow:
0 0 calc(8px + var(--voice-volume, 0) * 18px * var(--voice-intensity, 1)) rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.34 + var(--voice-motion, 0) * 0.34)),
0 0 1px var(--voice-shell-highlight);
transform:
rotate(var(--node-angle))
translateY(calc(-1 * var(--node-radius)))
scale(calc(0.84 + var(--voice-volume, 0) * 0.32 + var(--voice-motion, 0) * 0.38));
opacity: calc(0.38 + var(--voice-volume, 0) * 0.22 + var(--voice-motion, 0) * 0.28);
opacity: calc(0.68 + var(--voice-volume, 0) * 0.16 + var(--voice-motion, 0) * 0.16);
animation: voice-neural-node calc(7s / var(--voice-intensity, 1)) ease-in-out infinite;
animation-delay: var(--node-delay);
}

.voice-visual-hologram {
inset: 14%;
overflow: hidden;
border: 1px solid color-mix(in srgb, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.24) 80%, transparent);
border: 1px solid rgba(var(--voice-accent-rgb, 99, 183, 170), 0.42);
background:
radial-gradient(ellipse at center, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.08 + var(--voice-volume, 0) * 0.1)), transparent 68%),
linear-gradient(180deg, transparent, color-mix(in srgb, var(--voice-shell-highlight) 16%, transparent), transparent);
Expand All @@ -435,7 +436,7 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
radial-gradient(ellipse at 25% 50%, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.18 + var(--voice-volume, 0) * 0.22)), transparent 44%),
linear-gradient(90deg, transparent, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.12 + var(--voice-volume, 0) * 0.2)), transparent);
filter: blur(calc(var(--ribbon-index) * 0.35px));
opacity: calc(0.24 + var(--voice-motion, 0) * 0.38);
opacity: calc(0.54 + var(--voice-motion, 0) * 0.38);
transform: translateY(-50%) skewX(-8deg) scaleX(calc(0.78 + var(--voice-motion, 0) * 0.18 + var(--ribbon-index) * 0.035));
animation: voice-hologram-ribbon calc(2.8s / var(--voice-intensity, 1)) ease-in-out infinite;
animation-delay: var(--ribbon-delay);
Expand Down Expand Up @@ -464,8 +465,8 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
inset: 6%;
overflow: hidden;
background:
radial-gradient(circle, transparent 0 41%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.08) 42% 43%, transparent 44%),
conic-gradient(from 0deg, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.08 + var(--voice-motion, 0) * 0.16)), transparent 18%, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.1 + var(--voice-volume, 0) * 0.16)), transparent 52%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.08));
radial-gradient(circle, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.06 + var(--voice-volume, 0) * 0.1)) 0 40%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.18) 42% 43%, transparent 44%),
conic-gradient(from 0deg, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.18 + var(--voice-motion, 0) * 0.22)), transparent 18%, rgba(var(--voice-accent-rgb, 99, 183, 170), calc(0.2 + var(--voice-volume, 0) * 0.22)), transparent 52%, rgba(var(--voice-accent-rgb, 99, 183, 170), 0.18));
}

.voice-visual-command-grid {
Expand All @@ -477,7 +478,7 @@ body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top l
linear-gradient(90deg, var(--voice-shell-grid-soft) 1px, transparent 1px);
background-size: 18px 18px;
mask-image: radial-gradient(circle, black 50%, transparent 74%);
opacity: calc(0.18 + var(--voice-motion, 0) * 0.24);
opacity: calc(0.3 + var(--voice-motion, 0) * 0.34);
}

.voice-visual-command-ring {
Expand Down
21 changes: 9 additions & 12 deletions src/components/chat/voice-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,6 @@ export function VoiceAgent({
const listeningRgb = "var(--voice-listening-rgb)";
const speakingRgb = "var(--voice-speaking-rgb)";
const processingRgb = "var(--voice-processing-rgb)";
const activeRgb =
isMicMuted && !isPlayingAudio && !isLoading
? "var(--text-muted-rgb, 128, 128, 128)"
: state === "listening"
? listeningRgb
: state === "speaking"
? speakingRgb
: state === "processing"
? processingRgb
: accentRgb;
const stateColor =
isMicMuted && !isPlayingAudio && !isLoading
? "var(--text-tertiary)"
Expand All @@ -1212,7 +1202,14 @@ export function VoiceAgent({
: "var(--text-tertiary)";
const glowStrength = state === "idle" ? 0.16 : 0.28 + volumeLevel * 0.32;
const realtimeRelayActive = Boolean(realtimeRelayRef.current);
const visualVolume = Math.min(1, volumeLevel * (nativeSessionActive || realtimeRelayActive ? 1.25 : 0.8));
const baseReactiveLevel = state === "speaking"
? 0.36
: state === "listening"
? 0.22
: state === "processing"
? 0.28
: 0;
const visualVolume = Math.min(1, Math.max(baseReactiveLevel, volumeLevel * (nativeSessionActive || realtimeRelayActive ? 1.25 : 0.8)));
const motionLevel =
state === "speaking"
? Math.min(0.82, 0.24 + visualVolume * 0.78)
Expand Down Expand Up @@ -1257,7 +1254,7 @@ export function VoiceAgent({
haloSize={haloSize}
orbScale={orbScale}
glowStrength={glowStrength}
activeRgb={activeRgb}
activeRgb={accentRgb}
listeningRgb={listeningRgb}
speakingRgb={speakingRgb}
processingRgb={processingRgb}
Expand Down
Loading