aboutsummaryrefslogtreecommitdiff
path: root/src/app/api
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-12 19:07:07 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-12 19:10:09 +0300
commitf7a7da03fc27cc6fe4e6a44dabddcd303f939bb9 (patch)
tree69a00241e4500703bb723b64dd0060cc83730a0b /src/app/api
parent53429206b736aa0fcfb1c5bfc1c0b11dcca3a059 (diff)
fix: stabilize public pane and tab ids
refs #569
Diffstat (limited to 'src/app/api')
-rw-r--r--src/app/api/panes.rs14
-rw-r--r--src/app/api/tabs.rs18
-rw-r--r--src/app/api/workspaces.rs5
3 files changed, 25 insertions, 12 deletions
diff --git a/src/app/api/panes.rs b/src/app/api/panes.rs
index 5afac850..326fbd9f 100644
--- a/src/app/api/panes.rs
+++ b/src/app/api/panes.rs
@@ -599,6 +599,9 @@ impl App {
let Some((ws_idx, pane_id)) = self.parse_pane_id(&params.pane_id) else {
return pane_not_found(id, &params.pane_id);
};
+ let Some(public_pane_id) = self.public_pane_id(ws_idx, pane_id) else {
+ return pane_not_found(id, &params.pane_id);
+ };
let Some((pane, workspace_id)) = self.lookup_runtime(ws_idx, pane_id) else {
return pane_not_found(id, &params.pane_id);
};
@@ -630,7 +633,7 @@ impl App {
id,
ResponseResult::PaneRead {
read: PaneReadResult {
- pane_id: params.pane_id,
+ pane_id: public_pane_id,
workspace_id,
tab_id: self.public_tab_id(ws_idx, tab_idx).unwrap(),
source: params.source,
@@ -887,6 +890,10 @@ impl App {
let Some((ws_idx, pane_id)) = self.parse_pane_id(&target.pane_id) else {
return pane_not_found(id, &target.pane_id);
};
+ let Some(public_pane_id) = self.public_pane_id(ws_idx, pane_id) else {
+ return pane_not_found(id, &target.pane_id);
+ };
+ let workspace_id = self.public_workspace_id(ws_idx);
if self.state.close_pane_would_close_workspace(ws_idx, pane_id)
&& self.state.confirm_implicit_worktree_group_close(ws_idx)
{
@@ -896,7 +903,6 @@ impl App {
"closing this pane would close a worktree group",
);
}
- let workspace_id = self.state.workspaces[ws_idx].id.clone();
let terminal_id = self.state.terminal_id_for_pane(ws_idx, pane_id);
let should_close_workspace = {
let Some(ws) = self.state.workspaces.get_mut(ws_idx) else {
@@ -911,7 +917,7 @@ impl App {
self.emit_event(EventEnvelope {
event: EventKind::PaneClosed,
data: EventData::PaneClosed {
- pane_id: target.pane_id.clone(),
+ pane_id: public_pane_id,
workspace_id: workspace_id.clone(),
},
});
@@ -926,7 +932,7 @@ impl App {
self.emit_event(EventEnvelope {
event: EventKind::PaneClosed,
data: EventData::PaneClosed {
- pane_id: target.pane_id,
+ pane_id: public_pane_id,
workspace_id,
},
});
diff --git a/src/app/api/tabs.rs b/src/app/api/tabs.rs
index 4057eced..7c7ad9d7 100644
--- a/src/app/api/tabs.rs
+++ b/src/app/api/tabs.rs
@@ -98,9 +98,13 @@ impl App {
);
if let Some(label) = label {
let workspace_id = self.state.workspaces[ws_idx].id.clone();
- let tab_id = self
- .public_tab_id(ws_idx, tab_idx)
- .unwrap_or_else(|| format!("{}:{}", workspace_id, tab_idx + 1));
+ let tab_id = self.public_tab_id(ws_idx, tab_idx).unwrap_or_else(|| {
+ format!(
+ "{}:t{}",
+ workspace_id,
+ crate::workspace::encode_public_number(tab_idx + 1)
+ )
+ });
if let Some(tab) = self
.state
.workspaces
@@ -186,6 +190,10 @@ impl App {
let Some((ws_idx, tab_idx)) = self.parse_tab_id(&target.tab_id) else {
return tab_not_found(id, &target.tab_id);
};
+ let Some(tab_id) = self.public_tab_id(ws_idx, tab_idx) else {
+ return tab_not_found(id, &target.tab_id);
+ };
+ let workspace_id = self.public_workspace_id(ws_idx);
let terminal_ids = self.state.terminal_ids_for_tab(ws_idx, tab_idx);
let Some(ws) = self.state.workspaces.get_mut(ws_idx) else {
return tab_not_found(id, &target.tab_id);
@@ -210,8 +218,8 @@ impl App {
self.emit_event(EventEnvelope {
event: EventKind::TabClosed,
data: EventData::TabClosed {
- tab_id: target.tab_id,
- workspace_id: self.public_workspace_id(ws_idx),
+ tab_id,
+ workspace_id,
},
});
diff --git a/src/app/api/workspaces.rs b/src/app/api/workspaces.rs
index 92b41486..e1966adf 100644
--- a/src/app/api/workspaces.rs
+++ b/src/app/api/workspaces.rs
@@ -146,14 +146,13 @@ impl App {
if self.state.workspaces.get(index).is_none() {
return workspace_not_found(id, &target.workspace_id);
}
+ let workspace_id = self.public_workspace_id(index);
self.state.selected = index;
self.state.close_selected_workspace();
self.shutdown_detached_terminal_runtimes();
self.emit_event(EventEnvelope {
event: EventKind::WorkspaceClosed,
- data: EventData::WorkspaceClosed {
- workspace_id: target.workspace_id,
- },
+ data: EventData::WorkspaceClosed { workspace_id },
});
encode_success(id, ResponseResult::Ok {})