diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-29 18:57:13 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-29 18:57:13 +0300 |
| commit | 97f78226bf1f34dcdef164291a9c50fddf448c6e (patch) | |
| tree | 20f8793644f314521c6e064bef8ba4b25576524b /src/app/mod.rs | |
| parent | 1a4e94e57e181379e2ed42d63a49fbc56ed1dba4 (diff) | |
fix: route tui modal mutations through api authority
Diffstat (limited to 'src/app/mod.rs')
| -rw-r--r-- | src/app/mod.rs | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs index 65863fd8..2860664f 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1619,7 +1619,7 @@ impl App { self.handle_copy_mode_key(key); } Mode::RenameWorkspace | Mode::RenameTab | Mode::RenamePane => { - input::handle_rename_key(&mut self.state, key_event); + self.handle_rename_key_via_api(key_event); } Mode::NewLinkedWorktree => { self.handle_worktree_create_key(key_event); @@ -1631,17 +1631,13 @@ impl App { self.handle_worktree_remove_key(key_event); } Mode::Resize => { - input::handle_resize_key(&mut self.state, key); + self.handle_resize_key_via_api(key); } Mode::ConfirmClose => { - input::handle_confirm_close_key(&mut self.state, key_event); + self.handle_confirm_close_key_via_api(key_event); } Mode::ContextMenu => { - input::handle_context_menu_key( - &mut self.state, - &mut self.terminal_runtimes, - key_event, - ); + self.handle_context_menu_key_via_api(key_event); } Mode::KeybindHelp => { input::handle_keybind_help_key(&mut self.state, key_event); @@ -4364,6 +4360,47 @@ last_pane = "prefix+tab" } #[test] + fn route_client_input_rename_enter_submits_through_api_path() { + let mut app = test_app(); + app.state.workspaces = vec![Workspace::test_new("old")]; + app.state.active = Some(0); + app.state.selected = 0; + app.state.mode = Mode::RenameWorkspace; + app.state.name_input = "new".into(); + + app.route_client_input(b"\r".to_vec()); + + assert_eq!(app.state.workspaces[0].custom_name.as_deref(), Some("new")); + assert!(app.event_hub.events_after(0).iter().any(|(_, event)| { + matches!(event.event, crate::api::schema::EventKind::WorkspaceRenamed) + })); + } + + #[test] + fn route_client_input_context_menu_enter_submits_through_api_path() { + let mut app = test_app(); + app.state.workspaces = vec![Workspace::test_new("a"), Workspace::test_new("b")]; + app.state.active = Some(0); + app.state.selected = 0; + app.state.confirm_close = false; + app.state.context_menu = Some(state::ContextMenuState { + kind: state::ContextMenuKind::Workspace { ws_idx: 1 }, + x: 2, + y: 2, + list: state::MenuListState::new(1), + }); + app.state.mode = Mode::ContextMenu; + + app.route_client_input(b"\r".to_vec()); + + assert_eq!(app.state.workspaces.len(), 1); + assert_eq!(app.state.workspaces[0].display_name(), "a"); + assert!(app.event_hub.events_after(0).iter().any(|(_, event)| { + matches!(event.event, crate::api::schema::EventKind::WorkspaceClosed) + })); + } + + #[test] fn raw_ctrl_v_decodes_as_modal_paste_shortcut() { let events = crate::raw_input::parse_raw_input_bytes_sync(&[0x16]); let Some(crate::raw_input::RawInputEvent::Key(key)) = events.first() else { |
