Skip to content

Refactor: Extract rail tiles and space actions into separate files#108

Merged
krazyjakee merged 2 commits into
masterfrom
claude/intelligent-shannon-6pqghe
Jun 10, 2026
Merged

Refactor: Extract rail tiles and space actions into separate files#108
krazyjakee merged 2 commits into
masterfrom
claude/intelligent-shannon-6pqghe

Conversation

@krazyjakee

Copy link
Copy Markdown
Contributor

Summary

Refactored the accord_home_rail.dart file by extracting large helper classes and functions into dedicated, focused modules. This improves code organization, maintainability, and follows the single-responsibility principle without changing any functionality.

Changes

  • accord_home_rail_tiles.dart (new): Extracted _DraggableSpace, _DraggableSpaceState, _FolderTile, and _SpaceIcon widget classes that handle the visual representation and interaction of space tiles and folders in the rail.

  • accord_home_space_actions.dart (new): Extracted space action functions (_serverActionEntries, _copyServerLink, _leaveSpace, _leaveAndDeleteSpace) that handle muting, inviting, settings, and leaving spaces. These are shared between the standalone-space menu and folder-member menu.

  • accord_home_reactions.dart (new): Extracted reaction-related widgets (_ReactButton, _ReactionPill, _ReactorsDialog) from accord_home_message_row.dart for cleaner separation of concerns.

  • accord_home_mute_button.dart (new): Extracted the _MuteButton widget and _NotifAction enum from accord_home_message_row.dart to isolate channel notification management.

  • accord_home.dart: Updated to include new part directives for the extracted files, maintaining the part-file pattern used throughout the codebase.

  • accord_home_rail.dart: Removed ~750 lines of extracted code; file now focuses on the main _SpaceRail widget and rail layout logic.

  • accord_home_message_row.dart: Removed ~400 lines of extracted reaction and mute button code; file now focuses on message rendering and actions.

Implementation Details

  • All extracted code uses part of 'accord_home.dart' to maintain access to the same import scope and private members.
  • No logic changes; this is a pure refactoring for improved code organization.
  • Follows the existing Bonfire/Daccord codebase pattern of using part files for feature-specific UI components.

https://claude.ai/code/session_01G5zyWf2nQTv7wJpVkhEvAx

claude added 2 commits June 10, 2026 23:01
accord_home_message_row.dart (1200 lines) and accord_home_rail.dart
(1124 lines) were the only first-party source files over 1000 lines.
Break them up along class boundaries into new part files of the same
accord_home.dart library, with no code changes:

- accord_home_mute_button.dart: _MuteButton + _NotifAction (channel
  header notification toggle, unrelated to message rows)
- accord_home_reactions.dart: _ReactButton, _ReactionPill,
  _ReactorsDialog
- accord_home_space_actions.dart: _serverActionEntries,
  _copyServerLink, _leaveSpace, _leaveAndDeleteSpace
- accord_home_rail_tiles.dart: _DraggableSpace, _FolderTile,
  _SpaceIcon, _DirectMessagesButton, _AddServerButton,
  _HiddenServersButton

https://claude.ai/code/session_01G5zyWf2nQTv7wJpVkhEvAx
- accord_home_rail_tiles.dart: TextEditingController in _promptName was
  never disposed; chain .whenComplete(controller.dispose) so it's freed
  when the dialog closes regardless of cancel vs. save.

- accord_home_space_actions.dart: _leaveSpace docstring claimed
  "leave-and-delete lives in Privacy & Data" — inaccurate since
  _leaveAndDeleteSpace is also surfaced directly from the rail menu.
  Removed the false claim.

- test/features/settings/accord_settings_test.dart: add SpaceFolder
  round-trip, copyWith, and fromJson-defaults tests, plus
  AccordSettings.spaceOrder / spaceFolders persistence tests. The
  SpaceFolder model drives the extracted accord_home_rail_tiles.dart and
  accord_home_space_actions.dart part files and previously had no test
  coverage.

https://claude.ai/code/session_01GWsozNipjSqDPcW5goaAb7

Copy link
Copy Markdown
Contributor Author

Code Review — PR #108

Overall this is a clean, well-executed refactor. All extracted code uses part of correctly, the split boundaries make sense (one widget class / one concern per file), and no logic was changed. Three findings follow, ranked by severity. All fixes are pushed in commit 03527d1.


🔴 High — TextEditingController leak in _promptName

File: accord_home_rail_tiles.dart_FolderTile._promptName

The controller was created but never disposed:

// before
final controller = TextEditingController(text: initial);
return showDialog<String>(...);  // controller leaks when dialog closes

Fixed by chaining .whenComplete(controller.dispose) so it's freed on both cancel and save:

// after
return showDialog<String>(...).whenComplete(controller.dispose);

This bug was present in the original accord_home_rail.dart before extraction; the refactor was a good opportunity to catch it.


🟡 Medium — Stale/inaccurate docstring on _leaveSpace

File: accord_home_space_actions.dart

The docstring claimed "the destructive leave-and-delete lives in Privacy & Data", implying _leaveAndDeleteSpace is not surfaced from the rail. In fact both actions appear in _serverActionEntries and are shown directly in the rail's context menu. The incorrect sentence was removed.


🟢 Low — SpaceFolder model had no test coverage

File: test/features/settings/accord_settings_test.dart

SpaceFolder and the AccordSettings.spaceOrder / spaceFolders fields drive the extracted accord_home_rail_tiles.dart and accord_home_space_actions.dart part files but had zero tests. Added:

  • SpaceFolder round-trip (toJsonfromJson)
  • SpaceFolder.copyWith correctness (field preservation, clearColor)
  • SpaceFolder.fromJson with missing fields → documented defaults
  • AccordSettings spaceOrder and spaceFolders persistence round-trips

Notes (no action needed)

  • No logic changes confirmed. The three new part files are byte-for-byte identical to the sections removed from accord_home_rail.dart and accord_home_message_row.dart.
  • File sizes. All files are now well under 1000 lines (largest is accord_home_message_row.dart at 808 lines). Goal achieved.
  • Private types prevent direct unit testing of _SpaceRail._orderedIds / _buildUnits. These are pure algorithms and good candidates for a future extraction to a testable helper if regressions appear; no action needed for this PR.
  • No UI / 3D rendering changes — visual review not applicable.

Generated by Claude Code

@krazyjakee krazyjakee merged commit b7ab00f into master Jun 10, 2026
1 check passed
@krazyjakee krazyjakee deleted the claude/intelligent-shannon-6pqghe branch June 10, 2026 23:22
krazyjakee added a commit that referenced this pull request Jun 11, 2026
The reaction & mute work landed both in accord_home_message_row.dart and
in the dedicated part files (accord_home_mute_button.dart /
accord_home_reactions.dart) that refactor #108 had already extracted,
producing duplicate_definition compile errors. Remove the stale copies
from accord_home_message_row.dart and port the two bug fixes into the
canonical part files:

- mute-state read: parse channel_id out of the listMutes objects instead
  of stringifying the whole map (was always falsey, so muted state never
  showed).
- custom-emoji reactions: resolve the image URL from the space emoji
  catalog (image_url with space segment + real extension) rather than the
  bare AccordCDN.emoji(id) path, which 404'd.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
krazyjakee added a commit that referenced this pull request Jun 11, 2026
…111)

* feat(messaging): emoji reactions with custom-emoji image resolution

Adds reaction pills, a reaction picker, and a reactors dialog to message
rows, and resolves custom-emoji reaction images from the space's emoji
catalog (falling back to the bare CDN path) so animated/custom emoji
render correctly. Also fixes channel-mute detection to read channel_id
from the structured mutes list.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(messaging): resolve duplicate _MuteButton/_ReactionPill definitions

The reaction & mute work landed both in accord_home_message_row.dart and
in the dedicated part files (accord_home_mute_button.dart /
accord_home_reactions.dart) that refactor #108 had already extracted,
producing duplicate_definition compile errors. Remove the stale copies
from accord_home_message_row.dart and port the two bug fixes into the
canonical part files:

- mute-state read: parse channel_id out of the listMutes objects instead
  of stringifying the whole map (was always falsey, so muted state never
  showed).
- custom-emoji reactions: resolve the image URL from the space emoji
  catalog (image_url with space segment + real extension) rather than the
  bare AccordCDN.emoji(id) path, which 404'd.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(messaging): remove duplicate reaction/mute widget definitions and add tests

The PR added _ReactButton, _ReactionPill, _ReactorsDialog, _MuteButton, and
_NotifAction to accord_home_message_row.dart, but identical/older definitions
of the first three already existed in accord_home_reactions.dart (same `part of`
library → compile-time duplicate class error).

- Move all reaction/notification widgets to accord_home_reactions.dart (their
  natural home); remove duplicates from accord_home_message_row.dart.
- Update _ReactionPill in accord_home_reactions.dart to use the new `imageUrl`
  parameter (was `cdnUrl`) matching the improved PR design.
- Extract _ReactorTile to eliminate the double accordAvatarUrl() call per user.
- Fix wrong docstring on _MuteButton (previously read "Opens the full emoji
  picker to add a reaction to the message").
- Remove redundant `final emojiUrl = imageUrl;` alias in _ReactionPill.build().
- Wrap long _reactionEmojiUrl line to stay within 80 cols.
- Add test/features/messaging/emoji_utils_test.dart covering parseEmojiToken,
  resolveEmojiGlyph, and the mute-list channel_id extraction logic.

https://claude.ai/code/session_01MVhELbGUNvFDcBX2MkRs8r

* fix(messaging): remove _MuteButton/_NotifAction dupes from reactions part

The mute-button widgets were accidentally appended to accord_home_reactions.dart,
duplicating the definitions already in accord_home_mute_button.dart and failing
analyze with duplicate_definition. Keep only the canonical copies.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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