Skip to content

Storage lazy loaded, removed AppServices#26

Merged
contributory merged 3 commits into
mainfrom
opencode/issue25-20260107001908
Jan 7, 2026
Merged

Storage lazy loaded, removed AppServices#26
contributory merged 3 commits into
mainfrom
opencode/issue25-20260107001908

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Đã chuyển sang lazy load:

  • Storage classes: AppearanceStorage, PreferencesStorage, DefaultOptionsStorage - instance getter async
  • HiveBaseStorage classes: ChatProfileStorage, LlmProviderInfoStorage, McpServerInfoStorage, SpeechServiceStorage, ConversationStorage - singleton lazy init
  • icon_builder.dart: dùng await PreferencesStorage.instance
  • chat_screen.dart: lazy init storage khi cần
  • main.dart: thêm await Hive.initFlutter(), xóa AppServices.init()
  • Đã xóa lib/app/config/services.dart
  • Tạo TTSService class cho text-to-speech
  • Type alias McpServerStorage = McpServerInfoStorage

Closes #25

New%20session%20-%202026-01-07T00%3A19%3A07.116Z
opencode session  |  github run

Co-authored-by: contributory <contributory@users.noreply.github.com>
@contributory

Copy link
Copy Markdown
Member

/oc do not create TTSService because it has already been migrated to SpeechService.

Co-authored-by: contributory <contributory@users.noreply.github.com>
@opencode-agent

opencode-agent Bot commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

Done. Removed TTSService class and all its references:

  • Deleted lib/core/speech/tts_service.dart
  • Removed export from speech.dart
  • Removed TTSService field, parameter, and method from chat_controller.dart
  • Removed TTSService import and usage from chat_screen.dart

New%20session%20-%202026-01-07T00%3A34%3A25.168Z
opencode session  |  github run

@contributory

Copy link
Copy Markdown
Member

/oc don't just delete TTSService from chat, replace it with SpeechService.

Co-authored-by: contributory <contributory@users.noreply.github.com>
@opencode-agent

opencode-agent Bot commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

Done! I've successfully replaced TTSService with SpeechService in the chat functionality. Here's what I did:

Changes Made:

  1. Created lib/core/speech/speech_manager.dart - A new service class that implements TTS functionality using flutter_tts and reads configuration from SpeechService model

  2. Modified lib/core/speech/speech.dart - Exported the new speech_manager.dart

  3. Modified lib/features/home/ui/controllers/chat_controller.dart:

    • Added speechManager field
    • Added speechManager parameter to constructor
    • Added speechManager.stop() call in dispose method
  4. Modified lib/features/home/ui/pages/chat_screen.dart:

    • Added speech module import
    • Created SpeechManager instance in _initializeViewModel
    • Passed speechManager to ChatController constructor
    • Wired up onRead callback to use speechManager.speak(m.content ?? '')

The SpeechManager uses the SpeechService model for configuration and provides the same speak() and stop() methods that TTSService had, maintaining compatibility with the existing chat functionality.

New%20session%20-%202026-01-07T00%3A45%3A01.262Z
opencode session  |  github run

@contributory contributory merged commit c6feab8 into main Jan 7, 2026
@contributory contributory deleted the opencode/issue25-20260107001908 branch January 7, 2026 01:20
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.

1 participant