Skip to content

feat(prompt): show project (folder) name in the interactive prompt#625

Open
adi07das wants to merge 1 commit into
mpfaffenberger:mainfrom
adi07das:feature/prompt-project-name
Open

feat(prompt): show project (folder) name in the interactive prompt#625
adi07das wants to merge 1 commit into
mpfaffenberger:mainfrom
adi07das:feature/prompt-project-name

Conversation

@adi07das

@adi07das adi07das commented Jul 14, 2026

Copy link
Copy Markdown

The problem

When you're running multiple Code Puppy sessions across different terminal tabs/windows (one puppy working on repo A, another on repo B, maybe a third on some quick scratch dir), it's really hard to tell at a glance which puppy is working on which project.

Today, the only way to figure it out is to scroll up through the session history looking for the last 'cd' command or an early message that mentions the project. On busy sessions that can be a lot of scrolling.

The fix

The interactive prompt now displays the name of the folder the puppy is currently pointing to, right between the model badge and the full cwd path.

Before:
Booster [Code Puppy] [claude-sonnet-4-5] (~/workspace/repo-a) >>>

After:
Booster [Code Puppy] [claude-sonnet-4-5] repo-a (~/workspace/repo-a) >>>

Flip to another tab and you immediately see 'repo-b' instead of 'repo-a' without touching the scrollback. The label follows 'cd' — inside /workspace/repo-a/tests it shows 'tests', in /tmp it shows 'tmp', at $HOME it shows ''.

Implementation

  • New '_get_project_name(cwd)' helper: basename of the current working directory, with a '~' shortcut for $HOME.
  • New 'project' entry in PROMPT_STYLES so themes and the persistent bottom-bar prompt can style it consistently.
  • The fragment carries 'class:tui.warning' so it visually pops against the model's 'class:tui.title', and a local Style rule ('bold ansired') keeps it colored even without a theme plugin.
  • Zero new runtime dependencies. No subprocess or filesystem walking on every prompt render — just 'os.path.basename(os.path.normpath(cwd))'.

Tests

  • '_get_project_name': cwd basename, nested subdirectory, and $HOME
  • 'get_prompt_with_active_model': renders project name + carries the new 'class:project class:tui.warning' style token
  • Existing prompt/statusline tests still green (236 tests pass locally)

Co-Author: Aditya Das aditya.das@walmart.com

@mpfaffenberger

Copy link
Copy Markdown
Owner

This is not redundant with showing the folder?

## The problem

When you're running multiple Code Puppy sessions across different
terminal tabs/windows (one puppy on repo A, another on repo B, maybe a
third on some quick scratch dir), it's hard to tell at a glance which
puppy is working on which project. Today you have to scroll up through
the session history looking for the last 'cd' or an early message that
names the project.

Just showing the raw cwd path helps a little, but it doesn't survive
navigating into subdirectories: once you're at
'~/workspace/big-monorepo/packages/api/src/handlers', the path is long,
the meaningful bit (the repo name) is buried in the middle, and every
other tab looks the same.

## The fix

Two coordinated additions:

1. **Startup banner** (right after the CODE PUPPY logo, on both
   'code-puppy' and 'code-puppy -i'):

       Working in project: my-repo (~/workspace/my-repo)

   So the very first thing you see when opening a new terminal is
   which project this puppy is pointing to.

2. **Interactive prompt** now carries the same project label between
   the model badge and the cwd:

       Before:
         Booster [Code Puppy] [claude-sonnet-4-5] (~/workspace/my-repo) >>>

       After:
         Booster [Code Puppy] [claude-sonnet-4-5] my-repo (~/workspace/my-repo) >>>

## How the project name is resolved

Preference order (in '_get_project_name'):

  1. Basename of the nearest git worktree root. This is the key win:
     'cd packages/api/src' inside 'my-repo' still displays 'my-repo',
     not 'src'. Multi-tab users can eyeball each label and immediately
     know which project it belongs to.
  2. Basename of the cwd itself when not inside a git repo.
  3. '~' when sitting directly in $HOME.

Git detection reuses the existing 'code_puppy.config._detect_git_toplevel'
helper, which already has a 0.5s subprocess timeout and swallows every
error path, so it's safe to call on every prompt render.

## Implementation notes

- New 'project' entry in 'PROMPT_STYLES' so themes and the persistent
  bottom-bar prompt can style it consistently.
- The prompt fragment carries 'class:tui.warning' to pop against the
  model's 'class:tui.title'; a local Style rule ('bold ansired')
  guarantees visible color even without a theme plugin loaded.
- Startup banner uses Rich markup already available in cli_runner.
- Zero new runtime dependencies. No new subprocess calls beyond the
  existing git-toplevel helper.

## Tests

- '_get_project_name': git-rn-git fallback, $HOME, and a
  git-detection error case (must never crash the prompt).
- 'get_prompt_with_active_model': renders project name + carries the
  new 'class:project class:tui.warning' style token.
- All existing prompt/statusline tests still green (237 pass locally).

Co-authored-by: Aditya Das <Aditya.Das@walmart.com>
@adi07das
adi07das force-pushed the feature/prompt-project-name branch from 3062e48 to 9b14f6d Compare July 15, 2026 01:03
@adi07das

Copy link
Copy Markdown
Author

Thanks for the review @mpfaffenberger . Looks like it was done as part of the latest update. However, have repurposed to display the base root folder to provide the user a good reference point.

Two coordinated additions:

  1. Startup banner (right after the CODE PUPPY logo, on both
    code-puppy and code-puppy -i): (Mainly in cases where users trigger the Puppy from Terminal)

Working in project: my-repo (~/workspace/my-repo)

So the very first thing you see when opening a new terminal is which
project this puppy is pointing to.

  1. Interactive prompt now carries the same project label between
    the model badge and the cwd:

Before:
Booster [Code Puppy] [claude-sonnet-4-5] (~/workspace/my-repo) >>>

After:
Booster [Code Puppy] [claude-sonnet-4-5] my-repo (~/workspace/my-repo) >>>

How the project name is resolved
────────────────────────────────

Preference order (in _get_project_name):

  1. Basename of the nearest git worktree root. This is the key win:
    cd packages/api/src inside my-repo still displays my-repo, not
    src. Multi-tab users can eyeball each label and immediately know
    which project it belongs to.
  2. Basename of the cwd itself when not inside a git repo.
  3. ~ when sitting directly in $HOME.

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.

2 participants