Skip to content

Session naming: default launch uses bare name (code-reasonix), only -n gets a timestamp #401

@wviana

Description

@wviana

Observed

How Session name Old session preserved?
reasonix code (first run) code-reasonix N/A
Relaunch without flags Resumes code-reasonix ✅ — but in-place, same file
reasonix code -n / --new code-reasonix-202503211430
/new in TUI Same session (e.g. code-reasonix) ❌ — messages overwritten

How we got here

  • Before PR feat: Timesteamped session allowing mutiple sessions by project. #12 — no timestamped sessions at all. Every launch used the bare name (code-reasonix). Starting fresh overwrote in place.
  • 043dcb7 (Apr 30)feat: Timestamped session allowing multiple sessions by project introduced timestampSuffix(), findSessionsByPrefix(), resolveSession().
  • 9714d11 (same day)Fix for new session without interaction falling back to default old session style patched findSessionsByPrefix to exclude .events.jsonl sidecars.
  • 34464ff (same day, PR feat: Timesteamped session allowing mutiple sessions by project. #12)fix(session): preserve old sessions on "new"; clean .plan.json sidecars (#12) landed the current design.

The current logic (session.ts:107):

forceNew=true     →  code-reasonix-<timestamp>   (from -n/--new)
forceNew=false    →  code-reasonix               (default launch path)
forceResume=true  →  code-reasonix-<timestamp>   (latest prefixed)

The default branch (!forceNew && !forceResume) still resolves to the bare name with no timestamp — same as before the PR. The timestamp suffix was only wired into the --new and --resume paths.

The asymmetry

Three places create a "new" session, each with different semantics:

Trigger What happens
reasonix code (first launch) Plain name, no timestamp — but there's nothing to overwrite, so no harm.
reasonix code -n / --new Timestamped name — old session preserved.
/new in TUI loop.clearLog() rewrites .jsonl to [] — old messages lost, same filename.

Additionally, /new at runtime doesn't call resolveSession at all — it just truncates the current session file. So even if the default launch path were fixed to always use timestamps, /new would still overwrite in place.

Questions

  1. Should every session name carry a timestamp by default (not just -n/--new)? So reasonix code creates code-reasonix-202503211430, and re-launching without flags picks up the latest code-reasonix-*.

  2. Should /new in the TUI also spin off a new timestamped session instead of truncating the current one? This would preserve old conversations for later browsing via /sessions.

  3. Is the current /new design (truncate in place) intentional to keep the system prompt hash stable for cache-first? The comment at clearLog says "keeps session + immutable prefix (cache-first invariant)" — but the system prompt hash derives from rootDir, not sessionName, so a timestamped child session would produce the same hash.

Related: resolveSession already exists and works — it just isn't wired into the launch default path or the /new slash handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions