Skip to content

Restructure gpui implementation files#116

Open
stippi wants to merge 29 commits into
mainfrom
refactor/gpui-restructure
Open

Restructure gpui implementation files#116
stippi wants to merge 29 commits into
mainfrom
refactor/gpui-restructure

Conversation

@stippi
Copy link
Copy Markdown
Owner

@stippi stippi commented May 21, 2026

No description provided.

stippi added 29 commits May 21, 2026 16:55
- Move theme, settings, ui_state, assets, image, file_icons,
  context_indicator, auto_scroll, plan_banner into shared/ submodule
- Add gpui test-support feature to dev-dependencies
- Add 10 unit tests for UiStateStore (persistence logic)
- Add 5 tests for PlanBanner including 3 #[gpui::test] tests
  verifying event emission, state management, and initialization
- Re-export shared modules for backward compatibility
- All 491 tests pass
- Create tool_cards/ directory with trait, registry, and renderers
- Split tool_block_renderers.rs into:
  - tool_cards/mod.rs (trait, registry, CardRenderContext, ToolBlockStyle)
  - tool_cards/animated_card.rs (animated_card_body helper)
  - tool_cards/inline_renderer.rs (InlineToolRenderer)
- Move card renderers:
  - code_card_renderer.rs -> tool_cards/code_card.rs
  - diff_card_renderer.rs -> tool_cards/diff_card.rs
  - terminal_card_renderer.rs -> tool_cards/terminal_card.rs
  - sub_agent_card_renderer.rs -> tool_cards/sub_agent_card.rs
- Update all imports across the codebase
- All 491 tests pass, clippy clean
- Move chat_sidebar.rs -> project_sidebar/mod.rs
- Rename ChatSidebar -> SessionSidebar
- Rename ChatSidebarEvent -> SessionSidebarEvent
- Rename ChatListItem -> SessionListItem
- Rename ChatListItemEvent -> SessionListItemEvent
- Rename chat_collapsed -> sidebar_collapsed in MainScreen
- Update all imports and references across codebase
- Fix comments to reference 'project sidebar' consistently
- All 491 tests pass, clippy clean
- Move input_area.rs -> input/mod.rs
- Move attachment.rs -> input/attachment.rs
- Move model_selector.rs -> input/model_selector.rs
- Move sandbox_selector.rs -> input/sandbox_selector.rs
- Move worktree_selector.rs -> input/worktree_selector.rs
- Fix super:: references to use crate:: paths where needed
- All 491 tests pass, clippy clean
- Move messages.rs → messages/mod.rs (main MessagesView struct + Render impl)
- Extract scroll.rs (spring-damper constants + scroll handler installation)
- Extract activity_indicator.rs (braille spinner + rate limit rendering)
- Extract message_item.rs (single message row rendering logic)
- Move branch_switcher.rs → messages/branch_switcher.rs
- Delete old flat files (messages.rs, branch_switcher.rs)
- Add 12 gpui::test tests covering:
  - follow_tail initialization
  - messages_spliced list state updates
  - messages_spliced no-op when no growth
  - messages_reset list state reset
  - messages_reset to zero
  - activate_follow_tail behavior
  - scroll_to_bottom no-op when empty
  - stop_animation behavior
  - set_current_session_id
  - update_pending_message
  - animation trigger when following tail
  - no animation when not following tail
- All 503 tests pass, clean clippy
…/Green)

Add comprehensive gpui::test coverage for the elements module:
- test_message_container_add_text_block
- test_message_container_add_or_append_to_text_block
- test_message_container_add_or_append_to_thinking_block
- test_message_container_add_tool_use_block
- test_message_container_update_tool_status
- test_message_container_update_tool_status_nonexistent
- test_message_container_add_or_update_tool_parameter
- test_message_container_remove_blocks_with_request_id
- test_message_container_finish_thinking_blocks
- test_message_container_append_tool_output
- test_message_container_is_user_message
- test_message_container_node_id_and_branch_info
- test_thinking_block_formatted_duration
- test_thinking_block_reasoning_summary

Uses cx.update(|cx| entity.update(cx, ...)) pattern for non-Render
entities (MessageContainer doesn't need rendering for tests).

All 517 tests pass, clean clippy.
Move the message block types (MessageContainer, BlockView, TextBlock,
ThinkingBlock, ToolUseBlock, etc.) from the flat elements.rs into the
new blocks/ subdirectory. A thin elements.rs re-export file preserves
backward compatibility for all 22+ existing import sites.

Part of the GPUI restructure plan (Phase 2 - extract blocks/).
Split blocks/mod.rs into:
- block_types.rs: TextBlock, ThinkingBlock, ImageBlock, ToolUseBlock,
  ParameterBlock, CompactionSummaryBlock, BlockData enum + accessors
- container.rs: MessageContainer struct + all mutation methods +
  HiddenToolBlockType enum

blocks/mod.rs now only contains BlockView (struct + Render impl),
AnimationConfig/AnimationState, ToolCollapseState/ToolDiffModeState
helpers, and tests.
- Move new_project_dialog.rs → main_screen/project_dialog.rs
- Extract render_status_popover → main_screen/status_popover.rs
- Remove unused gpui/mod.rs module declaration for new_project_dialog
- Clean up unused imports

Part of Phase 8 of the GPUI restructure plan.
Move process_ui_event_async() and process_fragments_for_container()
into a dedicated event_loop.rs file. This is the largest single
extraction — the central UI event dispatcher that translates UiEvents
into message queue mutations.

mod.rs shrinks from 2601 to 1359 lines.
- backend.rs: handle_backend_response (~320 lines) — processes
  session created/loaded/deleted responses from background thread
- user_interface_impl.rs: UserInterface trait impl (~170 lines) —
  bridge between agent system and GUI event queue

mod.rs now ~865 lines (from original 2601).
- Create app/ directory with event_loop.rs, backend.rs,
  user_interface_impl.rs, and extracted drafts.rs
- Split blocks/mod.rs (1506 lines) into mod.rs (811) + render.rs (712)
- Rename block_types.rs to data.rs for clarity
- Rename project_sidebar/ to sidebar/, extract session_item.rs
- Fix module paths and visibility after moves

All 517 tests pass, clippy clean.
Fixes a layering violation where session and ACP code imported a
type defined inside the GPUI-specific UI module. MessageRole is now
defined in ui/ui_events.rs (alongside MessageData which uses it)
and re-exported from blocks/ for internal GPUI use.
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