Skip to content

feat(cli): --name <title> for custom session display titles (#99)#202

Merged
quangdang46 merged 2 commits into
masterfrom
feat/cli-name-custom-session-title
May 22, 2026
Merged

feat(cli): --name <title> for custom session display titles (#99)#202
quangdang46 merged 2 commits into
masterfrom
feat/cli-name-custom-session-title

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

Adds the missing CLI affordance requested in issue #99. Random animal-themed names work great for whimsy but don't help when juggling several projects.

Usage

jcode --name 'review pr 412' run 'review the diff'
jcode --session-name 'feature-X' run 'continue feature work'   # alias

Existing sessions are unaffected — jcode session rename <id> <name> still applies for those.

Changes

  • src/cli/args.rs: --name <text> (alias --session-name) global flag.
  • src/cli/startup.rs: parse_and_prepare_args translates the flag into the JCODE_SESSION_NAME env var so deep code paths read it without arg threading.
  • src/session.rs: Session::create reads JCODE_SESSION_NAME ONLY when parent_id is None (top-level only — subagents/spawned children stay random-named for clarity) AND title arg is None (explicit title always wins).
  • src/session_tests/cases.rs: jcode_session_name_env_titles_top_level_session covers all three branches.

Tests

$ cargo test -p jcode --lib jcode_session_name
test result: ok. 1 passed; 0 failed

Notes

The issue's secondary request — "default to working-directory basename" — is intentionally NOT bundled here. That changes existing UX (random animal names → directory name) for everyone, and should be opt-in via a config option in a separate PR (recommend session.name_format = "random" | "directory").

Adds the missing CLI affordance requested in issue #99. Today the
session list shows random animal-themed names ("Garden Scorpion",
"Garden Sauropod") which carry no semantic meaning when juggling
several projects.

Behavior:
  jcode --name 'review pr 412' run 'review the diff'
  jcode --session-name 'feature-X' run 'continue feature work'

Translates to the JCODE_SESSION_NAME env var in
parse_and_prepare_args (alias --session-name on the same flag).
Session::create reads the env var and sets it as the new session's
`title` ONLY when:
  - parent_id is None (top-level session, not a subagent/spawn child)
  - title argument is None (caller hasn't already supplied a title)

Existing sessions are unaffected — `jcode session rename <id> <name>`
still applies for those.

Test `jcode_session_name_env_titles_top_level_session` covers all
three branches: top-level pickup, child-no-pickup, explicit-arg-wins.

Closes #99
@quangdang46 quangdang46 merged commit 53f0746 into master May 22, 2026
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