Repository navigation
feat(nova): run spoken island requests as Nova threads - #374
Conversation
The dynamic island signs in with the CLI device-code flow and sends each utterance to a Nova voice route, which runs it as a web thread and returns a two-sentence summary for Sarvam to speak. A shared voice link lets Nova show the code the island joins with. EOF Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed.
Warning Some tools did not complete. Review the errors below.
|
[Medium impact] The change reaches the Jarvis voice workflow and its Nova web and CLI link services. Fix voice authentication, the default address, shared turns, and approval responses before merging. Findings
|
| const session = await auth.api.getSession({ headers: new Headers({ Authorization: `Bearer ${token}` }) }) | ||
| if (!session?.user?.id || !session.user.email) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }) |
There was a problem hiding this comment.
NovaSignIn gets a CLI session token, but this route passes it to the web app's auth.api.getSession. CLI sessions live in DATABASE_URL_TERMINAL; web auth uses DATABASE_URL and has no bearer plugin configured. Users can finish device sign-in but still get rejected here.
Check the token against the terminal session store, then map that user to the web account before creating the thread.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| /// Where Nova web runs. Spoken requests become threads here, so the | ||
| /// browser does not have to be open. | ||
| static var novaWebURL: String { | ||
| defaults.string(forKey: "nova_web_url") ?? "http://localhost:3000" |
There was a problem hiding this comment.
novaWebURL defaults to port 3000, but the web app's dev:web and start commands both serve port 3003. Nothing else in Jarvis sets this new value, and Settings has no address field. With the normal local setup, spoken requests go to the wrong port.
Use the web app's actual address or expose a way to set it.
| defaults.string(forKey: "nova_web_url") ?? "http://localhost:3000" | |
| defaults.string(forKey: "nova_web_url") ?? "http://localhost:3003" |
| let turn = try await novaService.run(content: text, sessionId: novaSessionId) | ||
| novaSessionId = turn.sessionId | ||
| response = turn.summary | ||
| state = .speaking | ||
| await ttsService.speak(turn.summary, apiKey: ttsAPIKey) |
There was a problem hiding this comment.
Connected links never receive turns
runNovaTurn never calls IslandLinkService.post. The only calls to the link service start the connection, and neither web route forwards turns into it. Even after the sidebar says “Island connected,” its turns stays empty.
Post the user's text and Nova's answer through the link when the turn runs.
| return NextResponse.json({ | ||
| sessionId, | ||
| summary: spokenSummary(answer), |
There was a problem hiding this comment.
Unfinished actions sound complete
Connected tools that need approval make runWebTurn finish with reason: "awaiting_input", without an error event. This route treats that as a completed answer. If no text came first, the island says “Done” even though the action has not run.
Check the finish reason and tell the user that Nova needs an answer or approval, including where to provide it.
| link.turns.push({ role, content: text, at: Date.now() }) | ||
| if (link.turns.length > MAX_TURNS) link.turns.splice(0, link.turns.length - MAX_TURNS) | ||
| link.lastSeenAt = Date.now() | ||
| link.expiresAt = Date.now() + LIVE_TTL_MS | ||
| return { ok: true, cursor: link.turns.length } |
There was a problem hiding this comment.
cursor is the retained array's length, but that length stops growing at MAX_TURNS. Once a reader reaches cursor 40, every later post removes an old turn and leaves the length at 40. Reading with since=40 then always returns an empty array.
Use a growing turn number and account for removed turns when reading.
| } catch { | ||
| // A dropped poll retries on the next tick; the link stays open. |
There was a problem hiding this comment.
The polling loop retries every failure without clearing link. Waiting codes expire after ten minutes, and the server returns 404 rather than a closed view. The page therefore keeps showing the expired code; an expired live link likewise keeps saying it is connected.
Handle 404 as a closed link and let the user request a new code.
| .trim() | ||
| .replace(/\s+([.!?])/g, "$1") | ||
| if (!clean) return "Done. I left the full result in your Nova thread." | ||
| const sentences = clean.match(/[^.!?]+[.!?]+/g) ?? [clean] |
There was a problem hiding this comment.
Spoken answers lose their ending
match drops a final sentence without punctuation whenever an earlier sentence has punctuation. For example, Found two options. Which one do you want becomes only Found two options. This can remove the question the voice user needs to answer.
Keep the remaining text as a sentence before taking the first two.
| const sentences = clean.match(/[^.!?]+[.!?]+/g) ?? [clean] | |
| const sentences = clean.match(/[^.!?]+(?:[.!?]+|$)/g) ?? [clean] |
| @State private var sarvamAPIKey: String = VoiceConfig.sarvamAPIKey | ||
| @State private var sarvamTTSSpeaker: String = VoiceConfig.sarvamTTSSpeaker | ||
| @State private var islandLinkCode: String = VoiceConfig.islandLinkCode | ||
| @State private var authToken: String = VoiceConfig.authToken |
There was a problem hiding this comment.
authToken is a one-time @State copy of VoiceConfig.authToken. Device sign-in updates VoiceConfig, not this state, so the open Settings view still shows “Sign in to Nova” and an empty token field after success.
Observe the stored value or update this state when sign-in completes.
| guard let http = response as? HTTPURLResponse, http.statusCode == 200 else { | ||
| let message = json?["error"] as? String ?? "Nova could not run that." | ||
| throw NovaError.unavailable(message) |
There was a problem hiding this comment.
The server includes sessionId when a turn fails after creating a thread, but this branch discards it. Because novaSessionId is saved only on success, a failed first turn makes the next utterance create another thread instead of continuing the saved request.
Carry the returned thread ID through the error and retain it for follow-ups.
The dynamic island signs in with the CLI device-code flow and sends each utterance to a Nova voice route, which runs it as a web thread and returns a two-sentence summary for Sarvam to speak. A shared voice link lets Nova show the code the island joins with.
EOF
Description
Please include a summary of the change and which issue is fixed.
Fixes #(issue)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
bun testpassesbun run typecheckpassesbun run lintpasses (if applicable)Checklist: