fix(onboarding): notify user when voice intro falls back due to#233
fix(onboarding): notify user when voice intro falls back due to#233maciej-konczal wants to merge 3 commits into
Conversation
missing Gemini key
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@maciej-konczal is attempting to deploy a commit to the Finna Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR surfaces a user-visible notice when Gemini Live is unavailable or fails during onboarding, replacing the previous silent fallback to text mode. The gateway now sends a typed
Confidence Score: 5/5Safe to merge — the change is additive (new message type, new state field, new banner) with no modifications to existing data paths or auth flows. All three fallback paths are covered by tests, the schema extension is backwards-compatible, and the notice/error state is correctly cleared on retry. The only finding is that the "could not connect" copy is reused for mid-session disconnects where the voice channel had already been established, which is a UX wording inaccuracy rather than a functional defect. The two-line wording change in Important Files Changed
Sequence DiagramsequenceDiagram
participant Shell
participant Gateway as ws-handler
participant Gemini as Gemini Live
Shell->>Gateway: "start { audioFormat: "pcm16" }"
alt No GEMINI_API_KEY
Gateway-->>Shell: "notice { code: "gemini_unavailable" }"
Gateway-->>Shell: "mode_change { mode: "text" }"
else Key present — connect attempt
Gateway->>Gemini: connect()
alt connect() throws
Gemini-->>Gateway: Error
Gateway-->>Shell: "notice { code: "gemini_unavailable", "could not connect" }"
Gateway-->>Shell: "mode_change { mode: "text" }"
else Connected, then mid-session drop
Gemini-->>Gateway: disconnected event
Gateway-->>Shell: "notice { code: "gemini_unavailable", "could not connect" }"
Gateway-->>Shell: "mode_change { mode: "text" }"
else Connected successfully
Gateway-->>Shell: voice onboarding proceeds normally
end
end
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/gateway/src/onboarding/ws-handler.ts:42-43
The `GEMINI_VOICE_CONNECT_FAILED_NOTICE` constant ("Voice intro could not connect…") is reused for mid-session disconnections, where the voice channel was already established. A user who heard several seconds of the voice intro and then lost the connection would see "could not connect", which is misleading. Keeping separate messages for the two paths makes the notification accurate for both.
```suggestion
const GEMINI_VOICE_CONNECT_FAILED_NOTICE =
"Voice intro could not connect — continue in text below, or try again in a moment.";
const GEMINI_VOICE_DISCONNECTED_NOTICE =
"Voice intro disconnected — continuing in text below.";
```
### Issue 2 of 2
packages/gateway/src/onboarding/ws-handler.ts:235-240
With the separate constant above, the `disconnected` handler should use `GEMINI_VOICE_DISCONNECTED_NOTICE` so the user sees an accurate message when the session drops mid-flow rather than during initial connection.
```suggestion
client.on("disconnected", () => {
if (gemini !== client) return;
if (sm.current !== "done") {
if (audioMode) {
sendGeminiVoiceNotice(send, GEMINI_VOICE_DISCONNECTED_NOTICE);
}
```
Reviews (3): Last reviewed commit: "fix(onboarding): gemini setup updates" | Re-trigger Greptile |
| case "notice": | ||
| setNotice(msg.message as string); | ||
| break; |
There was a problem hiding this comment.
Stale notice persists across reconnect/restart
notice is set on receipt but never cleared. If handleStart is called a second time (e.g., the user retries with a valid key), the old gemini_unavailable banner will remain visible until a new notice arrives or the component unmounts. error has the same pattern, but a stale "voice unavailable" message while voice is actually working would be misleading. Clearing notice (and error) at the start of a new session would match the intent.
Prompt To Fix With AI
This is a comment left during a code review.
Path: shell/src/hooks/useOnboarding.ts
Line: 336-338
Comment:
**Stale notice persists across reconnect/restart**
`notice` is set on receipt but never cleared. If `handleStart` is called a second time (e.g., the user retries with a valid key), the old `gemini_unavailable` banner will remain visible until a new `notice` arrives or the component unmounts. `error` has the same pattern, but a stale "voice unavailable" message while voice is actually working would be misleading. Clearing `notice` (and `error`) at the start of a new session would match the intent.
How can I resolve this? If you propose a fix, please make it concise.
Gemini live does not on onboarding without Gemini API Key