Skip to content

feat(tui): sort the credential table by field with a cycle key - #141

Merged
arimxyer merged 1 commit into
mainfrom
feat/tui-sort-toggle
Jul 1, 2026
Merged

feat(tui): sort the credential table by field with a cycle key#141
arimxyer merged 1 commit into
mainfrom
feat/tui-sort-toggle

Conversation

@arimxyer

@arimxyer arimxyer commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Adds a session-only sort control to the TUI credential table, addressing the "sort by specific fields" ask from discussion #89.

Supersedes #140, which GitHub auto-closed when its stacked base branch (fix/tui-case-insensitive-sort, PR #139) was merged and deleted. Same content, now rebased directly on main.

Summary

Sort state (field + direction) lives in AppState and defaults to Service ascending, so current behavior is unchanged until the user acts.

  • o — cycle the sort field: Service → Username → Last Used → Service
  • O — reverse the sort direction (ascending/descending)

The current sort is shown in the table title, e.g. Credentials (12) · Last Used ↓, and both keys are documented in the Help modal.

Design notes

  • Main table only. The category-grouped sidebar stays alphabetical — a "last used" ordering within category groups is confusing.
  • Deterministic ties. Every comparator falls back to Service (case-insensitive), so equal usernames / equal "Never" last-used values still order stably.
  • No new wiring. Refresh is driven through the existing OnFilterChanged callback.
  • o chosen over ss is already toggle_sidebar. o = "order by".
  • Session-only — resets to Service ↑ on relaunch. Config persistence was considered and deliberately deferred.

Test

  • TestAppStateSortState — default is Service ↑; field cycling wraps; direction toggles.
  • TestSortFieldString — title labels.
  • TestCredentialTableSortByField — table honors field + direction across Service/Username/Last Used, verifies reverse, and the Service tie-break (includes a lowercase entry and a "Never" last-used entry).

go test ./... ✓ · go vet ./... ✓ · golangci-lint run ./cmd/... → 0 issues ✓ · build ✓

Follow-ups (not in this PR)

🤖 Generated with Claude Code

Add a session-only sort control to the TUI credential table. Sort state
(field + direction) lives in AppState, defaulting to Service ascending
so existing behavior is preserved.

- `o` cycles the sort field: Service -> Username -> Last Used -> Service
- `O` reverses the sort direction (ascending/descending)

table.Refresh() applies the selected field and direction, with a Service
tie-break so ordering stays deterministic on equal keys, and the table
title shows the current sort (e.g. "Credentials (12) · Last Used ↓").
Refresh is driven through the existing OnFilterChanged callback, so no
new wiring is needed. The Help modal documents both keys.

Sorting applies to the main table only; the category-grouped sidebar
stays alphabetical. Persistence across restarts is intentionally out of
scope for this change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kVLjbUL4F4CkoA7RbMYy8
@arimxyer
arimxyer merged commit 116f39f into main Jul 1, 2026
7 checks passed
@arimxyer
arimxyer deleted the feat/tui-sort-toggle branch July 1, 2026 21:21
arimxyer added a commit that referenced this pull request Jul 2, 2026
Promote the [Unreleased] entries to [0.19.0] and add the two sort PRs
that shipped without changelog entries:
- TUI sort-by-field toggle (#141) under Added
- consistent case-insensitive ordering everywhere (#139) under Fixed

0.19.0 collects the background agent (#116), the env-injection epic
(#115: export/inject/exec --env-file/manifest, plus value filters #138),
the configurable sync probe timeout (#137), the TUI sort toggle (#141),
consistent ordering (#139), and the sync failure-backoff (#133).


Claude-Session: https://claude.ai/code/session_014kVLjbUL4F4CkoA7RbMYy8

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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