Skip to content

fix(sidebar): apply pinned rank only after an explicit reorder - #9724

Closed
rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/pin-order-only-after-explicit-reorder
Closed

rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/pin-order-only-after-explicit-reorder

Conversation

@rnoack1

@rnoack1 rnoack1 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Pinned sessions form a section ahead of the automatically sorted remainder, and before this change the rank driving that section was read from mc-pinned-session-order unconditionally. But membership bookkeeping writes that key from the first pin onwards, not only when someone reorders. So a stored order exists long before any row is dragged, and the pinned section freezes at whatever order a pin toggle happened to capture.

The symptom is that the sidebar's sort control stops working on pinned rows. A session touched minutes ago keeps a stale position while displaying a fresh timestamp, which reads as a broken sort rather than as an ordering preference being honoured.

Why it matters

It degrades with use: the more sessions you pin, the fewer rows the sort control reaches. On a sidebar where roughly 85% of sessions were pinned it governed almost nothing. The affected user has never used the reorder feature — they pinned sessions, which comparePinnedThenSort documents as "a reachability promise, not a ranking hint", and got the persistence of a feature they never invoked. There is also no UI affordance to reset the order, so the frozen state is not recoverable from the app.

What changed (motivation → approach → change)

Rank is a user preference, so it applies only once the user has stated one. A marker (mc-pinned-session-order-manual) records that intent and is set by reorderPinned alone — the single chokepoint both the drag handler and the Alt+Arrow handler already funnel through. Until it is set, the pinned section follows the active sort key like every other row.

Everything positional reads the order the user can actually see. Before the marker exists the rows render in naturalPinnedOrder while pinnedOrder still holds stored bookkeeping — two different sequences. effectivePinnedOrder resolves to the rendered one, and the reorder baseline, the keyboard peer walk and the drag indices all derive from it. Without this the first reorder would permute a list nobody is looking at: "move c above b" would resolve against the hidden order and persist a third arrangement, which would then become the manual order.

Deliberately narrow:

  • Membership bookkeeping is untouched. It keeps the stored order current, so the first reorder permutes an accurate list.
  • The rank map still feeds the drag affordances, which address rows by position. Only the comparator input is gated.
  • All three consuming surfaces read the marker — the expanded sidebar, the collapsed flyout, and the /sessions page — so a row cannot sit at one position on one surface and another elsewhere. Gating only the sidebar would have left /sessions still ranking by the ungated stored order, i.e. the reported defect surviving there while the sidebar was fixed. The /sessions ordering change is therefore deliberate and in scope.
  • One owner decides the arrangement is over, at the seam every removal passes through. Whatever empties the pinned set — an unpin, a delete, an archive, a bulk close, or another browser — publishes an authoritative slot list, so the detection lives once in a listener on sseSlots / fetchSlots.fulfilled (store/pinnedMarkerOwner.ts) rather than on each surface that can remove a pin. Hanging it off the surfaces meant the next one silently missed it: this PR only found the archive loop in ArtifactDetailPage because that path never calls the delete thunk. The two writers are trusted differently, and the difference is the point. A live frame is the server's current answer, so an EMPTY one counts — deleting the only session leaves no slots at all, and skipping that case stranded the marker for the commonest last-pin case there is. A refetch reply, by contrast, describes the moment its request was issued, so it is matched to the intent revision current when it started and ignored if a reorder overtook it in flight; acting on it would erase an arrangement the user had just stated. removeSlotOptimistic is deliberately not matched, because an optimistic removal is not a statement by the server: the pin it removes is still held there, so a rolled-back delete cannot be read as emptiness. Reordering once restores intent.
  • One new pinned-row menu item, scoped to the whole pinned section. "Follow sort order (all pinned)" appears on a pinned row's actions menu only while an arrangement is recorded, and hands the entire section back to the sort control. It is section-wide by design, because the arrangement it ends is section-wide — there is one arrangement, not one per row — and the label says so rather than leaving a per-row menu to imply otherwise. It is the in-app escape from the manual mode, which this change would otherwise leave exitable only by unpinning or closing every pinned session. There is deliberately no paired undo. An earlier revision shipped one, and it existed only to consume a third marker value that nothing else read, which made one rule look like two; the review that caught it was right. What ending an arrangement costs is therefore stated plainly here: the stored order is left untouched, but nothing reads it again until the user reorders once, and no menu action re-latches it. The marker is a plain two-state flag — recorded, or absent — and a single function removes it, whether the user asked or authoritative membership went empty. The label ships in every shipped locale catalog plus the generated pseudo-locale.
  • An arrangement ends when a snapshot shows sessions with none pinned. Whatever removed the last pin — an unpin here, a deletion, an archive, or another browser entirely — the next authoritative slots snapshot forgets the arrangement, so a later pin cannot inherit it. Zero slots is deliberately not that statement: a pre-hydration or filtered render looks identical, and acting on it would discard an arrangement that is still live. A deletion whose request may still roll back holds the same gate, so the rolled-back gap is not read as emptiness.
  • A self-drop states no preference. Dropping a pinned row onto itself is a no-op move, so it neither persists an order nor latches the marker — otherwise a stray drag would detach pinned rows from the sort control.

Upgrade migration, at the maintainer's explicit request: an earlier revision of this PR accepted a one-time trade — a user who had already reordered held a stored order but no marker, so their arrangement stopped displaying until they reordered once. The maintainer declined that trade as data loss for exactly the users who cared enough to reorder, so the migration ships instead: on first load, a stored order with no marker is adopted once as an explicit reorder (adoptStoredPinnedOrderAsManual, called from main.tsx before the first render), guarded by a once-per-browser flag so that ending an arrangement is not silently undone by the next reload.

What that costs, stated plainly: a stored order is also what ordinary pin bookkeeping leaves behind — commitPinnedSessionOperations persists it on a plain pin toggle with no marker write — and nothing from before the marker existed distinguishes the two. So every user with pinned sessions is adopted, not only those who dragged, and they keep the previous ordering until they use the pinned-row menu once. New users get the fix immediately.rather than hidden: the alternative is honouring every stored order, which is the bug.

Tests

ChatSidebar.pinnedOrderIntent.test.tsx asserts rendered row order rather than the comparator in isolation. The defect was in which rank the sidebar handed the comparator, so a unit test on comparePinnedThenSort passes either way and proves nothing about the wiring.

  • stored order, never reordered → rows follow date-desc.
  • stored order, reordered → the stored order wins. Locks in the existing feature.
  • first reorder → permutes the visible order (c,b,a → b,c,a), not the hidden stored one.

Both new behaviours are backed by negative controls — each fails on the unpatched code for the intended reason, not on a compile or harness error:

# gate reverted:            expected [ 'a', 'b', 'c' ] to deeply equal [ 'c', 'b', 'a' ]
# effective order reverted: expected [ 'a', 'b', 'c' ] to deeply equal [ 'b', 'c', 'a' ]

SessionFlyout.test.tsx is updated, not bent: it asserted that a stored order applies with no marker, which is precisely the contract this PR changes. It now sets the marker to express the intent it was always describing.

Manual verification

Screenshots of the real ChatSidebar over three pinned sessions whose titles ascend while their activity descends, so the two candidate orders are exact reverses and the frame cannot be read ambiguously. The capture script asserts the rendered sequence before it photographs, so a frame cannot show the wrong state.

Stored order present, never reordered — rows follow the sort key, newest first:

pinned rows ordered newest-first

Same stored order, after an explicit reorder — the user's arrangement wins:

pinned rows in the user's manual order

Reproduce: npx vite --host 127.0.0.1 --port 6817 --strictPort, then node scripts/capture-pinned-session-order.mjs http://127.0.0.1:6817 from website/.

Frames render in the default theme: ThemeProvider owns data-theme, so a per-theme query parameter does not change them. One frame per scene rather than two identically-themed frames under different names.

Pattern harvest

Rule candidate: review-prompt

Pattern: a persisted preference whose write path is wider than the intent it represents. mc-pinned-session-order is written by membership bookkeeping and by explicit reordering, so its presence cannot distinguish "the user arranged this" from "the user pinned something". Any gate keyed on storage is non-empty inherits that ambiguity and silently applies a preference nobody expressed. The prompt should ask, of any stored preference: is every writer of this key an expression of the intent the reader attributes to it? — and if not, require a separate intent marker rather than inferring intent from presence.

The same shape appears wherever a value doubles as a flag: a cache that also signals "feature used", a timestamp that also signals "seen", an order that also signals "curated".

Related Issues

None filed.

@rnoack1
rnoack1 requested review from a team and CrysisDeu September 9, 2026 14:31
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — 🟡 CONCERNS

UX-level review of c9ec6b323bb0d979a4a340a29e3698bceed73846 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence reviewed. The diff's user-visible surface is one new menu item ("Follow sort order (all pinned)") plus an ordering-behavior change across three surfaces; the PR's two screenshots are fork-hosted raw links the workflow couldn't download, and this lane has no blind read. Final review:

UX-Verdict: CONCERNS

Every existing user with pins is migrated into manual mode, and the only exit is a context-menu item nothing points them to.

Watch

  • The adoption in main.tsx (adoptStoredPinnedOrderAsManual) marks every user with a stored order manual — the PR states "every user with pinned sessions is adopted, not only those who dragged" — so the reported defect (sort control dead on pinned rows) persists for the whole existing base until they open a pinned row's menu and recognize "Follow sort order (all pinned)". High frequency (all upgraders with pins) × moderate friction × until discovered. Smallest fix: surface the same escape where the confusion happens — a one-line "Pinned rows keep your manual order" row in the sidebar's existing Sort menu.
  • "Follow sort order (all pinned)" instantly discards a possibly large hand-built arrangement with no undo; recovery is re-dragging every row, even though the exact order survives in storage and markPinnedSessionOrderManual() restores it verbatim (proven by the "restores the same arrangement" test). Rare action × moderate loss × once. An undo toast wired to that one call is nearly free.

Evidence gaps

  • The "Follow sort order (all pinned)" menu item appears in no screenshot — attach one showing the pinned-row actions menu with it visible.
  • The two ordering-state screenshots (stored-not-reordered / reordered) are raw.githubusercontent fork links, not PR attachments; they could not be fetched here. Re-attach as description attachments.
  • No blind read ran (fork lane) — first-time comprehension of the new label, especially the "(all pinned)" scope, is unverified. Pushing the branch to this repository enables it.

[UX-REVIEWED] c9ec6b3

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of c9ec6b323bb0d979a4a340a29e3698bceed73846 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

The evidence checks out: the defect's provenance is a new test asserting rendered order that fails on base, the quoted comparePinnedThenSort doc ("a reachability promise, not a ranking hint") exists at website/src/pages/chat/sessionOrder.ts:106-107, the capture harness follows a 273-file sibling convention, and all three rank-consuming surfaces are gated with no ungated sibling left. The one thing I cannot verify from the base checkout is the maintainer review comment the migration rests on.

First-Principles-Verdict: PASS

Verify on the PR thread that bolichen97 actually requested the adoption migration — adopting every pinned user (keeping the old ordering for them) rests entirely on that comment.

Not justified as shipped

    1. rides along — in-flight pin record moved to pinMutationsInFlight.ts and its export renamed; harm-free, forced by a documented import cycle with the store listener.
    1. rides along — screenshot capture harness (3 files); dev tooling, zero shipped surface, 273 sibling captures in website/capture/.

What this change ships

Inventory (10 items) — 8 justified

Intent: make the sidebar's sort control govern pinned rows until the user explicitly reorders them — a FIX (new rendered-order test fails on base).

  1. Sidebar pinned rows follow the active sort until an explicit reorder — justified
  2. The collapsed flyout applies the same gate — justified
  3. /sessions applies the same gate and now re-sorts live on arrangement changes — justified
  4. New pinned-row menu item "Follow sort order (all pinned)", visible only while an arrangement is recorded — justified
  5. An arrangement is forgotten when an authoritative slots snapshot shows nothing pinned — justified
  6. First load after upgrade adopts a pre-existing stored order as manual, once per browser — justified
  7. Dropping a pinned row onto itself no longer persists an order or latches intent — justified
  8. Two new browser-storage keys (…-manual, …-adopted) recording intent and the once-only adoption — justified
  9. In-flight pin record moved into pinMutationsInFlight.ts, pinMutationKeysInFlight renamed — rides along (import-cycle constraint)
  10. New capture harness for the pinned section's ordering — rides along (dev tooling, 273 siblings)

Checks run: readPinnedSessionOrder rank consumers on base = 3 (ChatSidebar, SessionFlyout, SessionsPage), all 3 gated, 0 unfixed siblings; quoted comparator doc confirmed at sessionOrder.ts:106; adoptStoredPinnedOrderAsManual has 1 consumer (main.tsx), a one-shot migration; docs/spec updated in the same commit as AGENTS.md mandates.

[FIRST-PRINCIPLES-REVIEWED] c9ec6b3

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of c9ec6b323bb0d979a4a340a29e3698bceed73846 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Premises verified against the base tree: the reducer's empty-frame rejection and slotsGeneration semantics the new listener relies on exist as described (dashboardSlice.ts:440-443), and the base code already documented pinning as "a reachability promise, not a ranking hint" (ChatSidebar.tsx:4130) — so the rewritten flyout test pinned an accident, not a decision, and the PR kept its manual-rank assertion under the new marker rather than deleting it.

Design-Verdict: PASS

Root-cause fix — a separate intent marker resolves the writer-wider-than-intent ambiguity, with migration, an in-app escape, and every consuming surface gated consistently.

The concurrency guards (in-flight window, generation-matched refetch, single settle owner) each carry a named failure they prevent, are individually tested with negative controls, and the change is cleanly revertible — leftover localStorage keys are inert. The adoption trade (all pinned users keep the old ordering until one menu click) was explicitly decided by the maintainer and, unlike the pre-PR state, is recoverable in-app. Spec and feature-map docs are updated in the same commit.

[DESIGN-REVIEWED] c9ec6b3

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed c9ec6b323bb0d979a4a340a29e3698bceed73846 via the fork AI-review pipeline; updated in place on each push.

Review details

Based on my analysis, I've verified the candidate against the real reducer and RTK listener semantics.

Confirmed the finding is real. The candidate claims the fetchSlots.fulfilled settle arm in the new pinnedMarkerOwner.ts is dead in production. I verified independently:

  • fetchSlots.pending effect captures slotsGeneration (= G) into generationWhenRequested — the pending reducer does not touch slotsGeneration.
  • The real fetchSlots.fulfilled reducer (dashboardSlice.ts:769) runs state.slotsGeneration = (state.slotsGeneration ?? 0) + 1 before the listener effect reads state (RTK listener middleware notifies effects after next(action); listenerApi.getState() is post-reducer).
  • So the fulfilled effect reads slotsGeneration = G+1 (minimum), while requested = G. The guard requested !== (state?.slotsGeneration ?? 0) is therefore always true → the effect returns before settleIfAuthoritative ever runs.
  • The bundled test pinnedReconnectRefetch.test.ts passes only because its stub reducer (state = { slotsLoaded: true }) => state never increments slotsGeneration, so requested (0) === slotsGeneration (0). It masks the production behavior.

Consequence chain is concrete: reconnect dispatches fetchSlots (useWebSocket.ts:1064); the reply is, per this file's own comment, "the only membership channel a reconnect has before its first live frame." With a stale manual marker set and all pins removed while offline, the reply reports zero pins but the arm never fires, so the marker is not cleared and a later pin set freezes in pin-toggle order — the exact defect this PR exists to remove.

Not BLOCKING: the harm is a persisted UI-ordering preference not clearing in an edge case (not a crash, data loss, corruption, or credential exposure), and the fix is in-diff.

No blocking findings.

FINDING — website/src/store/pinnedMarkerOwner.ts:74 — the fulfilled guard requested !== (state?.slotsGeneration ?? 0) is always true in production because the real fetchSlots.fulfilled reducer increments slotsGeneration before the effect reads it, so the refetch/reconnect settle arm never runs and a stale manual-order marker survives an offline all-unpin → Fix: compare against the reply's own increment, e.g. requested + 1 === (state?.slotsGeneration ?? 0), or record the post-reply generation rather than the request-time value.

[OPUS-REVIEWED] c9ec6b3

@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed c9ec6b323bb0d979a4a340a29e3698bceed73846 via the fork AI-review pipeline; updated in place on each push.

Review details

FINDING -- website/src/store/pinnedMarkerOwner.ts:76 -- requested !== state.slotsGeneration compares against the post-fulfillment generation, so reconnect refetches never clear stale manual ordering -> Fix: compare requested + 1 to the current generation.
[GPT-REVIEWED] c9ec6b3

@rnoack1
rnoack1 force-pushed the fix/pin-order-only-after-explicit-reorder branch 2 times, most recently from a72190e to 00c04ee Compare September 9, 2026 16:38
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 9, 2026
@rnoack1
rnoack1 force-pushed the fix/pin-order-only-after-explicit-reorder branch from 00c04ee to f215f2d Compare September 9, 2026 18:51
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention labels Sep 9, 2026
@rnoack1
rnoack1 force-pushed the fix/pin-order-only-after-explicit-reorder branch 3 times, most recently from cac5b0c to fff6f5a Compare September 9, 2026 20:11
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 9, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@rnoack1
rnoack1 force-pushed the fix/pin-order-only-after-explicit-reorder branch from 277ef1d to 7c06664 Compare September 10, 2026 02:10
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@rnoack1
rnoack1 force-pushed the fix/pin-order-only-after-explicit-reorder branch from 7c06664 to 415e512 Compare September 10, 2026 02:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 10, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maintainer decision by @bolichen97 (agent-assisted). The bug is real and the gate is wired correctly (pinnedRankForSort is undefined until mc-pinned-session-order-manual is '1', set only by reorderPinned after a successful write). What we do not want to ship is the "one-time trade": a user who already dragged their pinned sessions into an order has no marker, so on upgrade that order is silently discarded and the rows follow the active sort. That is data loss for exactly the users who cared enough to reorder.

Please add the migration: on first load, if a stored pinned order exists and the marker is absent, latch the marker (treat the stored order as an explicit reorder). Never-reordered users have no stored order and get the fix immediately; reordered users keep what they built. Then:

  • update docs/system-specs/modules/learn-cron-dashboard.md:1654 ("manual order applies only after an explicit reorder; until then pinned rows follow the active sort", plus the two clear events);
  • fix the pinnedSessionOrder.ts:65 comment ("never cleared" is false — clearPinnedSessionOrderManual clears it);
  • add the no-marker negative case to SessionFlyout.test.tsx, drop the stray whitespace line at ChatSidebar.tsx:7109, and re-pin the screenshots to the head SHA.

@rnoack1

rnoack1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 — five of your six items are fixed at head 64906452d247dee19b895cc882ee44c1737a9d8c. Evidence for each, since your line numbers had drifted and I want you to be able to check them without hunting:

  • pinnedSessionOrder.ts comment. You cited :65; the line is :66. It now reads "Set once the user has explicitly reordered the pinned section. Cleared by an explicit "Follow sort order", and removed outright once nothing is pinned." You were right that "never cleared" was false — two functions clear it, and the comment now names both events.
  • Spec doc. You cited learn-cron-dashboard.md:1654, which is avatar-tier prose; the pinned-order passage is :1678. It now carries your wording — "manual order applies only after an explicit reorder; until then pinned rows follow the active sort" — plus why the stored order cannot stand in for intent, and both clear events.
  • Flyout negative case. SessionFlyout.test.tsx:107, ignores a stored order while no reorder has been recorded: a stored order present with the marker absent must follow the sort key. Removing the flyout's gate makes exactly that case fail, so it is not vacuous.
  • Stray whitespace line. You cited ChatSidebar.tsx:7109; the only whitespace-only line was at :7158. It is gone — the file now has zero, and the diff adds zero.
  • Screenshots re-pinned. Both images in the description pointed at an old commit; they now resolve at this head.

The migration is the one item I have not implemented, and I want to be straight with you about why rather than quietly shipping around it. Its stated premise is that never-reordered users have no stored order. That does not hold in the base tree: commitPinnedSessionOperations persists the order on a plain pin toggle, with no marker write, so anyone who has ever pinned already has a stored order and no marker — indistinguishable from someone who dragged. Latching the marker for "stored order present, marker absent" therefore treats pin bookkeeping as intent for the majority of pinners, which restores the exact freeze this change removes; when I implemented it, it inverted three of the tests that pin the fix's contract.

I am not arguing the goal away — you are right that silently dropping a curated arrangement is real data loss, and the reviewers agree it needs an answer. There are three ways to give you one, and the choice is yours rather than mine: accept the trade with a one-time in-product notice explaining that one re-drag restores the order; add a discriminator now that distinguishes a dragged order from bookkeeping, and migrate in a later release once it has data to read; or narrow the migration to orders that pin sequence cannot explain, if a heuristic is acceptable. Say which and I will build it.

@rnoack1

rnoack1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 — five of your six items are verified fixed at head 44526f51451b5e5417da3c11d2c156fbf258f6cf. Your line numbers had drifted, so each item below names the line I actually read, to save you hunting.

  • pinnedSessionOrder.ts comment. You cited :65; it is :66-67, and it now reads "Set once the user has explicitly reordered the pinned section. Cleared by an explicit "Follow sort order", and removed outright once nothing is pinned." You were right that "never cleared" was false, and the comment now names both events that end it.
  • Spec doc. You cited learn-cron-dashboard.md:1654, which is avatar/PUT prose; the pinned-order passage is :1678. It carries your wording — "manual order applies only after an explicit reorder; until then pinned rows follow the active sort" — plus why a stored order cannot stand in for intent, and both clear events.
  • Flyout negative case. SessionFlyout.test.tsx:107, ignores a stored order while no reorder has been recorded: a stored order with the marker absent must follow the sort key. Removing the flyout's gate makes exactly that case fail, so it is not vacuous.
  • Stray whitespace line. You cited ChatSidebar.tsx:7109; the only whitespace-only line was at :7158. The file now has zero, and the diff adds zero.
  • Screenshots re-pinned to this head.

The migration is not in this head, and I want to be straight with you about why rather than leave it looking overlooked. I implemented it exactly as you specified — a one-shot boot-time latch, tests and all. A subsequent premise-level review then filed it as a BLOCK and required its removal, on the following grounds, which I had independently measured and disclosed when I built it:

The premise "never-reordered users have no stored order" does not hold in the base tree. commitPinnedSessionOperations persists the pinned order on a plain pin toggle, with no marker write, so a stored order is also exactly what ordinary pin bookkeeping leaves behind. Nothing distinguishes the two before the marker existed. Latching on "stored order present, marker absent" therefore adopts pin bookkeeping as intent, which keeps the frozen pinned section — the reported symptom — for every existing user who ever pinned, escapable only by using the new menu item once. For a heavily-pinned sidebar that is most of the section, so the fix would not reach the person who reported it.

So both positions are defensible and they are mutually exclusive: shipping the migration protects users who genuinely dragged and preserves the defect for those who only pinned; omitting it fixes the defect for everyone and costs a curated arrangement once, recoverable by one re-drag. That is a product call about which cost this release takes, and it is yours rather than mine — I have implemented both sides on request and am not trying to settle it by argument.

Three ways forward, any of which I can build: accept the omission, with a one-time in-product notice explaining that one reorder restores an arrangement; add a discriminator now that records a dragged order distinctly, and migrate in a later release once there is something unambiguous to read; or ship the migration knowingly, in which case the PR description needs a line stating that never-reordered users keep the old behaviour until they use the menu item. Tell me which and it goes in the next revision.

@rnoack1

rnoack1 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — the migration is in, and all four follow-on items are done. Everything below is verified at head 8fd54b562a5df259c4159297eb36b22aa9cfb827.

Migration — adoptStoredPinnedOrderAsManual() at website/src/utils/pinnedSessionOrder.ts:132, called once at boot from website/src/main.tsx:57 before the first render. Exactly your rule: stored order present and marker absent → latch; no stored order → untouched. Five cases in website/src/test/pinnedOrderAdoption.test.ts, including the no-marker negative you asked for; stubbing the adoption to return false fails the positive case, so it is not inert.

One guard I added that your description does not call for, because it is load-bearing here: since the marker is now two-state, ending an arrangement removes it, so "no marker" can no longer distinguish a user who never arranged from one who just chose to follow the sort. A once-per-browser flag (mc-pinned-session-order-adopted) is what stops every reload re-adopting and silently undoing that choice. does not re-adopt on a later load after the user opted out pins it.

Spec doc — docs/system-specs/modules/learn-cron-dashboard.md:1678 carries your wording verbatim plus both clear events. (Your :1654 is :1678 in this tree.)

The :65 comment — now at :66-67: "Set once the user has explicitly reordered the pinned section. Cleared by an explicit "Follow sort order", and removed outright once nothing is pinned." No "never cleared" text remains anywhere in the file.

One correction to that item: clearPinnedSessionOrderManual no longer exists. It was merged into a single forgetPinnedSessionOrderManual after a review flagged two functions doing one job, so the comment now names the two real clear events rather than a function.

Flyout negative case — website/src/test/SessionFlyout.test.tsx:107, ignores a stored order while no reorder has been recorded.

Whitespace at ChatSidebar.tsx:7109 — zero whitespace-only lines in the file.

Screenshots — re-pinned to this head.

One consequence of the migration worth stating plainly

Your premise was that never-reordered users have no stored order. In the base tree that does not hold: commitPinnedSessionOperations persists the order on a plain pin toggle without writing any marker, so a stored order is also what ordinary pin bookkeeping leaves behind, and nothing before the marker existed distinguishes the two.

So the adoption is broader than "users who dragged": anyone with pinned sessions is adopted, and keeps the current behaviour until they use the pinned-row menu once. New users get the fix immediately, everyone else with one click. That trade is recorded in the function's own docstring so it cannot be lost. Happy to narrow it if you would rather gate on something else, but I did not want to ship it without saying so.

@rnoack1

rnoack1 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Re-anchoring my earlier note to the current head, since the branch has moved twice since I wrote it. All six items verified at 95e7d8ab22b692419dc5569d6aa0bfaddc4e71bb:

  • Migration — adoptStoredPinnedOrderAsManual() at website/src/utils/pinnedSessionOrder.ts:145, called once at boot from website/src/main.tsx:57 before the first render. Your rule exactly: stored order present and marker absent → latch; no stored order → untouched. Five cases in website/src/test/pinnedOrderAdoption.test.ts; stubbing the adoption to return false fails one of them, so it is not inert.
  • Spec — docs/system-specs/modules/learn-cron-dashboard.md:1678, your wording plus both clear events (your :1654 is :1678 in this tree).
  • The :65 comment — now :67; zero occurrences of "never cleared" anywhere in the file. One correction: clearPinnedSessionOrderManual no longer exists, having been merged into a single forgetPinnedSessionOrderManual, so the comment names the two real clear events rather than that function.
  • Flyout negative case — website/src/test/SessionFlyout.test.tsx:107.
  • Whitespace — zero whitespace-only lines in website/src/pages/ChatSidebar.tsx.
  • Screenshots — re-pinned to this head.

Two things I corrected since that note, both worth flagging rather than leaving for you to find:

A test asserting the pre-migration behaviour had survived in the tree alongside the migration's own test, so the suite contradicted itself. That file is gone, and the sweep for it is clean.

The PR description still described the one-time trade as accepted and named the shipped behaviour as the bug. It now describes the migration and states its cost: because plain pin bookkeeping also persists an order, every user with pinned sessions is adopted, not only those who dragged — they keep the previous ordering until they use the pinned-row menu once. Happy to narrow that if you would rather gate on something else.

@rnoack1

rnoack1 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Re-verified each item at head c90b5bec66e908017d3c4582280e028a50416790, reading the files rather than carrying an earlier reply forward:

  1. Migration — adoptStoredPinnedOrderAsManual() in website/src/utils/pinnedSessionOrder.ts:122 latches the marker on first load when a stored order exists and the marker is absent, guarded by a one-time adopted key so it cannot re-fire. Called at boot from website/src/main.tsx:58. Five cases covered in website/src/test/pinnedOrderAdoption.test.ts, including the stored-order-without-marker case you described.
  2. Spec doc — updated; the sidebar-ordering paragraph in docs/system-specs/modules/learn-cron-dashboard.md now states that manual order applies only after an explicit reorder.
  3. Comment — the inaccurate "never cleared" wording is gone (0 occurrences); website/src/utils/pinnedSessionOrder.ts:67 now says the marker is set on an explicit reorder and cleared by an explicit action.
  4. Negative case — website/src/test/SessionFlyout.test.tsx:107, "ignores a stored order while no reorder has been recorded".
  5. Whitespace — no whitespace-only lines remain in website/src/pages/ChatSidebar.tsx.

Item 6 (screenshots) is still outstanding: I have not been able to regenerate them in this environment, and the repository does not permit committing captured frames, so that one needs a hand with a browser.

Separately, on your point about not shipping the one-time trade: a review lane has flagged that the migration also adopts users whose stored order came from plain pin bookkeeping rather than a drag, since the order is persisted on any pin toggle. The migration is in place as you asked; that broader question is noted for a maintainer call rather than changed unilaterally.

@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🔴 BLOCK (blocking)

Which legitimate operations does 4f5841b6901397d10bdcb1b218c8f286de5711d7 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

no leg reported, and this was not the nothing-to-adjudicate short circuit

No [SCOPE-REVIEWED] marker for this head was produced, so the model's text is withheld: it cannot be shown to describe this revision. See the job logs.

@rnoack1

rnoack1 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Re-verified your six items at head 00418720a52489b6d948ff9de5ba98f8b74e6338, reading each file at that head rather than relying on an earlier round:

  1. Migration — adoptStoredPinnedOrderAsManual() in website/src/utils/pinnedSessionOrder.ts latches the marker on first load when a stored order exists and no marker does, behind a one-time receipt so it cannot re-fire; the marker is rolled back if that receipt fails to write, so a quota failure cannot consume the single adoption chance. Called at boot from website/src/main.tsx. Five cases in website/src/test/pinnedOrderAdoption.test.ts, including the stored-order-without-marker upgrade you described. I also confirmed the test can detect a missing latch: stubbing the latch alone fails exactly that case and no other.
  2. Spec doc — the sidebar-ordering entry in docs/system-specs/modules/learn-cron-dashboard.md now states that manual order applies only after an explicit reorder, names both clear events, and records the first-load adoption.
  3. Comment — the "never cleared" wording is gone; that docstring now says the marker is set by an explicit reorder and cleared by an explicit action or an empty pin set.
  4. Negative case — added to website/src/test/SessionFlyout.test.tsx as "ignores a stored order while no reorder has been recorded".
  5. Whitespace — no whitespace-only lines remain in website/src/pages/ChatSidebar.tsx.
  6. Screenshots — still outstanding. I have not been able to regenerate them in the environment I am working in, and the repo does not permit committing captured frames, so this one needs someone with a browser.

One thing worth flagging rather than leaving in a review comment thread: a review lane has pointed out that the migration also adopts users whose stored order came from ordinary pin bookkeeping rather than a drag, because the order is persisted on any pin toggle. I looked at whether the two can be told apart and they cannot from the stored order alone — pin bookkeeping appends on pin and filters on unpin, so any order is reachable by pinning in that sequence with no drag at all. The migration is implemented as you asked; whether it should be narrowed is a product call I have left open rather than decided.

@rnoack1

rnoack1 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Verified at head c9ec6b323bb0d979a4a340a29e3698bceed73846: five of the six items are addressed. The remaining one and the red check both need a decision from you rather than another revision, so I have not pushed anything.

1. The migration — done. adoptStoredPinnedOrderAsManual() is called at website/src/main.tsx:58, before the first paint, so the initial sidebar render already reflects an adopted order. It latches through PINNED_SESSION_ORDER_ADOPTED_KEY, so a reload cannot re-adopt and silently undo a later "Follow sort order", and it records the decision even when nothing was there to adopt.

2. The spec — done. docs/system-specs/modules/learn-cron-dashboard.md:1812 (the line moved from :1654). It carries the "manual order applies only after an explicit reorder; until then pinned rows follow the active sort" wording, a sentence covering the first-load adoption, and both clear events — the explicit "Follow sort order" action, and an authoritative snapshot showing nothing pinned.

3. The pinnedSessionOrder.ts comment — done. "never cleared" no longer appears in the file. It now reads "Cleared by an explicit "Follow sort order", and removed outright once nothing is pinned."

4. The no-marker negative case — done. In website/src/test/SessionFlyout.test.tsx: it('ignores a stored order while no reorder has been recorded'). The file's beforeEach(() => localStorage.clear()) guarantees the marker is absent, and it asserts the rendered rows do not follow the stored order.

5. The stray whitespace — done. website/src/pages/ChatSidebar.tsx has zero trailing-whitespace lines.

6. Re-pinning the screenshots — this would break them, so I left it. The two images point at 95e7d8ab22b692419dc5569d6aa0bfaddc4e71bb, where both PNGs are in the tree and the raw URLs return 200. At the current head, temp-screenshots/pinned-order-intent/ is not in the tree and the same URLs return 404, so re-pinning as written would replace working images with broken ones. Either leaving the older working pin or re-committing/regenerating the PNGs at head is fine by me — the second costs a new head and a full CI re-run, which is why I am asking rather than choosing.


On the one red check, before spending a revision on it. The i18n render-time gate fails [vs-base] with developer-storage.text: 34 -> 38 (+4). All four added findings are latin-leak/untranslated-text on strings like "12B" and "9B", at website/src/pages/LocalStorageDebug.tsx:199 and :213 — both of which render formatBytes(e.bytes).

This PR touches neither LocalStorageDebug.tsx nor DeveloperPage.tsx. What it does add is localStorage keys, and that page renders one byte size per key, so the count rose because there are more rows to render, not because an unlocalised string was introduced.

The gate advises extracting "B" into the catalog and rendering it with t(). I do not think that is right here: formatBytes delegates to fmtBytes and then fmtUnit, which uses Intl.NumberFormat with style: 'unit' at website/src/i18n/format.ts:210 — real CLDR formatting, deliberately tuned across the shipped locales. website/src/i18n/unitLiterals.test.ts exists to forbid hand-rolled unit strings, and its own sample of defects the repo carried before Phase 4 includes bytes + ' KB'. Under en-XA there is no CLDR data, so Intl falls back to en and emits a Latin B, which the gate cannot distinguish from a string that never reached a catalog.

If that reading is right, any PR that adds a localStorage key trips this gate, and the suggested fix would regress localisation for the real locales to satisfy the pseudo-locale. How would you prefer it handled — teach the gate to tolerate Intl-formatted units, exclude that surface, or accept it as debt? The same run also reports the debt record is stale on 5/55 surfaces, overstating text by +12.

@chenmingwei23

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: chenmingwei23]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: The maintainer's CHANGES_REQUESTED is a specific mechanical checklist, not a design reconsideration ("the bug is real and the gate is wired correctly"). I'll add the requested first-load migration that latches the manual-order marker for users who already reordered (prevents silent data loss), update the doc line and the stale pinnedSessionOrder.ts comment, add the no-marker negative test, drop the stray whitespace line, re-pin screenshots, and rebase onto main to clear the conflict. Design direction unchanged.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

Membership bookkeeping stores a pinned order from the first pin onwards, so rank
froze the pinned section at whatever a pin toggle captured and the sort key stopped reaching it.

Copy link
Copy Markdown
Contributor

PR triage (automated, 2026-10-05) — OVERLAPPING with #14233 · needs rebase

Head checked: c5e19ebb, compared with origin/main@a97659df.

Rebase needed. The merge base c293d24 is 2003 commits behind main. git merge-tree against main conflicts in website/src/pages/ChatSidebar.tsx, website/src/main.tsx, website/src/components/SessionActionsMenu.tsx and docs/feature-map/README.md. Since then, #15094 (merged) moved the pinned-order hooks out of ChatSidebar.tsx into website/src/pages/chat-sidebar/pinnedOrder.ts. That means usePinnedSessionOrder and usePinnedOrderAuthority now hold the pinnedRank, reorderPinned and naturalPinnedOrder code this PR gates. The defect is still on main: pinnedRank is built from the stored order without any intent marker (chat-sidebar/pinnedOrder.ts:35, SessionsPage.tsx:114, chat/SessionFlyout.tsx:138). So this PR is not superseded.

Overlap to discuss with #14233 (open, feat(sidebar): keep the pinned-session order on the gateway):

  • Both PRs fix the same thing: the pinned rank should apply only after an explicit reorder, not after a pin toggle. They do it in ways that can't both land.
    • This PR adds a browser-side mc-pinned-session-order-manual marker, store/pinnedMarkerOwner.ts, pinMutationsInFlight.ts and a first-load adoptStoredPinnedOrderAsManual().
    • feat(sidebar): keep the pinned-session order on the gateway #14233 moves the order to the gateway (chat_pinned_order.json / pin_rank). It removes persistPinnedSessionOrder, commitPinnedSessionSnapshot and commitPinnedSessionOperations from utils/pinnedSessionOrder.ts, and keeps mc-pinned-session-order only as a one-time legacy hand-off.
  • Files both PRs edit: utils/pinnedSessionOrder.ts, chat/SessionFlyout.tsx, SessionsPage.tsx, hooks/useSessionActions.ts, the sidebar pinned-order owner and their tests.
  • Migration: both PRs treat any existing local order as intentional. That includes orders written only by pin bookkeeping: this PR through adoptStoredPinnedOrderAsManual, feat(sidebar): keep the pinned-session order on the gateway #14233 through the only_if_unset hand-off. So for existing users, either PR keeps the "sort control ignores pinned rows" symptom until the user takes an explicit action. Please settle this rule once, for whichever design is chosen.
  • Suggested next step: decide which PR owns pinned-rank authority before rebasing this one. If feat(sidebar): keep the pinned-session order on the gateway #14233 is the direction, this PR's client-side marker machinery mostly goes away. If this PR goes first, feat(sidebar): keep the pinned-session order on the gateway #14233 has to carry the marker semantics over.

An open review finding still holds at this head: in website/src/store/pinnedMarkerOwner.ts, the fetchSlots.fulfilled arm compares requested !== state.slotsGeneration. But the real reducer bumps slotsGeneration before listeners run (dashboardSlice.ts:771 at the merge base). That makes the refetch arm unreachable in production. pinnedReconnectRefetch.test.ts hides this because its stub reducer never increments the generation. The effect: with the socket down, emptying the pin set through a refetch leaves the marker set. That doesn't lose data, so it isn't a blocker on its own, but it should be fixed during the rebase.

Not a breaking change and no P0 found. The existing CHANGES_REQUESTED from the maintainer still applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants