Insert New Metrics at Their Default Position - #120
Conversation
New rows were appended at the bottom of Customize. Place them in the provider's default position, and one-time re-slot Cursor Grok Bot and Grok Rate Limit Resets that already landed at the end.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
🟢 Approval recommended
The ordering change is well-contained, the migration is versioned/idempotent, and the PR adds targeted tests covering both insertion and the v5 re-slot behavior.
Pull request overview
This PR updates Runway’s layout ordering/migration logic so newly shipped metrics appear in their provider’s declaration-order position (instead of being appended to the bottom), and adds a one-time schema migration to re-slot two already-shipped metrics for existing installs.
Changes:
- Update
LayoutOrderingnormalization to insert newly introduced metric IDs into saved orders at their canonical (declaration) slots. - Add a v5 settings migration to relocate
cursor.grokBotandgrok.rateLimitResetsinto their intended positions for existing layouts, using frozen “v5 canonical” order lists. - Add/adjust tests and documentation to cover the new ordering + migration behavior.
File summaries
| File | Description |
|---|---|
| Tests/RunwayTests/SettingsMigratorTests.swift | Updates v4 assertions to use SettingsSchema.current and adds a v5 migration test validating the two row relocations. |
| Tests/RunwayTests/LayoutOrderingTests.swift | Adds unit coverage for inserting, relocating, and the new “insert instead of append” normalization behavior. |
| Sources/Runway/Stores/LayoutBootstrap.swift | Changes metric-order normalization to insert new live metrics at declaration-order slots; adds helper functions for insertion/relocation. |
| Sources/Runway/Stores/DefaultLayout.swift | Updates comments/expanded defaults documentation to reflect Grok + Cursor row placement intent. |
| Sources/Runway/App/SettingsMigrator.swift | Bumps schema to v5 and adds the migration step + frozen canonical orders for Cursor and Grok. |
| docs/dashboard.md | Documents that new default metrics appear in the provider’s default position and clarifies Grok Rate Limit Resets placement. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
The new v5 migration throws on JSON decode/encode failures, which can block the entire settings migration cascade for users with corrupted layout data.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
| SettingsMigration(version: 5) { defaults in | ||
| let key = "runway.layout.v1.metricOrderByProvider" | ||
| guard let data = defaults.data(forKey: key) else { return } | ||
| var order = try JSONDecoder().decode([String: [String]].self, from: data) | ||
| if let cursor = order["cursor"] { | ||
| order["cursor"] = LayoutOrdering.relocating( | ||
| ["cursor.grokBot"], | ||
| in: cursor, | ||
| canonical: v5CursorMetricOrder | ||
| ) | ||
| } | ||
| if let grok = order["grok"] { | ||
| order["grok"] = LayoutOrdering.relocating( | ||
| ["grok.rateLimitResets"], | ||
| in: grok, | ||
| canonical: v5GrokMetricOrder | ||
| ) | ||
| } | ||
| defaults.set(try JSONEncoder().encode(order), forKey: key) | ||
| } |
TL;DR
New metrics now land in the provider's default Customize slot instead of at the bottom. Existing installs one-time re-slot Cursor Grok Bot above Extra Usage and Grok Rate Limit Resets above usage history.
What was happening
LayoutOrderingappended it to the savedmetricOrderByProviderlist, so it appeared at the bottom of Customize (and the dashboard) even when its declaration order put it in the middle.What this changes
Heads-up
metricOrderByProvider. Fresh installs already declare the right order.Tests
swift test --filter LayoutOrderingTests --filter SettingsMigratorTests