diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-21 16:30:04 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-21 16:30:04 +0300 |
| commit | 3397e1ce2922c4ae9b814e8110e81de7d201de81 (patch) | |
| tree | c457a7cf0af271dea1a412474fad5a33c1b60be8 /src/app/actions.rs | |
| parent | 2818ff492d45d17fd4f9b15478d703c6c664a8c0 (diff) | |
feat: add persistent server-client sessions
Make herdr persistent by default.
Launching herdr now starts or reattaches to a background session
server. Clients can detach and reattach while panes and agent
processes keep running. Session mode now supports multi-client attach,
auto-detect startup, and a thin-client/headless-server split.
This also refactors the large app, ui, input, pane, config,
workspace, and persistence modules into smaller focused submodules,
while preserving behavior and colocating tests with the code they
exercise.
Upgrade notes:
- persistence mode is now the default
- in-app quit detaches the current client instead of stopping the server
- use `herdr server stop` to stop the background session
- use `--no-session` for the old single-process behavior
- default socket paths now live under the config directory
Diffstat (limited to 'src/app/actions.rs')
| -rw-r--r-- | src/app/actions.rs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index 3617bb07..f9136b9c 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -15,7 +15,7 @@ fn is_background_completion_transition(prev_state: AgentState, new_state: AgentS && matches!(prev_state, AgentState::Working | AgentState::Blocked) } -fn notification_sound_for_state_change( +pub fn notification_sound_for_state_change( is_active_tab: bool, prev_state: AgentState, new_state: AgentState, @@ -89,7 +89,7 @@ pub struct PaneStateUpdate { // --------------------------------------------------------------------------- impl AppState { - fn pane_is_in_active_tab(&self, ws_idx: usize, pane_id: PaneId) -> bool { + pub(crate) fn pane_is_in_active_tab(&self, ws_idx: usize, pane_id: PaneId) -> bool { let Some(active_ws_idx) = self.active else { return false; }; @@ -445,8 +445,8 @@ impl AppState { if let Some(text) = text { if !text.is_empty() { - crate::selection::write_osc52(&text); - info!(len = text.len(), "copied selection to clipboard"); + self.request_clipboard_write = Some(text.into_bytes()); + info!("copied selection to clipboard"); } } @@ -472,7 +472,7 @@ impl AppState { self.toast = Some(ToastNotification { kind: ToastKind::UpdateInstalled, title: format!("v{version} available"), - context: "run `herdr update`".to_string(), + context: "detach, then run `herdr update`".to_string(), }); Vec::new() } @@ -663,6 +663,22 @@ mod tests { } #[test] + fn update_ready_sets_explicit_upgrade_toast() { + let mut state = AppState::test_new(); + + let updates = state.handle_app_event(crate::events::AppEvent::UpdateReady { + version: "0.5.0".into(), + }); + + assert!(updates.is_empty()); + assert_eq!(state.update_available.as_deref(), Some("0.5.0")); + assert!(state.latest_release_notes_available); + let toast = state.toast.as_ref().expect("update toast"); + assert_eq!(toast.title, "v0.5.0 available"); + assert_eq!(toast.context, "detach, then run `herdr update`"); + } + + #[test] fn switch_workspace_updates_active_and_selected() { let mut state = app_with_workspaces(&["a", "b", "c"]); state.switch_workspace(2); @@ -1038,7 +1054,7 @@ mod tests { let toast = state.toast.as_ref().expect("update toast"); assert_eq!(toast.kind, ToastKind::UpdateInstalled); assert_eq!(toast.title, "v0.5.0 available"); - assert_eq!(toast.context, "run `herdr update`"); + assert_eq!(toast.context, "detach, then run `herdr update`"); } #[test] |
