Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

refactor(chat): extract SendMessage interactor from ChatPanel#264

Open
91jaeminjo wants to merge 3 commits intomainfrom
refactor/extract-send-message-interactor-from-chat-panel
Open

refactor(chat): extract SendMessage interactor from ChatPanel#264
91jaeminjo wants to merge 3 commits intomainfrom
refactor/extract-send-message-interactor-from-chat-panel

Conversation

@91jaeminjo
Copy link
Copy Markdown
Collaborator

Summary

  • Extracts orchestration logic (thread creation, document transfer, run initiation) from ChatPanel._handleSend() into a framework-free SendMessage interactor class
  • Introduces DocumentSelection abstract class and StartRun typedef for dependency injection
  • Removes _Result/Ok/Err sealed class hierarchy in favor of direct try/catch
  • ChatPanel retains all UI side-effects: thread selection, pending doc clearing, navigation, thread list invalidation, last-viewed persistence, error snackbars

Closes #208

New files

File Purpose
lib/core/document_selection.dart DocumentSelection abstract class + ThreadKey typedef
lib/features/chat/send_message.dart SendMessage interactor + StartRun typedef + SendMessageResult record
lib/features/chat/send_message_provider.dart Riverpod provider wiring
test/features/chat/send_message_test.dart 11 unit tests (thread creation, doc transfer, run invocation, doc filter, error propagation)

Modified files

File Changes
lib/core/providers/selected_documents_provider.dart implements DocumentSelection, re-exports ThreadKey, adds documentSelectionProvider
lib/features/chat/chat_panel.dart Delegates to sendMessageProvider, removes _withErrorHandling/Result types

Test plan

  • 11 new SendMessage unit tests pass
  • 22 existing chat_panel_test.dart tests pass unchanged
  • Full suite: 1193 tests pass
  • dart format . — 0 changes
  • flutter analyze --fatal-infos — 0 issues

🤖 Generated with Claude Code

91jaeminjo and others added 2 commits February 9, 2026 15:15
Separates orchestration logic (thread creation, document transfer, run
initiation) from UI concerns (snackbars, navigation, setState) by
introducing a framework-free SendMessage interactor class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ThreadKey is defined in document_selection.dart and no consumer
imports it through selected_documents_provider.dart.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move orchestration logic (send, retry, document selection, room-change
listener) into a ChatController Notifier. ChatPanel becomes a thin UI
shell that delegates to the controller and handles navigation/snackbars
via SendResult pattern matching.

Also removes the invalidateLastViewed(WidgetRef) factory in favor of
inline lambdas at both call sites.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract SendMessage interactor from ChatPanel

1 participant