fix: enable voice input for fresh agent conversations

This commit is contained in:
2026-08-17 14:29:34 +08:00
parent 9fd9a7761d
commit b6148a5cb4
3 changed files with 169 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
# Task: Fix Code fresh-conversation voice input
## Identity
- Task ID: 20260817-voice-input-fix-b4e62d91
- Mode: Feature
- Branch: codex/20260817-voice-input-fix-b4e62d91-voice-input-fix
- Worktree: D:\Datas\OthersProjects\makelore-voice-input-fix-b4e62d91
- Base commit: 9fd9a7761d3872f25e853ac1b059e55251c6ae8f
- Owner: codex
- Status: Completed
## Scope
- Enable AI Programming voice capture after the user selects an Agent but before the lazy first OpenCode session exists.
- Add a component-level regression that exercises the real fresh-contact state and verifies transcription populates the composer draft without creating an empty session.
- Preserve existing-session voice behavior and the current busy/transcribing guards.
## Intent And Constraints
- Preserve lazy contact selection: choosing an unused Agent or starting voice capture must not create or start an OpenCode session; only message submission may create the first session.
- Keep speech capture and transcription on the existing Renderer -> Host API -> Electron Main -> Works Square path.
- Do not change Canvas, Learning, Agent templates, provider configuration, or unrelated composer behavior.
- Keep the implementation surgical and limited to the ChatPanel predicate and its focused unit coverage.
## Outcome
- Updated the AI Programming composer voice-availability predicate so a selected Agent is sufficient before the lazy first session exists.
- Kept the existing loading, transcription, recording, and session-busy guards unchanged.
- Added a component regression covering a fresh Agent conversation: voice capture transcribes into the draft while the selected session remains lazy and no session-creation request is sent.
## Verification
- Regression-first evidence: the new fresh-Agent test failed before the predicate change because the voice button was disabled, then passed after the one-line fix.
- `pnpm exec eslint src/pages/Chat/OpencodeChatPanel.tsx tests/unit/opencode-chat-panel.test.tsx` passed.
- Five focused lazy-session and voice-input tests passed (`5 passed`, `80 skipped`).
- The complete `opencode-chat-panel.test.tsx` file passed (`85/85`) during implementation.
- `pnpm test` passed (`175` files, `2048` tests).
- `pnpm run typecheck` passed.
- `pnpm run build:vite` passed for Renderer, Electron Main, and Preload (`3921`, `133`, and `1` modules transformed respectively); only pre-existing chunk-size and mixed static/dynamic import warnings were reported.
- Final read-only Sol review: `PASS`, with no blocking findings across spec and standards checks.
- Electron microphone E2E was not added because the shared fixture does not provide a deterministic `MediaRecorder`/microphone seam; the component regression exercises Agent selection, recording start/stop, transcription, and lazy-session behavior directly.
## Follow-ups
- None.
## Promotion Candidates
- None. The change restores the documented lazy-session behavior and does not alter an architectural or product contract.