Skip to content

Add author and token count sorting#256

Open
Archkr wants to merge 2 commits into
prolix-oc:stagingfrom
Archkr:staging
Open

Add author and token count sorting#256
Archkr wants to merge 2 commits into
prolix-oc:stagingfrom
Archkr:staging

Conversation

@Archkr

@Archkr Archkr commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Add Author and Token Count sorting to the Characters browser and Token Count
sorting to the Personas browser. Character author ordering is case-insensitive,
keeps blank authors last, and uses character name/id tie-breakers. Character
token totals count Description, Personality, and Scenario separately before
server-side pagination. Persona token totals count Description through a new
authenticated, user-scoped POST /api/v1/personas/token-counts endpoint.

Both token sorts resolve the active profile model, fall back to the default
profile model, and ultimately use the existing ceil(text.length / 4) behavior
when no exact tokenizer is available. Persona requests are made only while
Token Count is selected and use a generation guard so stale model/persona
responses cannot replace current counts. Group Chats continue to expose only
Recent, Name, and Created. Labels were added to all six existing locales.

No main-menu sorting button, persona author field, database migration, or schema
change is included.

Validation

Commands and results:

bun test src/services/characters.service.test.ts src/routes/personas.routes.test.ts frontend/src/lib/characterSort.test.ts frontend/src/lib/personaTokenSort.test.ts src/macros/MacroEnv.test.ts
# 32 pass, 0 fail, 64 assertions across 5 files

bun x tsc --noEmit
# Passed with no output

cd frontend && bun run typecheck
# Passed; TypeScript project build completed

cd frontend && bun run lint
# Passed with 0 errors and 0 warnings

cd frontend && bun run build
# Passed; production bundle and PWA service worker built successfully

Manual validation used an isolated temporary Lumiverse instance and disposable
30-character/30-persona data set. Verified:

  • Character Author and Token Count options, both directions, blank authors last,
    stable pagination, search interaction, and persistence after reload.
  • Character Token Count ordering using the fallback tokenizer path.
  • Group Chats exposes only Name, Recent, and Created.
  • Persona Token Count in both directions, pagination, search/filter interaction,
    and persistence after reload.
  • Desktop layout and a 390x844 responsive mobile viewport.
  • No warning/error entries in the validation browser console.

The isolated server and disposable validation data were removed afterward.

Required checklist

  • This pull request is based on the latest staging branch and targets
    staging, not main.
    Current local branch is staging, but no remote sync or PR target was
    performed/verified.
  • All applicable tests pass.
  • I ran the relevant type check(s) with no type errors or warnings:
    • Backend: bun x tsc --noEmit
    • Frontend: cd frontend && bun run typecheck, bun run lint

UI changes (if applicable)

  • I validated this change in more than one browser.
  • I verified the integrated experience on a mobile interface or through
    the mobile PWA.
  • Browsers, devices, and PWA coverage: Codex in-app browser at its desktop
    viewport and at a 390x844 responsive mobile viewport. An installed PWA and a
    second browser were not tested.

Performance changes (if applicable)

  • I added or updated tests.
  • I included reproducible benchmarks and comparison results below.
  • Benchmark commands and results: Not run. Character token sorting intentionally
    resolves ordering before pagination and reuses the tokenizer service's loaded
    tokenizer and content-hash count caches. Focused tests cover stable pagination.

Security-sensitive changes (if applicable)

The new persona token-count endpoint uses the authenticated user id and queries
only that user's persona ids/descriptions. It accepts only an optional string
model_id. No Spindle surface, privilege boundary, database schema, or stored
credential behavior changed; no separate security audit was performed.

LLM-assisted work (if applicable)

  • I, as the human orchestrating this work, audited the submitted changes
    in a live environment.

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