Skip to content

Code quality: Extract submethods from _processTranscript (112 lines) #9

@0xharkirat

Description

@0xharkirat

Priority: Medium

_processTranscript in assistant_screen.dart is 112 lines with deeply nested control flow handling capability help, NLU resolution, TTS, dispatch, result-waiting, and error handling.

Recommended fix

Extract submethods: _handleCapabilityHelp(), _handleCommandResolution(), _handleDispatch().

Additional cleanup

  • AgentManifest.fromJson crashes on missing capabilities key — use as List? with null-coalescing
  • _messages list grows unbounded — cap at ~200 messages
  • allActionsAsJson() in capability_registry.dart is dead code — remove it
  • Magic numbers in NLU confidence thresholds (0.30, 0.35) — extract to named constants

Files

  • lib/screens/assistant_screen.dart (lines 221-342)
  • lib/models/agent_manifest.dart (line 48)
  • lib/services/capability_registry.dart (lines 102-106)
  • lib/services/nlu_command_resolver.dart (lines 66, 165)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions