Skip to content

Sy 4118 improve mosaic tab rename syncrhonization#2266

Open
emilbon99 wants to merge 6 commits intorcfrom
sy-4118-improve-mosaic-tab-rename-syncrhonization
Open

Sy 4118 improve mosaic tab rename syncrhonization#2266
emilbon99 wants to merge 6 commits intorcfrom
sy-4118-improve-mosaic-tab-rename-syncrhonization

Conversation

@emilbon99
Copy link
Copy Markdown
Contributor

@emilbon99 emilbon99 commented Apr 26, 2026

Issue Pull Request

Linear Issue

SY-####

Description

Basic Readiness

  • I have performed a self-review of my code.
  • I have added relevant, automated tests to cover the changes.
  • I have updated documentation to reflect the changes.

Greptile Summary

This PR replaces the useSyncName push-based hook with a renderer-owned NameHook pattern: each renderer (LinePlot, Log, Table, Schematic, Arc, Range Overview, Task Form) exposes a static useName property, and a new CustomTabName component in Mosaic.tsx calls it to subscribe to remote name changes and propagate user-initiated tab renames back to the server. New useRetrieveObservableName hooks are added across all pluto query modules to subscribe to live resource name changes via the existing flux observable infrastructure.

Confidence Score: 4/5

Safe to merge with awareness of the previously flagged workspace-sync gap in LinePlot's inline title path.

Score is capped at 4 by the previously-flagged P1 (handleTitleChange in LinePlot.tsx replacing syncDispatch with plain dispatch, dropping multi-window workspace sync for inline title edits). The new NameHook architecture is well-structured, the prior broken-guard bugs are fixed, and new integration tests cover both rename directions.

console/src/lineplot/LinePlot.tsx (handleTitleChange workspace sync), console/src/hardware/common/task/Form.tsx (useName declaration order)

Important Files Changed

Filename Overview
console/src/layout/useFluxName.ts New factory that creates NameHook instances; correctly defaults isEnabled to true when useEnabled is omitted, fixing the prior remote-guard bug.
console/src/layouts/Mosaic.tsx Adds CustomTabName and TabName components that bridge renderer.useName into the Tabs system via useEffect-based retrieve and handleRename callbacks.
console/src/lineplot/LinePlot.tsx Removes push-based usePrevious/useEffect sync; handleTitleChange uses plain dispatch + renameRemote, dropping syncDispatch (already flagged in prior review).
console/src/layout/slice.ts Adds NameHook type, NameHookResult interface, and attaches useName? to the Renderer type — clean extensibility point.
console/src/hardware/common/task/Form.tsx Removes useSyncName and adds a standalone useName NameHook with taskKey-gated retrieve/onRename; hook is assigned to Wrapper after wrapForm closes (module init order is safe but fragile).
pluto/src/tabs/Selector.tsx DefaultName exported, Name render-prop plumbed through context; level now uses locally-computed variable (functionally identical to prior inline expression).
pluto/src/text/Editable.tsx Adds React-19-style ref forwarding via ref: propsRef destructuring and combines it into useCombinedRefs.
pluto/src/lineplot/queries.ts Adds resource ontology listener to mountListeners and exports useRetrieveObservableName for name-only change subscription.
console/src/schematic/Schematic.tsx Removes push-based name sync; snapshot early-return in useSyncComponent simplified to just return (no rename); Schematic.useName added.
console/src/range/overview/Overview.tsx Overview.useName created without a useEnabled guard — isEnabled defaults to true, which is correct since ranges are always server-backed; prior broken-guard concern is addressed.

Sequence Diagram

sequenceDiagram
    participant Remote as Server (Remote)
    participant RN as useRetrieveObservableName
    participant TN as TabName / CustomTabName
    participant Dispatch as Redux (Layout slice)
    participant DP as Tabs.DefaultName

    note over TN: Mount – TabName detects renderer.useName
    TN->>RN: useName(tabKey, handleNameChange)
    note over TN: useEffect fires retrieve()
    TN->>Remote: retrieve({ key: tabKey })
    Remote-->>RN: onChange(result) → result.data.name
    RN-->>Dispatch: handleNameChange → Layout.rename

    note over DP: User edits tab name inline
    DP->>TN: handleRename(key, newName)
    TN->>Dispatch: dispatch(Layout.rename)
    TN->>Remote: hookOnRename(newName) → useRename.update

    note over Remote: External rename (e.g., another window)
    Remote-->>RN: observable fires with new name
    RN-->>Dispatch: handleNameChange → Layout.rename
Loading

Comments Outside Diff (4)

  1. console/src/arc/editor/Editor.tsx, line 11-12 (link)

    P2 Single-letter variable names reduce readability

    arc was renamed to a, and the same pattern appears in Log.tsx (logl) and Table.tsx (tablet). These one-letter names make the code harder to scan — the original descriptive names conveyed the type at a glance.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  2. console/src/layout/useSyncName.spec.tsx

    P2 Tests deleted with no replacement

    useSyncName.spec.tsx is removed along with the hook it tested, but no tests for the new NameHook / CustomTabName / useName pattern are added. The prior tests covered the two-way sync (remote → layout slice and layout state → remote). These paths are now handled by each renderer's useName hook and by CustomTabName's handleNameChange / handleRename, neither of which has coverage.

  3. console/src/hardware/common/task/Form.tsx, line 83-85 (link)

    P2 retrieve silently no-ops when taskKey is null

    When the task hasn't been persisted yet (taskKey == null), retrieve() returns without fetching, so onChange is never called and the tab name stays at whatever value the layout slice already has. This is probably intentional, but the asymmetry with other useName hooks (which always call baseRetrieve) could cause the tab name to be stale if the task key becomes available after the component mounts — the observable won't start until the next retrieve.

  4. console/src/lineplot/LinePlot.tsx, line 449-453 (link)

    P1 handleTitleChange drops workspace sync

    syncDispatch was replaced with plain dispatch. The syncDispatch variant propagates Layout.rename across windows (multi-window workspace sync); plain dispatch is local-only. When the plot's inline title editor is used to rename the layout the workspace will no longer be notified, causing the name to diverge between open windows.

    Previously syncDispatch(Layout.rename(...)) handled both local update and workspace propagation in one call. Now only dispatch (local) and renameRemote (server resource) are called — the workspace sync path is missing for this code path.

Reviews (5): Last reviewed commit: "updated console names" | Re-trigger Greptile

Comment thread console/src/layouts/Mosaic.tsx Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 19.32773% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.82%. Comparing base (08db767) to head (d9aca28).
⚠️ Report is 1 commits behind head on rc.

Files with missing lines Patch % Lines
console/src/layouts/Mosaic.tsx 0.00% 16 Missing and 2 partials ⚠️
console/src/hardware/common/task/Form.tsx 14.28% 10 Missing and 2 partials ⚠️
pluto/src/arc/queries.ts 14.28% 5 Missing and 1 partial ⚠️
pluto/src/lineplot/queries.ts 25.00% 5 Missing and 1 partial ⚠️
pluto/src/log/queries.ts 25.00% 5 Missing and 1 partial ⚠️
pluto/src/ranger/queries.ts 14.28% 5 Missing and 1 partial ⚠️
pluto/src/schematic/queries.ts 25.00% 5 Missing and 1 partial ⚠️
pluto/src/table/queries.ts 25.00% 5 Missing and 1 partial ⚠️
pluto/src/task/queries.ts 25.00% 5 Missing and 1 partial ⚠️
console/src/lineplot/LinePlot.tsx 0.00% 5 Missing ⚠️
... and 8 more

❌ Your patch check has failed because the patch coverage (19.32%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##               rc    #2266      +/-   ##
==========================================
- Coverage   63.92%   63.82%   -0.11%     
==========================================
  Files        2156     2152       -4     
  Lines      109353   109174     -179     
  Branches     8298     8288      -10     
==========================================
- Hits        69906    69678     -228     
- Misses      33425    33475      +50     
+ Partials     6022     6021       -1     
Flag Coverage Δ
pluto 54.93% <28.81%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread console/src/layout/useFluxName.ts Outdated
…8-improve-mosaic-tab-rename-syncrhonization
Comment thread console/src/arc/editor/Editor.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant