Fix: Make sudo/install prompts more prominent with defaults

Root Cause: The sudo and install prompts were not visually prominent,
causing users to miss them or not respond clearly. Additionally, the
prompts had [Y/n] format but didn't default to Yes on Enter.

Changes:
1. Main install prompt (line 674-676):
   - Added prominent MAGENTA boxed prompt
   - "Install Z.AI coding-helper now? [Y/n]"
   - Defaults to Yes when user presses Enter
   - Visual box makes it stand out from other output

2. Sudo retry prompt (line 747-748):
   - Added prominent YELLOW boxed prompt
   - "Try installing with sudo now? [Y/n] (recommended)"
   - Defaults to Yes when user presses Enter
   - Clear "(recommended)" label

3. Default handling:
   - Changed from `[y/N]` to `[Y/n]` (Yes is default)
   - Added check for empty input (Enter key) to treat as Yes
   - `if [[ -z "$var" ]] || [[ $var =~ ^[Yy]$ ]]`

Example output:
═══════════════════════════════════════════════════════════
  Install Z.AI coding-helper now? [Y/n]
═══════════════════════════════════════════════════════════

This makes it much harder to miss the prompts and provides a better
user experience by accepting Enter as "Yes" (the common case).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-22 16:41:15 +00:00
Unverified
parent d4bfb4bf80
commit 1e2054dcd2

View File

@@ -670,15 +670,20 @@ offer_coding_helper_addons() {
fi
# Core not installed, offer installation
read -p "Install Z.AI coding-helper? [y/N] " -n 1 -r install_helper < /dev/tty
echo ""
echo -e "${BOLD}${MAGENTA}═══════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}${MAGENTA} Install Z.AI coding-helper now?${NC} ${GREEN}[Y/n]${NC}"
echo -e "${BOLD}${MAGENTA}═══════════════════════════════════════════════════════════${NC}"
read -p " " -n 1 -r install_helper < /dev/tty
echo ""
if [[ ! $install_helper =~ ^[Yy]$ ]]; then
# Default to Yes if user just presses Enter
if [[ -z "$install_helper" ]] || [[ $install_helper =~ ^[Yy]$ ]]; then
install_coding_helper
else
log_info "Skipping coding-helper installation"
return
fi
install_coding_helper
}
install_coding_helper() {
@@ -743,10 +748,13 @@ install_coding_helper() {
echo -e "${GREEN}Option 3: Run without installation (works immediately)${NC}"
echo -e " Just use: ${YELLOW}npx @z_ai/coding-helper${NC}"
echo ""
echo -e "${CYAN}Want to try with sudo now? [y/N]${NC}"
echo -e "${BOLD}${YELLOW}═══════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD} Try installing with sudo now?${NC} ${GREEN}[Y/n]${NC} ${BOLD}(recommended)${NC}"
echo -e "${BOLD}${YELLOW}═══════════════════════════════════════════════════════════${NC}"
read -p " " -n 1 -r use_sudo < /dev/tty
echo ""
if [[ $use_sudo =~ ^[Yy]$ ]]; then
# Default to Yes if user just presses Enter
if [[ -z "$use_sudo" ]] || [[ $use_sudo =~ ^[Yy]$ ]]; then
echo ""
log_info "Installing with sudo..."
if sudo npm install -g @z_ai/coding-helper 2>&1; then