aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2026-01-29 11:53:56 +0100
committerGitHub <noreply@github.com>2026-01-29 11:53:56 +0100
commitcdbdf2b6679c580d4b0c8332694cd8ee9117d49f (patch)
treef262277077de2891c3952663f69f6906356c4e04 /zellij-utils/src/plugin_api
parentfix: session creation time on musl (for "zellij ls") (#4645) (diff)
downloadsl0ppij-cdbdf2b6679c580d4b0c8332694cd8ee9117d49f.tar.gz
sl0ppij-cdbdf2b6679c580d4b0c8332694cd8ee9117d49f.tar.xz
sl0ppij-cdbdf2b6679c580d4b0c8332694cd8ee9117d49f.zip
Allow saving current session for resurrection on demand (#4654)
* initial implementation * session manager ui and plugin api * remove event * cleanups and formatting * add pr
Diffstat (limited to 'zellij-utils/src/plugin_api')
-rw-r--r--zellij-utils/src/plugin_api/action.rs3
-rw-r--r--zellij-utils/src/plugin_api/event.proto1
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.proto19
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs31
4 files changed, 46 insertions, 8 deletions
diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs
index bc5bc87c..7903be80 100644
--- a/zellij-utils/src/plugin_api/action.rs
+++ b/zellij-utils/src/plugin_api/action.rs
@@ -1777,7 +1777,8 @@ impl TryFrom<Action> for ProtobufAction {
| Action::TogglePaneBorderless { pane_id: _ }
| Action::SetPaneBorderless { .. }
| Action::SkipConfirm { action: _ }
- | Action::SwitchSession { .. } => Err("Unsupported action"),
+ | Action::SwitchSession { .. }
+ | Action::SaveSession => Err("Unsupported action"),
}
}
}
diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto
index 10125387..f5dadcb9 100644
--- a/zellij-utils/src/plugin_api/event.proto
+++ b/zellij-utils/src/plugin_api/event.proto
@@ -504,3 +504,4 @@ message ActionCompletePayload {
optional PaneId pane_id = 2;
repeated ContextItem context = 3;
}
+
diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto
index 9c529013..6ef1ad34 100644
--- a/zellij-utils/src/plugin_api/plugin_command.proto
+++ b/zellij-utils/src/plugin_api/plugin_command.proto
@@ -178,6 +178,8 @@ enum CommandName {
GetFocusedPaneInfo = 183;
TogglePaneBorderless = 184;
SetPaneBorderless = 185;
+ SaveSession = 186;
+ CurrentSessionLastSavedTime = 187;
}
message PluginCommand {
@@ -305,6 +307,8 @@ message PluginCommand {
GetFocusedPaneInfoPayload get_focused_pane_info_payload = 134;
TogglePaneBorderlessPayload toggle_pane_borderless_payload = 135;
SetPaneBorderlessPayload set_pane_borderless_payload = 136;
+ SaveSessionPayload save_session_payload = 137;
+ CurrentSessionLastSavedTimePayload current_session_last_saved_time_payload = 138;
}
}
@@ -906,3 +910,18 @@ message FocusedPaneInfo {
uint32 focused_tab_index = 1;
PaneId focused_pane_id = 2;
}
+
+message SaveSessionPayload {}
+
+message SaveSessionResponse {
+ oneof result {
+ bool success = 1;
+ string error = 2;
+ }
+}
+
+message CurrentSessionLastSavedTimePayload {}
+
+message CurrentSessionLastSavedTimeResponse {
+ optional uint64 timestamp_millis = 1; // None if never saved, otherwise milliseconds elapsed since last save
+}
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index da0f4599..691a6c45 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -6,12 +6,14 @@ pub use super::generated_api::api::{
delete_layout_response, dump_layout_response, dump_session_layout_response,
edit_layout_response, get_focused_pane_info_response, get_pane_pid_response,
parse_layout_response, plugin_command::Payload, rename_layout_response,
- save_layout_response, BreakPanesToNewTabPayload, BreakPanesToTabWithIndexPayload,
- ChangeFloatingPanesCoordinatesPayload, ChangeHostFolderPayload,
- ClearScreenForPaneIdPayload, CliPipeOutputPayload, CloseMultiplePanesPayload,
- CloseTabWithIndexPayload, CommandName, ContextItem, CopyToClipboardPayload,
- CreateTokenResponse as ProtobufCreateTokenResponse, CreateTokenResponse, CursorPosition,
- DeleteLayoutPayload, DeleteLayoutResponse as ProtobufDeleteLayoutResponse,
+ save_layout_response, save_session_response, BreakPanesToNewTabPayload,
+ BreakPanesToTabWithIndexPayload, ChangeFloatingPanesCoordinatesPayload,
+ ChangeHostFolderPayload, ClearScreenForPaneIdPayload, CliPipeOutputPayload,
+ CloseMultiplePanesPayload, CloseTabWithIndexPayload, CommandName, ContextItem,
+ CopyToClipboardPayload, CreateTokenResponse as ProtobufCreateTokenResponse,
+ CreateTokenResponse, CurrentSessionLastSavedTimePayload,
+ CurrentSessionLastSavedTimeResponse as ProtobufCurrentSessionLastSavedTimeResponse,
+ CursorPosition, DeleteLayoutPayload, DeleteLayoutResponse as ProtobufDeleteLayoutResponse,
DumpLayoutPayload, DumpLayoutResponse as ProtobufDumpLayoutResponse,
DumpSessionLayoutPayload, DumpSessionLayoutResponse as ProtobufDumpSessionLayoutResponse,
EditLayoutPayload, EditLayoutResponse as ProtobufEditLayoutResponse,
@@ -44,7 +46,8 @@ pub use super::generated_api::api::{
RequestPluginPermissionPayload, RerunCommandPanePayload, ResizePaneIdWithDirectionPayload,
ResizePayload, RevokeAllWebTokensResponse, RevokeTokenResponse, RevokeWebLoginTokenPayload,
RunActionPayload, RunCommandPayload, SaveLayoutPayload,
- SaveLayoutResponse as ProtobufSaveLayoutResponse, ScrollDownInPaneIdPayload,
+ SaveLayoutResponse as ProtobufSaveLayoutResponse, SaveSessionPayload,
+ SaveSessionResponse as ProtobufSaveSessionResponse, ScrollDownInPaneIdPayload,
ScrollToBottomInPaneIdPayload, ScrollToTopInPaneIdPayload, ScrollUpInPaneIdPayload,
SetFloatingPanePinnedPayload, SetPaneBorderlessPayload,
SetSelfMouseSelectionSupportPayload, SetTimeoutPayload, ShowCursorPayload,
@@ -2103,6 +2106,10 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
},
Some(CommandName::GetLayoutDir) => Ok(PluginCommand::GetLayoutDir),
Some(CommandName::GetFocusedPaneInfo) => Ok(PluginCommand::GetFocusedPaneInfo),
+ Some(CommandName::SaveSession) => Ok(PluginCommand::SaveSession),
+ Some(CommandName::CurrentSessionLastSavedTime) => {
+ Ok(PluginCommand::CurrentSessionLastSavedTime)
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -3443,6 +3450,16 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
GetFocusedPaneInfoPayload {},
)),
}),
+ PluginCommand::SaveSession => Ok(ProtobufPluginCommand {
+ name: CommandName::SaveSession as i32,
+ payload: Some(Payload::SaveSessionPayload(SaveSessionPayload {})),
+ }),
+ PluginCommand::CurrentSessionLastSavedTime => Ok(ProtobufPluginCommand {
+ name: CommandName::CurrentSessionLastSavedTime as i32,
+ payload: Some(Payload::CurrentSessionLastSavedTimePayload(
+ CurrentSessionLastSavedTimePayload {},
+ )),
+ }),
}
}
}