Skip to content

feat(cli): set terminal title to project name#988

Open
zerone0x wants to merge 2 commits intovoidzero-dev:mainfrom
zerone0x:feat/terminal-title-project-name
Open

feat(cli): set terminal title to project name#988
zerone0x wants to merge 2 commits intovoidzero-dev:mainfrom
zerone0x:feat/terminal-title-project-name

Conversation

@zerone0x
Copy link
Contributor

Summary

  • Read the project name from the nearest package.json and set it as the terminal window title using the OSC 0 escape sequence (ESC ] 0 ; <title> BEL)
  • Applies to both the global CLI (vp binary) and the local CLI entry point
  • Falls back gracefully: no-op when stdout is not a terminal, when running in CI, or when no package.json with a name field is found

Fixes #978

Test plan

  • vite_shared tests pass (31 passed, 1 ignored)
  • Run vp dev in a project directory and verify the terminal tab/window title shows the project name instead of "vp"
  • Run vp outside any project directory and verify no error occurs (graceful fallback)
  • Verify CI pipeline passes

🤖 Generated with Claude Code

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>
@netlify
Copy link

netlify bot commented Mar 17, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 414beb4
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69bb8e36f1fc540008dae04a

pub fn set_terminal_title(title: &str) {
use std::io::Write;

if !std::io::stdout().is_terminal() || std::env::var_os("CI").is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be similar issues to #986? Under what conditions would title not be supported?

@fengmk2
Copy link
Member

fengmk2 commented Mar 19, 2026

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +535 to +539
if !std::io::stdout().is_terminal() || std::env::var_os("CI").is_some() {
return;
}

let _ = write!(std::io::stdout(), "\x1b]0;{title}\x07");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

Set terminal title

2 participants