feat(cli): set terminal title to project name#988
feat(cli): set terminal title to project name#988zerone0x wants to merge 2 commits intovoidzero-dev:mainfrom
Conversation
Instead of showing just "vp" as the terminal window title, read the project name from the nearest package.json and set it as the terminal title using the OSC 0 escape sequence. This applies to both the global CLI and the local CLI entry points. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for viteplus-preview canceled.
|
| pub fn set_terminal_title(title: &str) { | ||
| use std::io::Write; | ||
|
|
||
| if !std::io::stdout().is_terminal() || std::env::var_os("CI").is_some() { |
There was a problem hiding this comment.
Will there be similar issues to #986? Under what conditions would title not be supported?
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 414beb4bae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !std::io::stdout().is_terminal() || std::env::var_os("CI").is_some() { | ||
| return; | ||
| } | ||
|
|
||
| let _ = write!(std::io::stdout(), "\x1b]0;{title}\x07"); |
There was a problem hiding this comment.
Check terminal capability before writing OSC 0
This emits ESC]0;…BEL on any TTY except CI, but that is broader than the terminal-capability checks we already use elsewhere in header.rs. In environments where stdout is a terminal but OSC/VT sequences are not supported—e.g. TERM=dumb, or Windows console hosts that have not enabled ENABLE_VIRTUAL_TERMINAL_PROCESSING—users will see the raw bytes at the top of every vp invocation instead of just getting a title update. Please gate this on real escape-sequence support before writing to stdout.
Useful? React with 👍 / 👎.
Summary
package.jsonand set it as the terminal window title using the OSC 0 escape sequence (ESC ] 0 ; <title> BEL)vpbinary) and the local CLI entry pointpackage.jsonwith anamefield is foundFixes #978
Test plan
vite_sharedtests pass (31 passed, 1 ignored)vp devin a project directory and verify the terminal tab/window title shows the project name instead of "vp"vpoutside any project directory and verify no error occurs (graceful fallback)🤖 Generated with Claude Code