Focus queue: prioritize recently-finished agents above running ones (#333) - #338
Open
germanescobar wants to merge 1 commit into
Open
Focus queue: prioritize recently-finished agents above running ones (#333)#338germanescobar wants to merge 1 commit into
germanescobar wants to merge 1 commit into
Conversation
…333) The on-radar (focus queue) sidebar used to sort pinned sessions by `focusPinnedAt ?? createdAt` ascending (oldest-pin-first). That buried the agent that just stopped on its own — the one that actually needs attention — under long-idle sessions the user forgot to unpin. Replace the single ascending sort with a partition + two sorts: 1. Finished (inactive) sessions — most recently finished first (`lastActiveAt` desc). 2. Running (active) sessions — oldest running first, so the most recently started running session lands at the very bottom (`lastActiveAt` asc). The radar-inclusion filter (`Boolean(session.focusPinnedAt)`) is unchanged, so manually unpinned sessions still don't appear. No server changes; `lastActiveAt` is already updated at the locations called out in the issue. Extract the sort into a small pure helper `sortFocusQueue` so it can be unit-tested in isolation, and add tests covering all-finished, all-running, mixed, ties on `lastActiveAt`, and the active-state transition (a session flipping from active to inactive moves from bottom to top in the same render). Refs #333.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #333.
What changed
The on-radar (focus queue) sidebar used to sort pinned sessions by
focusPinnedAt ?? createdAtascending — i.e. oldest-pin-first. That buried the agent that just stopped on its own — the one that actually needs attention — under long-idle sessions the user forgot to unpin.Replace the single ascending sort with a partition + two sorts:
lastActiveAtdesc).lastActiveAtasc).From top to bottom:
Why this shape
Boolean(session.focusPinnedAt)) is unchanged, so manually unpinned sessions still don't appear — anduserUnpinned === trueis server-side only, never reaches the client filter, so it can't regress.focusDoneAtdoes not enter the sort: sessions marked done clearfocusPinnedAton the server (updateSessionFocusinserver/lib/sessions.ts) and the sidebar filter removes them, so they never reach the queue.lastActiveAtalready doubles as the "finished-at" timestamp; the server updates it at the locations called out in the issue (reply, agent stream close). No new field needed.sortFocusQueue(items)exported fromclient/src/components/sidebar.tsxso it can be unit-tested in isolation. TheuseMemoinSidebarjust builds the items and calls the helper.Acceptance criteria
focusPinnedAtis unset (still hidden from radar) or where the user has manually unpinned (userUnpinned === true).Validation
client/src/components/__tests__/sidebar-sort-focus-queue.test.tsx— 6/6 pass:lastActiveAt→ stable-sort fallback to array order (matches the issue's explicit allowance)sidebar-delete-loading,sidebar-help-link,settings-responsive,agents-section,focus-advance-toast, or the lib helpers).node --import tsxsmoke-import ofsidebar.tsxsucceeds (bothsortFocusQueueandSidebarexport correctly).Out of scope