aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-09 04:40:50 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-09 04:42:35 +0300
commitbb2c579df206e51d43833544d114f321423c997c (patch)
treea26c6702e048f31429ebaa260ee40c3c2b111d3e /src/app
parent5460a9601ea8dd3d05e64e97040c71c6be29172b (diff)
feat(cli): support labels when creating tabs and workspaces
Diffstat (limited to 'src/app')
-rw-r--r--src/app/mod.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index a39ed436..8d089a9d 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -1069,6 +1069,11 @@ impl App {
.unwrap_or_else(|| std::path::PathBuf::from("/"));
match self.create_workspace_with_options(cwd, params.focus) {
Ok(index) => {
+ if let Some(label) = params.label {
+ if let Some(workspace) = self.state.workspaces.get_mut(index) {
+ workspace.set_custom_name(label);
+ }
+ }
let workspace = self.workspace_info(index);
self.emit_event(crate::api::schema::EventEnvelope {
event: crate::api::schema::EventKind::WorkspaceCreated,
@@ -1280,7 +1285,13 @@ impl App {
}
}
Method::TabCreate(params) => {
- let ws_idx = if let Some(workspace_id) = params.workspace_id {
+ let crate::api::schema::TabCreateParams {
+ workspace_id,
+ cwd,
+ focus,
+ label,
+ } = params;
+ let ws_idx = if let Some(workspace_id) = workspace_id {
let Some(ws_idx) = self.parse_workspace_id(&workspace_id) else {
return serde_json::to_string(&ErrorResponse {
id: request.id,
@@ -1304,8 +1315,7 @@ impl App {
})
.unwrap();
};
- let cwd = params
- .cwd
+ let cwd = cwd
.map(std::path::PathBuf::from)
.or_else(|| {
self.state.workspaces.get(ws_idx).and_then(|ws| {
@@ -1333,7 +1343,17 @@ impl App {
});
match result {
Ok(tab_idx) => {
- if params.focus {
+ if let Some(label) = label {
+ if let Some(tab) = self
+ .state
+ .workspaces
+ .get_mut(ws_idx)
+ .and_then(|ws| ws.tabs.get_mut(tab_idx))
+ {
+ tab.set_custom_name(label);
+ }
+ }
+ if focus {
self.state.switch_workspace(ws_idx);
self.state.switch_tab(tab_idx);
self.state.mode = Mode::Terminal;