Skip to content

Restore persisted Studio resource monitor - #10237

Merged
wasimysaid merged 4 commits into
unslothai:mainfrom
wasimysaid:fix/studio-monitor-persistence
Sep 4, 2026
Merged

wasimysaid merged 4 commits into
unslothai:mainfrom
wasimysaid:fix/studio-monitor-persistence

Conversation

@wasimysaid

@wasimysaid wasimysaid commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Third follow-up split from #10209 at reviewer request. Restacked onto current main after #10236 merged.

Head: 60accfd215ec783438a6c134ba75ccbcd1a86a0a

  • restore a resource monitor persisted open after reload even when Settings has never opened
  • give Settings and the floating monitor separate lazy lifetimes
  • transfer monitor ownership without duplicate mounted or visible panels
  • preserve monitor position/state while Settings opens and closes

Exact browser assertions

The real Settings dialog and persisted monitor stores were driven in Chromium and Firefox:

  • persisted-open reload: one visible monitor without opening Settings
  • Settings open/close: one monitor before, during, and after ownership transfer
  • no duplicate monitor nodes and no page/console errors
  • every Settings tab, deep-open target, search jump, and LAN QR/copy target remains functional

An additional isolated local Studio run on the restacked head confirmed the persisted monitor after reload, simultaneous System-tab and overlay rendering with exactly one floating monitor, and an in-bounds 390×844 layout with no console errors.

Verification

  • focused frontend suites: pass (144 and 69 tests)
  • desktop reliability contracts: pass (36 tests)
  • npm run typecheck: pass
  • production build and bundle check: pass
  • Python compile, Biome, diff, stray-file, AGPL, and static review gates: pass
  • isolated local Studio + Firefox desktop/mobile flow: pass

Exact-head Codex review requested for 60accfd2.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@wasimysaid
wasimysaid force-pushed the fix/studio-monitor-persistence branch from a996264 to e34c713 Compare September 3, 2026 09:48
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

Exact-head convergence update for 6ad627d2680c01ff63e89a31a2714d22f34397e3:

  • monitor ownership is centralized in SettingsDialogMount; there is exactly one production mount
  • persisted-open reload restores before Settings opens, and opening/closing Settings keeps exactly one monitor
  • Chromium and Firefox Settings/persistence suites pass; typecheck, production build, and bundle check pass
  • independent exact-head review found no remaining genuine production issue
  • the tip commit is pre-commit.ci formatting only; the monitor-only functional commit remains e34c713470a995bdba67de3f18db02cd9ece5422

@wasimysaid
wasimysaid force-pushed the fix/studio-monitor-persistence branch from 6ad627d to f1e4e47 Compare September 3, 2026 12:31
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

Fresh-main convergence update for f1e4e477bfedd7db3d6adb6f05409fbd2f085332 (rebased onto 01262664ea4662686bdde90caf247e8177813119):

  • preserved the stacked lazy-loading and monitor-persistence commits; the fresh-main changes had no file overlap before the rebase
  • fixed the four reproduced stale source-contract failures introduced by the rebase without changing runtime behavior
  • the formerly red exact-head jobs are now green: Frontend build + bundle sanity, Frontend unit tests (Windows), and Repo tests (CPU)
  • all 35 completed checks are green; the macOS integration job remains queued for runner capacity
  • local verification: 6,820 frontend units, focused CPU contract, typecheck, production build, bundle budget, pre-commit, post-fix audit, worktree checks, and pre-push gate all pass

Codex review is currently quota-capped, so I did not post another trigger.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T15:30:23.344127Z 60accfd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cea620db1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +79 to +81
useEffect(() => {
if (pendingStep === 0 || count === 0 || appliedPendingStepRef.current)
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear deferred steps after a zero-result search

When the lazy find chunk is still loading, pressing Enter with an empty or nonmatching query sets pendingStep; after the real engine reports zero matches, this guard returns without clearing it. If the user subsequently types a query with multiple matches, the stale step is applied as soon as count becomes positive, unexpectedly advancing past the initial result even though Enter was pressed for the previous query.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0fbb31e with a focused regression.

Comment on lines +84 to +85
{monitorMounted && (
<LazyImportBoundary

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide the monitor failure after it is closed

If the monitor chunk rejects after the user has toggled the monitor back off—for example, they click “Show” and then “Hide” while a stale deployment chunk request is pending—monitorMounted remains latched and this branch still renders the error boundary's fallback. The result is a persistent monitor-load alert for a monitor whose isOpen state is false, with no way to dismiss it except reloading; the failed fallback should be gated by monitorOpen even if the lazy component itself remains mounted for later reuse.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0fbb31e with a focused regression.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fbb31e65e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +70 to +71
fallback={
<LazyImportFailure

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide the settings failure after the dialog closes

If the Settings chunk rejects after the user closes its loading state—for example, opening Settings and pressing Escape while the request is pending—settingsMounted remains latched and this unconditional fallback appears even though settingsOpen is false. The resulting centered alert outlives the dismissed dialog and cannot itself be closed; gate it on settingsOpen, as the monitor failure fallback is.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new head with the same gated-fallback regression covering both lazy settings surfaces.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: d9ab3149cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid
wasimysaid force-pushed the fix/studio-monitor-persistence branch from d9ab314 to 60accfd Compare September 4, 2026 15:27
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 60accfd215

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

Live Studio before/after UI evidence

Tested two isolated local Studio installs with Chromium:

  • BEFORE: merge base e8a88546ddef77ac6efc3d034ba4a142e7f61179
  • AFTER: PR head 60accfd215ec783438a6c134ba75ccbcd1a86a0a
  • viewports: 1280×720 and 390×844
  • both sides started with the same persisted overlay state (isOpen=true, isMinimized=false) before first navigation; Settings was never opened
  • the closed Settings chunk was deliberately made unavailable to exercise the independent lazy-lifetime behavior rather than merely show the same happy path twice

Desktop

PR 10237 desktop before and after

Mobile

PR 10237 mobile before and after

Head-only ownership/regression check

The real Settings → System monitor and floating overlay were then opened together on the head. There was exactly 1 Settings dialog, 1 floating-monitor node, and 1 visible floating monitor (not a duplicate):

PR 10237 System settings and floating monitor

Measured result

Assertion BEFORE AFTER
closed Settings chunk requested 1 0
desktop visible monitors 0 1
desktop load-failure cards 1 0
mobile visible monitors 0 1
mobile load-failure cards 1 0
Settings dialogs during reload scene 0 0
unexpected HTTP errors / page exceptions 0 / 0 0 / 0

The mobile monitor measured x=118, y=660.06, w=256, h=167.94, fully inside the 390×844 viewport. I inspected all final images: no duplicate monitor, clipping, overflow, broken layering, or other scoped visual regression was visible. Live CPU/RAM/disk/VRAM data also rendered in the System view.

Persistent sanitized image assets: https://github.com/wasimysaid/unsloth/releases/tag/pr-10237-ui-evidence-60accfd

@wasimysaid
wasimysaid merged commit 99a83f6 into unslothai:main Sep 4, 2026
35 of 36 checks passed
danielhanchen pushed a commit that referenced this pull request Sep 4, 2026
…sertion

`test_auth_flow_routes_do_not_mount_global_settings` asserted the literal
`if (!active || !mounted) return null;` in settings-dialog-mount.tsx. #10237
added the resource monitor and renamed that flag to
`settingsMounted || monitorMounted`, so the assertion has been failing on main
against a file that still has exactly the property the test was written to
protect: the mount refuses to render while inactive, which is what keeps the
settings dialog off the login and change-password routes.

Match the guard rather than the spelling. Removing `!active` from the condition
still fails the test, checked both ways.
Souravrajvi0 pushed a commit to Souravrajvi0/unsloth that referenced this pull request Sep 4, 2026
…rd (unslothai#10307)

`Repo tests (CPU)` was red on `main` at `99a83f6a6` and `a2a4143ce`, and so on PRs branched from them, on one test out of 15,899:

```
FAILED tests/studio/test_auth_form_input_count.py::test_auth_flow_routes_do_not_mount_global_settings
  assert 'if (!active || !mounted) return null;' in mount
```

unslothai#10237 gave `SettingsDialogMount` a second surface, so the single lazy-mount flag became two:

```diff
-  const [mounted, setMounted] = useState(open || monitorOpen);
-  if (!active || !mounted) return null;
+  if (!active || !(settingsMounted || monitorMounted)) return null;
```

That is right and it did not open the auth routes. `!active` still short-circuits, so an inactive mount still renders nothing, which is the whole of what this test is named for. The other two assertions in the test still match byte for byte, so the chain it protects, auth route to `active={false}` to nothing rendered, is intact at every link. The assertion had simply quoted the auth gate and the lazy-mount bookkeeping as one string.

## The change

Assert the property rather than a spelling: `SettingsDialogMount` must return null from its own top level on every inactive render. The guard is read as a parse, because a textual match is what got us here:

- Comments and string bodies are blanked first, in a same-length copy so indices still line up. The assertion this replaces matched `// if (!active || !mounted) return null;` just as happily as the live line, so the guard could have been struck out entirely and the test would have stayed green.
- The slice is the real function body. The signature is `({ active }: { active: boolean })`, so the body brace is found by walking the parameter list rather than taking the first brace after the name.
- Only statements directly in that body count, so `(active) => { if (!active) return null; }` cannot answer for the component.
- The condition must be a disjunction whose first operand is `!active`. A top-level `?` or `,` disqualifies it, since both bind looser than `||`: `!active || mounted ? false : true` and `!active || track(), active` each leave the disjunction as a discarded sub-expression and skip the return while inactive. `?.` and `??` are neither.
- `{ return null; }` is accepted alongside `return null;`, so a bracing pass does not go red for nothing.

This is the same shape as unslothai#10267, unslothai#10231, unslothai#10289 and unslothai#10297. The file had already reached that conclusion twice on its own, as "Lock the count, not the spelling, so a rename does not falsely fail" and "Lock the behaviour, not one spelling of it, so either form passes". This assertion had not had the treatment.

## Verified by breaking it

The predicate was checked directly against 15 conditions, all correct. Then fifteen edits to `settings-dialog-mount.tsx`, each run against the test, next to what a plain re-sync of the literal would give:

| edit | re-synced literal | this change |
| --- | --- | --- |
| baseline | passed | passed |
| both mount flags renamed | **failed** | **passed** |
| a third surface joins the mount | **failed** | **passed** |
| the operands reordered | **failed** | **passed** |
| back to a single flag, as before unslothai#10237 | **failed** | **passed** |
| optional chaining in the second operand | **failed** | **passed** |
| the guard braced by a formatter | **failed** | **passed** |
| the `!active` half dropped | failed | failed |
| `||` becomes `&&` | failed | failed |
| the whole guard deleted | failed | failed |
| the gate inverted to `active` | failed | failed |
| a ternary swallows the disjunction | failed | failed |
| a comma expression discards the disjunction | failed | failed |
| the guard moved into a nested callback | failed | failed |
| the guard survives only as a comment | **passed** | **failed** |

Six harmless forms pass where a re-sync goes red on all six, none of which touches the auth routes. Nine real regressions fail. The last row is the one that matters most: a re-sync, and the assertion that was there before it, both accept a guard that exists only as a comment.

`tests/studio`: 7483 passed, 195 skipped. No source changes. Staging CI green.
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Sep 6, 2026
The find bar became its own lazily loaded module on main (unslothai#10236), the index
grew portal surfaces and `renumbersMatches` (unslothai#10237), and unslothai#10209 landed its own
Hangul handling. Resolved by keeping both sides:

- `OffsetRuns`, `unsafe` and `shifted` sit alongside `rootLength` and
  `surfaces` on `FindTextIndex`, and `buildTextIndex` returns all of them.
- `CLUSTER_PATTERN` and the Hangul spelling helpers are main's, which require
  the vowel and carry the lint exemption. `canonicalSource` uses
  `partiallyComposedHangul` for the half-composed spelling and keeps the
  longest-first sort the grapheme fence needs.
- Every component-source assertion now reads `find-bar.tsx`, and the store
  tests are main's, since the store is gone.

`check-bundle-budget.ts` is back to main's: the branch only reflowed its
comments and added a note that the find bar is eager, which main's lazy split
has made untrue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants