feat(sessions): sort session list by filesystem modTime#2972
Merged
Conversation
e1ed596 to
02a1eac
Compare
ZaynJarvis
commented
Jul 2, 2026
ZaynJarvis
left a comment
Collaborator
Author
There was a problem hiding this comment.
Codex Review
Verdict: LGTM — no blocking issues
Structure: Single commit, 6 files, all changes are on-topic (session recency sorting + file tree modTime sort). No unrelated changes.
Design: The approach is correct. mod_time is already present in viking_fs.ls() output, so adding it to the list response is zero extra I/O. Frontend simplification from 1+N requests to 1 is a clear win.
One design note (non-blocking, already discussed with author):
- Directory mtime ≠ last-activity time. On Unix filesystems, a directory's mtime only updates when entries are created/deleted/renamed inside it — not when an existing file (like
messages.jsonlor.meta.json) is written in-place. So a session receiving new messages may not bubble to the top of the list. This is a trade-off vs. the previous approach of reading.meta.json'supdated_atper session. Acceptable for the 1-request simplification; revisit if users report stale ordering.
Fix applied during review: Renamed reversedSessions → playgroundSessions in agent-panel.tsx — the variable no longer reverses anything, it just filters from the recency-sorted list.
Compatibility: mod_time is an additive field. Existing callers (Python SDK, bot) use .get() to access dict fields, so no breakage.
The AgentPanel used to call POST /sessions on every page load (via a
useEffect gated on botHealth.isSuccess), creating empty UUID sessions
even when the user never sent a message. These orphan sessions cluttered
the session list.
Fix: generate a client-side UUID as the initial sessionId instead of an
empty string. The session is lazily created on the backend by the first
addMessage call (POST /sessions/{id}/messages uses auto_create=True).
- Remove startSession() and its auto-create useEffect
- Always have a sessionId (createRandomUuid fallback)
- Simplify useChat params (persistMessages always true, no preview fallback)
- Remove dead isCreating UI branch
- Call onSessionChange on mount so the URL stays in sync
- Error retry button now uses handleNewSession()
Closes: orphan empty sessions created on playground page load
- Backend: add mod_time to session list API response (from viking_fs.ls stat) - Frontend: useSessionListByRecency sorts by mod_time instead of N detail fetches - Frontend: sidebar and playground history use recency-sorted list - Frontend: sortTreeEntries sorts directories by modTime descending Reduces session list load from 1+N requests to 1 request.
02a1eac to
dc5ee7f
Compare
qin-ctx
approved these changes
Jul 3, 2026
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.
Summary
Session lists in the web studio (sidebar + playground history) were sorted by name order with a
.reverse()hack. This PR adds proper recency sorting using the session directory's filesystem mtime.Changes
Backend (
openviking/service/session_service.py)sessions()list API now includesmod_timefromviking_fs.ls()stat output — zero extra I/O since the entry already carries itFrontend types (
web-studio/types/ov-server/api/v1/sessions.ts)SessionListItemgainsmod_time: stringFrontend hooks (
web-studio/src/lib/sessions/use-sessions.ts)useSessionListByRecencysimplified: sorts bymod_timedirectly from the list response instead of issuing N per-session detail requests viauseQueriesFrontend consumers
app-shell.tsx: sidebar usesuseSessionListByRecency, removes.reverse()hackagent-panel.tsx: playground history filters from the recency-sorted listFile tree (
web-studio/src/routes/playground/-lib/utils.ts)sortTreeEntriessorts directories bymodTimestampdescending (newest first), fallback to nameImpact
updated_atfrom .meta.json