You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 from App.xaml.cs:1141-1146)
GatewayTopologyClassifier (logic for classifying gateway topology from a GatewaySelfInfo)
ModelFormatting (display-name and tooltip formatters)
Total: ~700 lines.
Plus the file mixes three coexisting parser conventions:
static class ChannelHealthParser with Parse(JsonElement) returning a typed ChannelHealth
Inline TryParse... static methods on record types
Inline From... factory methods on record types (e.g., GatewaySelfInfo.FromHealthPayload)
Why it matters
Models.cs is 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.
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:
ModelFormatting and GatewayTopologyClassifier are pure static helpers with no circular references; they can move to separate files with a simple cut-paste.
CommandCenterDiagnostics / CommandCenterCommandGroups are called from App.xaml.cs — moving them doesn't change the using directives already present, so it's mechanically safe.
What needs care:
ChannelHealthParser.Parse(JsonElement) returns a ChannelHealth record that lives in Models.cs. Moving the parser to a sibling file (Parsing/ChannelHealthParser.cs) requires ChannelHealth to remain in Models.cs or 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 TryParse on 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.
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.
Activity
github-actions commentedon May 17, 2026
🤖 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:
static TryParseon each record) as a follow-up — this is the larger change and benefits from being separate.The
Models.csreduction 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.shanselman commentedon May 18, 2026
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.