Skip to content

ADFA-5403 | Fix LlmInferenceService resolution for Voice-to-Code - #93

Open
jatezzz wants to merge 5 commits into
mainfrom
fix/ADFA-5403-resolve-llm-from-shared-services
Open

ADFA-5403 | Fix LlmInferenceService resolution for Voice-to-Code#93
jatezzz wants to merge 5 commits into
mainfrom
fix/ADFA-5403-resolve-llm-from-shared-services

Conversation

@jatezzz

@jatezzz jatezzz commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

Updated SpeechToTextPlugin to resolve the LlmInferenceService from the correct global registry. Previously, the plugin failed to find the service in the local context, causing Voice-to-Code to insert raw transcribed text instead of generated code. The service is now resolved from SharedServices first, with the local context.services used as a fallback. Resolution is dynamically retried on every use to account for parallel loading delays when the AI Core activates.

Details

  • Added resolveLlmService() to cache successful lookups and retry upon failure.
  • Bound the code generation request to a 60-second timeout (GENERATION_TIMEOUT_SECONDS) to prevent UI freezes.
  • Implemented stripCodeFences() to remove markdown from the generated output so the editor receives raw code.
  • Migrated logging from Android Log to the plugin's context.logger.
Screen_Recording_20260903_155612_Code.on.the.Go.mp4

Ticket

ADFA-5403
Parent: ADFA-5402

…(ADFA-5403)

context.services is a per-plugin registry that never holds it, so Voice-to-Code always inserted the raw transcript. Resolve per use, bound generation with a timeout, strip markdown fences, and target the open file's language, not Kotlin.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@hal-eisen-adfa hal-eisen-adfa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (Claude Code), high and medium findings only. Low-severity notes (duplicate fence stripper, LinkageError on SharedServices, no unit tests) are left out.

F09 (Medium) — line 52, outside the diff, so no inline comment is possible.
private var llmService: LlmInferenceService? = null is a plain non-volatile var, but this PR turns it into a lazily-populated cache. activate() writes it on the main thread; handleTranscript reads it from scope.launch on Dispatchers.IO. There is no happens-before edge, so the IO thread can keep seeing null and re-resolve on every transcript. recordingState in this same class is already @Volatile.

Resolve the LLM service through getPluginService as well, and drop the
cached reference when AI Core unloads. Tune the generation request
(system prompt, temperature, maxTokens) instead of scraping fences off
the reply, size the timeout to that token budget, and await the future
cancellably so plugin teardown unwinds it. Rewrite the fence stripper to
handle a lead-in line, an unclosed fence and a one-line fenced reply.
Guard logging against an uninitialized context during teardown.
@jatezzz

jatezzz commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@hal-eisen-adfa F09: fixed. llmService is now @Volatile, like recordingState in the same class, so the IO threads in scope see the value activate() publishes.
dispose() and the new AI Core lifecycle listener (F03) are the only other writers.

@hal-eisen-adfa hal-eisen-adfa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second automated review pass (Claude Code, xhigh). All thirteen findings from the first pass are addressed in code and the plugin builds clean; thanks. Five new issues below, four of them in the code this round introduced.

F16 (the Speech-to-Text max_ide_version 26.30 vs ai-core min_ide_version 26.35 gap) is dropped — we do not enforce those ranges.

Restore IDLE state and the raw-transcript fallback when AI Core cancels the shared future, release listener/scope/service in deactivate(), and stop the fence stripper from inserting prose (F17) or eating real code (F18, F20).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants