Skip to content

feat(files): sort file tree by modification time #163

Description

@angellei10112358

Below are generated by agents:

Problem

The Files tab (FileTreeView) always shows directories first, then files by name. That order comes straight from the server: GET /file returns FileNode[] with only name, path, absolute, type, ignored, and upstream File.list sorts by a.name.localeCompare(b.name). The client does no local sorting (visibleNodes just flattens fileTreeRoot).
When revisiting a project, I usually want the most recently touched files on top, not an alphabetical walk.

Expected

A sort toggle in the Files tab: Name (current behavior, default) vs. Modified (most recent first). Keep directories-first to avoid confusion, only change ordering within each group. Persist the choice.

Suggested fix

Two small additive changes:

  1. Server: add optional mtime to File.Node in packages/opencode/src/file/index.ts (stat per entry in File.list). Old clients ignore unknown keys, so backward compatible.
  2. Client: decode let mtime: Double? in FileNode (Services/APIClient.swift:543), sort in FileTreeView.visibleNodes when the toggle is set, fall back to name when mtime is nil (older servers).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions