Skip to content

Commit 7bd2f39

Browse files
authored
Merge pull request #22 from Unity-Lab-AI/codex/create-functional-ui-voice-activation-circles
Improve voice circle feedback and prompt diagnostics
2 parents b402b27 + bbf277f commit 7bd2f39

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

app.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ function setCircleState(circle, { speaking = false, listening = false, error = f
6666
circle.classList.toggle('is-error', error);
6767
circle.classList.toggle('is-active', speaking || listening || error);
6868

69-
if (label) {
70-
circle.setAttribute('aria-label', label);
69+
const resolvedLabel = label || circle.dataset.defaultLabel || '';
70+
71+
if (resolvedLabel) {
72+
circle.setAttribute('aria-label', resolvedLabel);
73+
}
74+
75+
const statusText = circle.querySelector('.status-text');
76+
if (statusText && resolvedLabel) {
77+
statusText.textContent = resolvedLabel;
7178
}
7279
}
7380

@@ -122,11 +129,19 @@ function updateBackgroundLinkOverlay(urls) {
122129

123130
async function loadSystemPrompt() {
124131
try {
125-
const response = await fetch(resolveAssetPath('ai-instruct.txt'));
132+
const response = await fetch(resolveAssetPath('ai-instruct.txt'), {
133+
cache: 'no-store'
134+
});
126135
systemPrompt = await response.text();
136+
document.body.dataset.systemPromptStatus = 'loaded';
137+
console.info(
138+
'[Unity Voice]',
139+
`System prompt loaded (${systemPrompt.length} characters)`
140+
);
127141
} catch (error) {
128142
console.error('Error fetching system prompt:', error);
129143
systemPrompt = 'You are Unity, a helpful AI assistant.';
144+
document.body.dataset.systemPromptStatus = 'fallback';
130145
}
131146
}
132147

index.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,24 @@
1616
<div id="background-urls" aria-hidden="true"></div>
1717
<main class="layout" aria-live="polite">
1818
<section class="voice-stage" role="group" aria-label="Voice activity monitors">
19-
<article class="voice-circle ai" data-role="ai" aria-label="Unity is idle">
19+
<article
20+
class="voice-circle ai"
21+
data-role="ai"
22+
data-default-label="Unity is idle"
23+
aria-label="Unity is idle"
24+
>
2025
<div class="pulse-ring"></div>
26+
<span class="status-text" aria-hidden="true">Unity is idle</span>
2127
<span class="sr-only">Unity</span>
2228
</article>
23-
<article class="voice-circle user" data-role="user" aria-label="Microphone is muted">
29+
<article
30+
class="voice-circle user"
31+
data-role="user"
32+
data-default-label="Microphone is muted"
33+
aria-label="Microphone is muted"
34+
>
2435
<div class="pulse-ring"></div>
36+
<span class="status-text" aria-hidden="true">Microphone is muted</span>
2537
<span class="sr-only">You</span>
2638
</article>
2739
</section>

style.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ body {
170170
border-color: rgba(67, 217, 189, 0.6);
171171
}
172172

173+
.voice-circle .status-text {
174+
position: relative;
175+
z-index: 2;
176+
padding: 0 18px;
177+
text-align: center;
178+
font-size: clamp(0.82rem, 2.4vw, 1rem);
179+
font-weight: 500;
180+
letter-spacing: 0.03em;
181+
color: rgba(245, 245, 245, 0.88);
182+
transition: color 0.4s ease;
183+
}
184+
185+
.voice-circle.is-error .status-text {
186+
color: rgba(255, 161, 181, 0.95);
187+
}
188+
189+
.voice-circle.is-speaking .status-text {
190+
color: rgba(255, 255, 255, 0.96);
191+
}
192+
193+
.voice-circle.is-listening.user .status-text {
194+
color: rgba(193, 255, 244, 0.96);
195+
}
196+
173197
.voice-circle.is-speaking {
174198
box-shadow: 0 0 54px -16px rgba(255, 255, 255, 0.75);
175199
transform: translateY(-6px) scale(1.05);

0 commit comments

Comments
 (0)