Skip to content

Commit c493f0e

Browse files
claudesinelaw
authored andcommitted
fix(plugins): repair test failures from widget migrations
Two independent regressions surfaced by the e2e suite: **theme_editor: 31 tests failing to bundle.** After commit 4f74b97 added `import { hintBar, parseHintString, WidgetPanel } from "./lib/index.ts"` to theme_editor.ts, every test that does `copy_plugin(&plugins_dir, "theme_editor")` without also copying the lib subdir tries to bundle a plugin whose import can't resolve, panicking with: Cannot resolve import './lib/index.ts' from .../config/plugins git_log tests escape this because they go through `setup_git_log_plugin()` which calls `copy_plugin_lib` first; pkg tests don't import the plugin (no entry in tests/e2e/plugins/). theme_editor's test file already imports `copy_plugin_lib` and uses it in one place (line 2721) but the other 37 sites just call `copy_plugin` directly. Add `copy_plugin_lib(&plugins_dir);` immediately before each `copy_plugin(&plugins_dir, "theme_editor");`. **git_log: jk navigation broken on detail pane.** After commit ffb413c migrated the log pane to a List widget, the mode bindings rebound j/k from `move_down`/`move_up` (a generic buffer-cursor action that worked uniformly on whichever panel had focus) to `git_log_select_down`/`git_log_select_up`, which always dispatched to the log List's command channel. This broke the detail pane: pressing j there moved the LIST's selection, not the detail buffer's cursor — so users couldn't scroll the diff to find a `+` line and Enter on it to open the file view. The test `test_git_log_file_view_jk_navigation` walks j down the detail pane until a diff line opens; after the migration it walked nowhere and timed out. Guard the widget dispatch on whether the focused buffer is the log buffer; fall back to `editor.executeAction("move_up" | "move_down" | "page_up" | "page_down")` otherwise. Same for PageUp/PageDown. New helper `isLogPanelActive()` checks `editor.getActiveBufferId() === state.logBufferId`. Verification: - `cargo test -p fresh-editor --test e2e_tests theme_editor::`: 34 passed, 0 failed, 6 ignored. - `cargo test -p fresh-editor --test e2e_tests git::`: 37 passed, 0 failed. - `cargo test -p fresh-editor --lib widgets`: 136 passed. - `tsc -p crates/fresh-editor/plugins/tsconfig.json`: clean. The two test-failure roots had different shapes: theme_editor was a *bundling* failure (the plugin file became unloadable in test contexts that don't ship lib), git_log was a *behavioural* regression (j/k stopped doing what users expected on the detail pane). Both shipped in this branch; both fixed here. https://claude.ai/code/session_014H6iXqpzBQXVCrfiS65512
1 parent a6e3722 commit c493f0e

2 files changed

Lines changed: 71 additions & 4 deletions

File tree

crates/fresh-editor/plugins/git_log.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,45 @@ editor.defineMode(
123123
);
124124

125125
function git_log_select_up(): void {
126-
state.logPanel?.command(key("Up"));
126+
if (isLogPanelActive()) {
127+
state.logPanel?.command(key("Up"));
128+
} else {
129+
editor.executeAction("move_up");
130+
}
127131
}
128132
function git_log_select_down(): void {
129-
state.logPanel?.command(key("Down"));
133+
if (isLogPanelActive()) {
134+
state.logPanel?.command(key("Down"));
135+
} else {
136+
editor.executeAction("move_down");
137+
}
130138
}
131139
function git_log_select_page_up(): void {
132-
state.logPanel?.command(key("PageUp"));
140+
if (isLogPanelActive()) {
141+
state.logPanel?.command(key("PageUp"));
142+
} else {
143+
editor.executeAction("page_up");
144+
}
133145
}
134146
function git_log_select_page_down(): void {
135-
state.logPanel?.command(key("PageDown"));
147+
if (isLogPanelActive()) {
148+
state.logPanel?.command(key("PageDown"));
149+
} else {
150+
editor.executeAction("page_down");
151+
}
152+
}
153+
154+
/** True iff the log panel is the focused buffer in the group. The
155+
* group's bindings (j/k/Up/Down/PageUp/PageDown) apply to all panels
156+
* uniformly; we only want navigation to drive the List widget when
157+
* the user is *on* the log panel. From the detail panel, the same
158+
* keys must move the buffer cursor (so users can scroll the diff
159+
* before pressing Enter on a diff line to open the file view). */
160+
function isLogPanelActive(): boolean {
161+
return (
162+
state.logBufferId !== null &&
163+
editor.getActiveBufferId() === state.logBufferId
164+
);
136165
}
137166
registerHandler("git_log_select_up", git_log_select_up);
138167
registerHandler("git_log_select_down", git_log_select_down);

