Repository navigation
test(tui): cover empty-session and continue selection (#48) - #57
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inpackages/tui/src/util/session.tsso it can be tested directly (matching the existingdialog-session-listpattern 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-clands (newest parentless conversation, skipping default-titled auto-created empties, falling back to the newest overall).app.tsxnow calls these instead of the inline filter/sort chains; no runtime behavior changes.Tests
test/util/session.test.tscovers: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 typecheckinpackages/tui— clean.🤖 Generated with Claude Code