rea-analysis-optimization
MOmorluto/rea485k近 7 天新增 7,690 个 star
Use when deciding where new domain or GPUI feature code belongs (avoiding dumping new features into oxideterm-gpui-app or WorkspaceApp), and when refactoring Rust monoliths by extracting crates or modules, avoiding one-file crates, or verifying that an extracted crate owns real state, rendering, and behavior.
Treat every crate as a responsibility boundary, not a dumping folder—and do not grow oxideterm-gpui-app / WorkspaceApp by default when adding or refactoring features.
oxideterm-* without gpui). Never import GPUI into a domain crate.oxideterm-gpui-* feature UI crate—not directly in oxideterm-gpui-app.lib.rs, unless it is a tiny facade under 200 lines and all behavior lives in other modules.oxideterm-gpui-* feature UI crates, move UI state AND rendering together (Entity state, drafts, ListState/virtual-list caches, impl Render views, localized cx.notify(), and UI tests). Do not export stateless render() shims driven by full-window cx.observe(..., |_, _, cx| cx.notify()) hooks in oxideterm-gpui-app.oxideterm-gpui-app (WorkspaceApp) limited to window chrome, tab/pane orchestration, global IME/focus/shortcut routing, active runtime registries, and narrow HostBridge / *WindowRequest adapters.Audit before editing
scripts/audit_crate_responsibility.py <crate-dir> when available to catch one-file crates and oversized modules.Write the responsibility contract Before creating or editing a crate, state:
Owns: the behaviors the crate will own.Does not own: behaviors that must remain elsewhere.Inputs/outputs: public API types and side effects.Dependencies: allowed dependency direction.Acceptance: target module layout, max file sizes, and tests to run.Design modules first A real extracted crate usually has several of these:
lib.rs: facade, explicit exports, short crate docs.types.rs: shared domain DTOs only when they are not enough to justify their own module.state.rs: state container and state transitions.config.rs or storage.rs: persistence and loading.validation.rs: manifest/input invariants.runtime.rs, worker.rs, or service.rs: async/background behavior.adapter.rs: conversion between app/UI/backend shapes.tests.rs or focused test modules.Move behavior with the data If a struct moves, move at least one of:
Keep the app crate thin by crate type
oxideterm-gpui-app should retain only:
*WindowRequest / HostBridge adapters for OS dialogs, secret store, terminal/tab launch, and notifications.Domain crates (oxideterm-* without gpui) should own:
Feature UI crates (oxideterm-gpui-*) should own:
ListState/virtual-list caches, and local timers,impl Render views/dialogs and localized cx.notify() (never full-window root cx.observe -> cx.notify()),*Views) rather than adding one WorkspaceApp field per dialog,*Environment / frame inputs + unified *WindowRequest dispatch back to oxideterm-gpui-app.Replace broad field sprawl
When moving business state out of an app root struct, replace many fields with one focused state/views handle, then update methods to access that handle. Do not leave duplicate old fields or add a new WorkspaceApp field per sub-dialog.
Validate Run the narrow crate checks first, then the dependent app:
cargo fmt --checkcargo check -p <new-crate>cargo test -p <new-crate>cargo check -p <old-app-crate>Use these gates unless the repo has stricter local standards:
lib.rs should normally be under 200 lines and act as a facade.lib.rs for non-trivial work.Stop immediately when you see:
oxideterm-gpui-app / WorkspaceApp instead of an appropriate domain or oxideterm-gpui-* crate.lib.rs contains most implementation, or a crate is mostly pub use.oxideterm-gpui-* UI crate leaves impl Render in WorkspaceApp or relies on root cx.observe(..., |_, _, cx| cx.notify()) repaints for local edits/streams/frames.If any of these happen, do not present the work as complete. Either continue splitting or explicitly call it a partial migration.
MOmorluto/rea485k近 7 天新增 7,690 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star
MAmattpocock/skills336k近 7 天新增 4,217 个 star