Skip to content

Commit 9e0dd6b

Browse files
committed
feat(ui): move cache hit line to end
1 parent 41f102e commit 9e0dd6b

8 files changed

Lines changed: 19 additions & 26 deletions

File tree

a.js

Whitespace-only changes.

crates/vite_task/src/session/reporter.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,8 @@ impl<W: Write> LabeledReporter<W> {
152152
}
153153

154154
// Handle None display case - direct synthetic execution (e.g., `vite lint`)
155-
// Print inline cache status before command output for consistency
155+
// Don't print cache status here - will be printed at finish for cache hits only
156156
let Some(display) = display else {
157-
// Print inline cache status (e.g., "✓ cache hit, replaying") before output
158-
// Skip if silent_if_cache_hit is enabled and this is a cache hit
159-
let should_print =
160-
!self.silent_if_cache_hit || !matches!(cache_status, CacheStatus::Hit { .. });
161-
if should_print {
162-
if let Some(inline_status) = format_cache_status_inline(&cache_status) {
163-
let styled_status = match &cache_status {
164-
CacheStatus::Hit { .. } => {
165-
inline_status.style(Style::new().green().dimmed())
166-
}
167-
CacheStatus::Miss(_) => inline_status.style(CACHE_MISS_STYLE.dimmed()),
168-
CacheStatus::Disabled(_) => {
169-
inline_status.style(Style::new().bright_black())
170-
}
171-
};
172-
let _ = writeln!(self.writer, "{}", styled_status);
173-
}
174-
}
175157
self.executions.push(ExecutionInfo {
176158
display: None,
177159
cache_status,
@@ -257,6 +239,21 @@ impl<W: Write> LabeledReporter<W> {
257239
exec.exit_status = status;
258240
}
259241

242+
// For direct synthetic execution with cache hit, print message at the bottom
243+
if let Some(exec) = self.executions.last() {
244+
if exec.display.is_none() && matches!(exec.cache_status, CacheStatus::Hit { .. }) {
245+
let should_print =
246+
!self.silent_if_cache_hit || !self.cache_hit_executions.contains(&execution_id);
247+
if should_print {
248+
let _ = writeln!(
249+
self.writer,
250+
"{}",
251+
"✓ cache hit, logs replayed".style(Style::new().green().dimmed())
252+
);
253+
}
254+
}
255+
}
256+
260257
// Add a line break after each task's output for better readability
261258
// Skip if silent_if_cache_hit is enabled and this execution is a cache hit
262259
if !self.silent_if_cache_hit || !self.cache_hit_executions.contains(&execution_id) {

crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots/builtin different cwd.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Finished in <duration> on 1 file with 90 rules using <n> threads.
3333
> echo 'console.log(1);' > folder2/a.js # modify folder2
3434
3535
> cd folder1 && vite lint # cache hit
36-
✓ cache hit, replaying
3736
3837
! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
3938
,-[a.js:1:1]
@@ -44,9 +43,9 @@ Finished in <duration> on 1 file with 90 rules using <n> threads.
4443
4544
Found 1 warning and 0 errors.
4645
Finished in <duration> on 1 file with 90 rules using <n> threads.
46+
✓ cache hit, logs replayed
4747
4848
4949
> cd folder2 && vite lint # cache miss
50-
✗ cache miss: content of input 'folder2/a.js' changed, executing
5150
Found 0 warnings and 0 errors.
5251
Finished in <duration> on 1 file with 90 rules using <n> threads.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-lint-cache/snapshots/direct lint.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Finished in <duration> on 0 files with 90 rules using <n> threads.
1212
> echo debugger > main.js # add lint error
1313

1414
> vite lint # cache miss, lint fails
15-
✗ cache miss: content of input '' changed, executing
1615

1716
! eslint(no-debugger): `debugger` statement is not allowed
1817
,-[main.js:1:1]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency/snapshots/cycle dependency error.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ expression: e2e_outputs
55
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/error_cycle_dependency
66
---
77
[1]> vite run task-a # task-a -> task-b -> task-a cycle
8-
cache disabled: cycle detected
98
Cycle dependencies detected: Cycle(NodeIndex(ExecutionIx(1)))
109

1110
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

crates/vite_task_bin/tests/e2e_snapshots/fixtures/lint-dot-git/snapshots/lint dot git.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Finished in <duration> on 1 file with 90 rules using <n> threads.
2222
> echo hello > .git/foo.txt # add file inside .git
2323
2424
> vite lint # cache hit, .git is ignored
25-
✓ cache hit, replaying
2625
2726
! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
2827
,-[a.js:1:1]
@@ -33,3 +32,4 @@ Finished in <duration> on 1 file with 90 rules using <n> threads.
3332
3433
Found 1 warning and 0 errors.
3534
Finished in <duration> on 1 file with 90 rules using <n> threads.
35+
✓ cache hit, logs replayed

crates/vite_task_bin/tests/e2e_snapshots/fixtures/same-name-as-builtin/snapshots/same name as builtin.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Task Details:
3838
> echo 'console.log(1);' > a.js # add valid JS file
3939
4040
> vite lint # builtin lint: cache miss
41-
✗ cache miss: content of input 'a.js' changed, executing
4241
Found 0 warnings and 0 errors.
4342
Finished in <duration> on 1 file with 90 rules using <n> threads.
4443

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"prepare": "husky",
1212
"hello": "echo Hello, Vite Task Monorepo!",
13-
"a": "vite foo"
13+
"lint": "vite lint"
1414
},
1515
"devDependencies": {
1616
"@types/node": "catalog:",

0 commit comments

Comments
 (0)