crates/fresh-editor/tests/e2e/plugins/theme_editor.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ fn test_theme_editor_command_registered() {
8484
let plugins_dir = project_root.join("plugins");
8585
fs::create_dir(&plugins_dir).unwrap();
8686

87+
copy_plugin_lib(&plugins_dir);
8788
copy_plugin(&plugins_dir, "theme_editor");
8889

8990
// Create themes directory with a test theme
@@ -137,6 +138,7 @@ fn test_theme_editor_tab_bar_persists() {
137138
let plugins_dir = project_root.join("plugins");
138139
fs::create_dir(&plugins_dir).unwrap();
139140

141+
copy_plugin_lib(&plugins_dir);
140142
copy_plugin(&plugins_dir, "theme_editor");
141143

142144
let mut harness =
@@ -216,6 +218,7 @@ fn test_close_buffer_while_in_group_closes_whole_group() {
216218

217219
let plugins_dir = project_root.join("plugins");
218220
fs::create_dir(&plugins_dir).unwrap();
221+
copy_plugin_lib(&plugins_dir);
219222
copy_plugin(&plugins_dir, "theme_editor");
220223

221224
let mut harness =
@@ -292,6 +295,7 @@ fn test_next_buffer_cycles_across_groups_and_buffers() {
292295

293296
let plugins_dir = project_root.join("plugins");
294297
fs::create_dir(&plugins_dir).unwrap();
298+
copy_plugin_lib(&plugins_dir);
295299
copy_plugin(&plugins_dir, "theme_editor");
296300

297301
let test_file = project_root.join("cycle_test.txt");
@@ -409,6 +413,7 @@ fn test_theme_editor_opens_without_error() {
409413
let plugins_dir = project_root.join("plugins");
410414
fs::create_dir(&plugins_dir).unwrap();
411415

416+
copy_plugin_lib(&plugins_dir);
412417
copy_plugin(&plugins_dir, "theme_editor");
413418

414419
// Create themes directory with a test theme
@@ -490,6 +495,7 @@ fn test_theme_editor_open_close_reopen() {
490495
let plugins_dir = project_root.join("plugins");
491496
fs::create_dir(&plugins_dir).unwrap();
492497

498+
copy_plugin_lib(&plugins_dir);
493499
copy_plugin(&plugins_dir, "theme_editor");
494500

495501
let mut harness =
@@ -559,6 +565,7 @@ fn test_theme_editor_reopen_after_close_buffer() {
559565
let plugins_dir = project_root.join("plugins");
560566
fs::create_dir(&plugins_dir).unwrap();
561567

568+
copy_plugin_lib(&plugins_dir);
562569
copy_plugin(&plugins_dir, "theme_editor");
563570

564571
let mut harness =
@@ -623,6 +630,7 @@ fn test_theme_editor_shows_color_sections() {
623630
fs::create_dir(&plugins_dir).unwrap();
624631

625632
// Copy the theme_editor.ts plugin
633+
copy_plugin_lib(&plugins_dir);
626634
copy_plugin(&plugins_dir, "theme_editor");
627635

628636
// Create themes directory with test themes
@@ -692,6 +700,7 @@ fn test_theme_editor_open_builtin() {
692700

693701
let plugins_dir = project_root.join("plugins");
694702
fs::create_dir(&plugins_dir).unwrap();
703+
copy_plugin_lib(&plugins_dir);
695704
copy_plugin(&plugins_dir, "theme_editor");
696705

697706
// Create harness with isolated directory context
@@ -762,6 +771,7 @@ fn test_theme_editor_displays_correct_colors() {
762771
fs::create_dir(&plugins_dir).unwrap();
763772

764773
// Copy the theme_editor.ts plugin
774+
copy_plugin_lib(&plugins_dir);
765775
copy_plugin(&plugins_dir, "theme_editor");
766776

767777
// Create themes directory
@@ -909,6 +919,7 @@ fn test_cursor_position_preserved_after_section_toggle() {
909919
let plugins_dir = project_root.join("plugins");
910920
fs::create_dir(&plugins_dir).unwrap();
911921

922+
copy_plugin_lib(&plugins_dir);
912923
copy_plugin(&plugins_dir, "theme_editor");
913924

914925
let themes_dir = project_root.join("themes");
@@ -977,6 +988,7 @@ fn test_color_prompt_shows_suggestions() {
977988
let plugins_dir = project_root.join("plugins");
978989
fs::create_dir(&plugins_dir).unwrap();
979990

991+
copy_plugin_lib(&plugins_dir);
980992
copy_plugin(&plugins_dir, "theme_editor");
981993

982994
let themes_dir = project_root.join("themes");
@@ -1082,6 +1094,7 @@ fn test_colors_displayed_in_hex_format() {
10821094
let plugins_dir = project_root.join("plugins");
10831095
fs::create_dir(&plugins_dir).unwrap();
10841096

1097+
copy_plugin_lib(&plugins_dir);
10851098
copy_plugin(&plugins_dir, "theme_editor");
10861099

10871100
let themes_dir = project_root.join("themes");
@@ -1145,6 +1158,7 @@ fn test_comments_appear_before_fields() {
11451158
let plugins_dir = project_root.join("plugins");
11461159
fs::create_dir(&plugins_dir).unwrap();
11471160

1161+
copy_plugin_lib(&plugins_dir);
11481162
copy_plugin(&plugins_dir, "theme_editor");
11491163

11501164
let themes_dir = project_root.join("themes");
@@ -1226,6 +1240,7 @@ fn test_theme_applied_immediately_after_save() {
12261240

12271241
let plugins_dir = project_root.join("plugins");
12281242
fs::create_dir(&plugins_dir).unwrap();
1243+
copy_plugin_lib(&plugins_dir);
12291244
copy_plugin(&plugins_dir, "theme_editor");
12301245

12311246
// Create a test file to see theme changes
@@ -1398,6 +1413,7 @@ fn test_cursor_x_position_preserved_after_section_toggle() {
13981413
let plugins_dir = project_root.join("plugins");
13991414
fs::create_dir(&plugins_dir).unwrap();
14001415

1416+
copy_plugin_lib(&plugins_dir);
14011417
copy_plugin(&plugins_dir, "theme_editor");
14021418

14031419
let themes_dir = project_root.join("themes");
@@ -1534,6 +1550,7 @@ fn test_color_suggestions_show_hex_format() {
15341550
let plugins_dir = project_root.join("plugins");
15351551
fs::create_dir(&plugins_dir).unwrap();
15361552

1553+
copy_plugin_lib(&plugins_dir);
15371554
copy_plugin(&plugins_dir, "theme_editor");
15381555

15391556
let themes_dir = project_root.join("themes");
@@ -1665,6 +1682,7 @@ fn test_color_prompt_prefilled_with_current_value() {
16651682
let plugins_dir = project_root.join("plugins");
16661683
fs::create_dir(&plugins_dir).unwrap();
16671684

1685+
copy_plugin_lib(&plugins_dir);
16681686
copy_plugin(&plugins_dir, "theme_editor");
16691687

16701688
let themes_dir = project_root.join("themes");
@@ -1744,6 +1762,7 @@ fn test_theme_editor_color_values_no_internal_spaces() {
17441762
let plugins_dir = project_root.join("plugins");
17451763
fs::create_dir(&plugins_dir).unwrap();
17461764

1765+
copy_plugin_lib(&plugins_dir);
17471766
copy_plugin(&plugins_dir, "theme_editor");
17481767

17491768
let themes_dir = project_root.join("themes");
@@ -1832,6 +1851,7 @@ fn test_theme_editor_navigation_skips_non_selectable_lines() {
18321851
let plugins_dir = project_root.join("plugins");
18331852
fs::create_dir(&plugins_dir).unwrap();
18341853

1854+
copy_plugin_lib(&plugins_dir);
18351855
copy_plugin(&plugins_dir, "theme_editor");
18361856

18371857
let themes_dir = project_root.join("themes");
@@ -1986,6 +2006,7 @@ fn test_cursor_position_preserved_after_color_edit() {
19862006
let plugins_dir = project_root.join("plugins");
19872007
fs::create_dir(&plugins_dir).unwrap();
19882008

2009+
copy_plugin_lib(&plugins_dir);
19892010
copy_plugin(&plugins_dir, "theme_editor");
19902011

19912012
let themes_dir = project_root.join("themes");
@@ -2116,6 +2137,7 @@ fn test_cursor_on_value_field_when_navigating() {
21162137
let plugins_dir = project_root.join("plugins");
21172138
fs::create_dir(&plugins_dir).unwrap();
21182139

2140+
copy_plugin_lib(&plugins_dir);
21192141
copy_plugin(&plugins_dir, "theme_editor");
21202142

21212143
let themes_dir = project_root.join("themes");
@@ -2182,6 +2204,7 @@ fn test_builtin_theme_requires_save_as() {
21822204
let plugins_dir = project_root.join("plugins");
21832205
fs::create_dir(&plugins_dir).unwrap();
21842206

2207+
copy_plugin_lib(&plugins_dir);
21852208
copy_plugin(&plugins_dir, "theme_editor");
21862209

21872210
// Create a DirectoryContext so we know where config_dir/themes is
@@ -2303,6 +2326,7 @@ fn test_color_swatches_displayed() {
23032326
let plugins_dir = project_root.join("plugins");
23042327
fs::create_dir(&plugins_dir).unwrap();
23052328

2329+
copy_plugin_lib(&plugins_dir);
23062330
copy_plugin(&plugins_dir, "theme_editor");
23072331

23082332
let themes_dir = project_root.join("themes");
@@ -2360,6 +2384,7 @@ fn test_theme_editor_nostalgia_builtin_shows_correct_colors() {
23602384
let plugins_dir = project_root.join("plugins");
23612385
fs::create_dir(&plugins_dir).unwrap();
23622386

2387+
copy_plugin_lib(&plugins_dir);
23632388
copy_plugin(&plugins_dir, "theme_editor");
23642389

23652390
// Don't create a themes directory - we want to use the built-in themes only
@@ -2445,6 +2470,7 @@ fn test_theme_editor_nostalgia_builtin_via_arrow_selection() {
24452470
let plugins_dir = project_root.join("plugins");
24462471
fs::create_dir(&plugins_dir).unwrap();
24472472

2473+
copy_plugin_lib(&plugins_dir);
24482474
copy_plugin(&plugins_dir, "theme_editor");
24492475

24502476
// Don't create a themes directory - we want to use the built-in themes only
@@ -2540,6 +2566,7 @@ fn test_theme_editor_select_nostalgia_from_dropdown() {
25402566
let plugins_dir = project_root.join("plugins");
25412567
fs::create_dir(&plugins_dir).unwrap();
25422568

2569+
copy_plugin_lib(&plugins_dir);
25432570
copy_plugin(&plugins_dir, "theme_editor");
25442571

25452572
let mut harness =
@@ -2782,6 +2809,7 @@ fn test_inspect_theme_at_cursor_opens_theme_editor() {
27822809

27832810
let plugins_dir = project_root.join("plugins");
27842811
fs::create_dir(&plugins_dir).unwrap();
2812+
copy_plugin_lib(&plugins_dir);
27852813
copy_plugin(&plugins_dir, "theme_editor");
27862814

27872815
// Create a test file so the cursor is on editor content
@@ -2847,6 +2875,7 @@ fn test_inspect_theme_at_cursor_multiple_rounds() {
28472875

28482876
let plugins_dir = project_root.join("plugins");
28492877
fs::create_dir(&plugins_dir).unwrap();
2878+
copy_plugin_lib(&plugins_dir);
28502879
copy_plugin(&plugins_dir, "theme_editor");
28512880

28522881
let test_file = project_root.join("test.txt");
@@ -2976,6 +3005,7 @@ fn test_save_builtin_theme_produces_valid_file() {
29763005

29773006
let plugins_dir = project_root.join("plugins");
29783007
fs::create_dir(&plugins_dir).unwrap();
3008+
copy_plugin_lib(&plugins_dir);
29793009
copy_plugin(&plugins_dir, "theme_editor");
29803010

29813011
let test_file = project_root.join("test.txt");
@@ -3166,6 +3196,7 @@ fn test_issue_1180_save_theme_creates_themes_directory() {
31663196

31673197
let plugins_dir = project_root.join("plugins");
31683198
fs::create_dir(&plugins_dir).unwrap();
3199+
copy_plugin_lib(&plugins_dir);
31693200
copy_plugin(&plugins_dir, "theme_editor");
31703201

31713202
let test_file = project_root.join("test.txt");
@@ -3332,6 +3363,7 @@ fn test_inspect_after_saving_custom_theme() {
33323363

33333364
let plugins_dir = project_root.join("plugins");
33343365
fs::create_dir(&plugins_dir).unwrap();
3366+
copy_plugin_lib(&plugins_dir);
33353367
copy_plugin(&plugins_dir, "theme_editor");
33363368

33373369
let test_file = project_root.join("test.txt");
@@ -3512,6 +3544,7 @@ fn test_palette_swatch_click_targets_correct_column() {
35123544
let plugins_dir = project_root.join("plugins");
35133545
fs::create_dir(&plugins_dir).unwrap();
35143546

3547+
copy_plugin_lib(&plugins_dir);
35153548
copy_plugin(&plugins_dir, "theme_editor");
35163549

35173550
let themes_dir = project_root.join("themes");
@@ -3697,6 +3730,7 @@ fn test_theme_editor_page_up_page_down() {
36973730
let plugins_dir = project_root.join("plugins");
36983731
fs::create_dir(&plugins_dir).unwrap();
36993732

3733+
copy_plugin_lib(&plugins_dir);
37003734
copy_plugin(&plugins_dir, "theme_editor");
37013735

37023736
let themes_dir = project_root.join("themes");
@@ -3836,6 +3870,7 @@ fn test_named_color_swatch_uses_native_ansi_color() {
38363870

38373871
let plugins_dir = project_root.join("plugins");
38383872
fs::create_dir(&plugins_dir).unwrap();
3873+
copy_plugin_lib(&plugins_dir);
38393874
copy_plugin(&plugins_dir, "theme_editor");
38403875

38413876
// Create a theme with a named color "Yellow" for tab_active_fg.
@@ -4007,6 +4042,7 @@ fn test_theme_editor_colors_update_on_theme_change() {
40074042

40084043
let plugins_dir = project_root.join("plugins");
40094044
fs::create_dir(&plugins_dir).unwrap();
4045+
copy_plugin_lib(&plugins_dir);
40104046
copy_plugin(&plugins_dir, "theme_editor");
40114047

40124048
let mut config = fresh::config::Config::default();
@@ -4155,6 +4191,7 @@ fn test_paste_in_theme_editor_does_not_panic() {
41554191

41564192
let plugins_dir = project_root.join("plugins");
41574193
fs::create_dir(&plugins_dir).unwrap();
4194+
copy_plugin_lib(&plugins_dir);
41584195
copy_plugin(&plugins_dir, "theme_editor");
41594196

41604197
let mut harness =
@@ -4207,6 +4244,7 @@ fn test_theme_editor_terminal_builtin_renders_field_rows() {
42074244

42084245
let plugins_dir = project_root.join("plugins");
42094246
fs::create_dir(&plugins_dir).unwrap();
4247+
copy_plugin_lib(&plugins_dir);
42104248
copy_plugin(&plugins_dir, "theme_editor");
42114249

42124250
let mut harness =

0 commit comments

Comments
 (0)