Skip to content

Commit 9f11b6c

Browse files
authored
Merge branch 'main' into copilot/fix-e2e-test-scheduled-run
2 parents e4cf46a + 53d7be0 commit 9f11b6c

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

crates/vite_shared/src/tracing.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tracing initialization for vite-plus
22
3-
use std::sync::OnceLock;
3+
use std::{str::FromStr, sync::OnceLock};
44

55
use tracing_subscriber::{
66
filter::{LevelFilter, Targets},
@@ -14,25 +14,28 @@ use crate::env_vars;
1414
/// Uses `OnceLock` to ensure tracing is only initialized once,
1515
/// even if called multiple times.
1616
///
17+
/// Only sets the global default subscriber when `VITE_LOG` is set.
18+
/// When unset, the global default slot is left free so that other
19+
/// subscribers (e.g., rolldown devtools) can claim it without panicking.
20+
///
1721
/// # Environment Variables
1822
/// - `VITE_LOG`: Controls log filtering (e.g., "debug", "vite_task=trace")
1923
pub fn init_tracing() {
2024
static TRACING: OnceLock<()> = OnceLock::new();
2125
TRACING.get_or_init(|| {
26+
let Ok(env_var) = std::env::var(env_vars::VITE_LOG) else {
27+
return;
28+
};
29+
2230
tracing_subscriber::registry()
2331
.with(
24-
std::env::var(env_vars::VITE_LOG)
25-
.map_or_else(
26-
|_| Targets::new(),
27-
|env_var| {
28-
use std::str::FromStr;
29-
Targets::from_str(&env_var).unwrap_or_default()
30-
},
31-
)
32+
Targets::from_str(&env_var)
33+
.unwrap_or_default()
3234
// disable brush-parser tracing
3335
.with_targets([("tokenize", LevelFilter::OFF), ("parse", LevelFilter::OFF)]),
3436
)
3537
.with(tracing_subscriber::fmt::layer())
36-
.init();
38+
.try_init()
39+
.ok();
3740
});
3841
}

packages/prompts/src/__tests__/__snapshots__/render.spec.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ exports[`prompt renderers > renders multiselect with cursor marker plus checkbox
5252
Second line
5353
› ◼ Beta
5454
◻ Gamma
55+
Press space to select, enter to submit
5556
5657
"
5758
`;

packages/prompts/src/multi-select.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
120120
);
121121
};
122122
const required = opts.required ?? true;
123+
const hint =
124+
' ' +
125+
color.reset(
126+
color.dim(
127+
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(
128+
color.bgWhite(color.inverse(' enter ')),
129+
)} to submit`,
130+
),
131+
);
123132

124133
return new MultiSelectPrompt({
125134
options: opts.options,
@@ -131,13 +140,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
131140
cursorAt: opts.cursorAt,
132141
validate(selected: Value[] | undefined) {
133142
if (required && (selected === undefined || selected.length === 0)) {
134-
return `Please select at least one option.\n${color.reset(
135-
color.dim(
136-
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(
137-
color.bgWhite(color.inverse(' enter ')),
138-
)} to submit`,
139-
),
140-
)}`;
143+
return `Please select at least one option.\n${hint}`;
141144
}
142145
return undefined;
143146
},
@@ -221,7 +224,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
221224
columnPadding: prefix.length,
222225
rowPadding: titleLineCount + footerLineCount,
223226
style: styleOption,
224-
}).join(`\n${prefix}`)}\n${footer}\n`;
227+
}).join(`\n${prefix}`)}\n${hint}\n${footer}\n`;
225228
}
226229
default: {
227230
const prefix = hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix;
@@ -236,7 +239,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
236239
columnPadding: prefix.length,
237240
rowPadding: titleLineCount + footerLineCount,
238241
style: styleOption,
239-
}).join(`\n${prefix}`)}\n${hasGuide ? color.blue(S_BAR_END) : ''}\n`;
242+
}).join(`\n${prefix}`)}\n${hint}\n${hasGuide ? color.blue(S_BAR_END) : ''}\n`;
240243
}
241244
}
242245
},

0 commit comments

Comments
 (0)