[deep-review][duplication] D5: Models.cs (1972 lines) contains ~700 lines of non-DTO helper classes
Summary
src/OpenClaw.Shared/Models.cs is 1,972 lines. It's named Models.cs and most of its content is DTOs — but ~700 lines belong to four static helper classes that aren't models at all and have no business sharing this file.
Where
In Models.cs:
CommandCenterDiagnostics(static helper)CommandCenterCommandGroups(static taxonomy: safe-companion command list, privacy-sensitive command list — referenced fromApp.xaml.cs:1141-1146)GatewayTopologyClassifier(logic for classifying gateway topology from aGatewaySelfInfo)ModelFormatting(display-name and tooltip formatters)
Total: ~700 lines.
Plus the file mixes three coexisting parser conventions:
static class ChannelHealthParserwithParse(JsonElement)returning a typedChannelHealth- Inline
TryParse...static methods on record types - Inline
From...factory methods on record types (e.g.,GatewaySelfInfo.FromHealthPayload)
Why it matters
Models.csis the file new contributors search when looking for a model. They find static helpers instead. Cognitive overhead.- Code-quality review found this file has grown alongside
App.xaml.cs— uncapped growth signal. - The four helper classes have different lifecycles than the DTOs. They're called from UI code (
App.xaml.cs:1141); the DTOs are owned by the protocol layer. Coupling.
Proposed fix
Split into:
src/OpenClaw.Shared/Models.cs— keep only the DTO record types. Should drop to ~1,200 lines.src/OpenClaw.Shared/Diagnostics/CommandCenterDiagnostics.cssrc/OpenClaw.Shared/Diagnostics/CommandCenterCommandGroups.cssrc/OpenClaw.Shared/Diagnostics/GatewayTopologyClassifier.cssrc/OpenClaw.Shared/Diagnostics/ModelFormatting.cssrc/OpenClaw.Shared/Parsing/ChannelHealthParser.cs(or fold into Models.cs as nested static)
Followup: pick one parser convention (suggest: static TryParse on each record) and migrate the others.
Severity
Low (cosmetic) but high-payoff for new-contributor onboarding.
🤖 This is an automated response from Repo Assist.
Looked at Models.cs — the 1,972-line count is accurate and the proposed split makes sense. A couple of observations from reading the file:
What's safe to move immediately:
ModelFormattingandGatewayTopologyClassifierare pure static helpers with no circular references; they can move to separate files with a simple cut-paste.CommandCenterDiagnostics/CommandCenterCommandGroupsare called fromApp.xaml.cs— moving them doesn't change theusingdirectives already present, so it's mechanically safe.
What needs care:
ChannelHealthParser.Parse(JsonElement)returns aChannelHealthrecord that lives inModels.cs. Moving the parser to a sibling file (Parsing/ChannelHealthParser.cs) requiresChannelHealthto remain inModels.csor be moved first — otherwise there's a cyclic dependency between the two new files.
Suggested ordering:
- Move the four static helpers first (no DTO dependencies).
- Standardise on one parse convention (
static TryParseon each record) as a follow-up — this is the larger change and benefits from being separate.
The Models.cs reduction from ~1,970 to ~1,270 lines is the real payoff: it makes the file scannable in a way it currently isn't. New contributors looking for a DTO today have to scroll past hundreds of lines of helper logic.
Generated by 🌈 Repo Assist, see workflow run. Learn more.
Generated by 🌈 Repo Assist, see workflow run. Learn more.
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
Closing during the post-refactor deep-review cleanup. Models.cs bloat is reduced/changed after refactors and is consolidated into #372 as architecture debt. This keeps the signal while reducing stale one-off issue noise.