Skip to content

test(tui): cover empty-session and continue selection (#48) - #57

Merged
quickbeard merged 2 commits into
mainfrom
test-empty-session-select
Jul 13, 2026
Merged

quickbeard merged 2 commits into
mainfrom
test-empty-session-select

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Summary

Adds unit tests for the startup session-selection logic introduced in #48 (skip the home screen and start in a new session).

The logic was inline in app.tsx; this extracts it into two pure, behavior-preserving helpers in packages/tui/src/util/session.ts so it can be tested directly (matching the existing dialog-session-list pattern of exporting pure functions for tests):

  • selectEmptySession(sessions, directory) — the leftover empty session that plain startup reuses (newest parentless, unarchived, default-titled session in the current directory).
  • selectContinueSession(sessions) — where -c lands (newest parentless conversation, skipping default-titled auto-created empties, falling back to the newest overall).

app.tsx now calls these instead of the inline filter/sort chains; no runtime behavior changes.

Tests

test/util/session.test.ts covers:

  • selectEmptySession: newest-in-directory reuse; ignoring archived/parented/titled/other-directory rows; any-directory when none is given; no match.
  • selectContinueSession: preferring the newest real conversation; falling back to newest when all default-titled; skipping child sessions; empty list.

Verification

  • bun test test/util/session.test.ts — 9 pass.
  • bun typecheck in packages/tui — clean.

🤖 Generated with Claude Code

quickbeard and others added 2 commits July 13, 2026 20:19
Extract the startup empty-session reuse and the `-c` continue resolver from
app.tsx into pure `selectEmptySession`/`selectContinueSession` helpers in
util/session, and unit test their filtering, ordering, and fallbacks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 30fcdc2 into main Jul 13, 2026
3 of 5 checks passed
@quickbeard
quickbeard deleted the test-empty-session-select branch July 13, 2026 13:34
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