Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/okena-views-sidebar/src/hook_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ impl Sidebar {
let terminal_id = terminal_id.clone();
move |this, _, _window, cx| {
this.cursor_index = None;
this.workspace.update(cx, |ws, cx| {
ws.focus_terminal_by_id(&project_id, &terminal_id, cx);
this.request_broker.update(cx, |broker, cx| {
broker.push_overlay_request(
okena_workspace::requests::OverlayRequest::ShowHookTerminal {
project_id: project_id.clone(),
terminal_id: terminal_id.clone(),
},
cx,
);
});
}
}))
Expand Down
27 changes: 2 additions & 25 deletions crates/okena-views-sidebar/src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ pub struct Sidebar {
pub service_manager: Option<Entity<ServiceManager>>,
/// Collapsed state for group headers (Terminals/Services) per project
pub(crate) collapsed_groups: HashSet<(String, GroupKind)>,
/// Project IDs that have been auto-expanded due to hook terminals.
/// Tracked so we only auto-expand once (user can collapse afterward).
pub(crate) hook_auto_expanded: HashSet<String>,
/// Parent project IDs with in-flight worktree creation (debounce guard)
pub(crate) creating_worktree: HashSet<String>,
/// Callback to get settings
Expand Down Expand Up @@ -170,27 +167,8 @@ impl Sidebar {
cx.notify();
}).detach();

// Auto-expand projects that gain hook terminals (outside of render).
// Tracked in hook_auto_expanded so we only expand once per project
// (user can collapse afterward without it re-expanding).
cx.observe(&workspace, |this, workspace, cx| {
let ws = workspace.read(cx);
let mut changed = false;
for project in &ws.data().projects {
// Auto-expand projects with hook terminals
if !project.hook_terminals.is_empty() && this.hook_auto_expanded.insert(project.id.clone()) {
this.expanded_projects.insert(project.id.clone());
changed = true;
}
}
let before_len = this.hook_auto_expanded.len();
this.hook_auto_expanded.retain(|id| {
ws.data().projects.iter().any(|p| p.id == *id && !p.hook_terminals.is_empty())
});
if changed || this.hook_auto_expanded.len() != before_len {
cx.notify();
}
}).detach();
// Hook terminals are displayed in the dedicated HookPanel, so we no
// longer auto-expand the sidebar project when hooks appear.

Self {
workspace,
Expand All @@ -213,7 +191,6 @@ impl Sidebar {
dispatch_action: None,
service_manager: None,
collapsed_groups: HashSet::new(),
hook_auto_expanded: HashSet::new(),
creating_worktree: HashSet::new(),
get_settings: None,
get_remote_connections: None,
Expand Down
8 changes: 7 additions & 1 deletion crates/okena-views-terminal/src/layout/split_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub enum DragState {
initial_mouse_y: f32,
initial_height: f32,
},
/// Resizing per-project hook panel height
HookPanel {
project_id: String,
initial_mouse_y: f32,
initial_height: f32,
},
}

/// Trait object wrapper for ActionDispatch in DragState (needs Clone).
Expand Down Expand Up @@ -166,7 +172,7 @@ pub fn compute_resize(
ws.update_project_widths(new_widths, cx);
});
}
DragState::Sidebar | DragState::ServicePanel { .. } => {
DragState::Sidebar | DragState::ServicePanel { .. } | DragState::HookPanel { .. } => {
// Handled directly in RootView's on_mouse_move
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/okena-workspace/src/actions/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ mod tests {
project_order: order.into_iter().map(String::from).collect(),
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
}
}
Expand Down Expand Up @@ -290,6 +291,7 @@ mod gpui_tests {
project_order: order.into_iter().map(String::from).collect(),
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/okena-workspace/src/actions/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,7 @@ mod gpui_tests {
project_order: order.into_iter().map(String::from).collect(),
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
}
}
Expand Down
8 changes: 8 additions & 0 deletions crates/okena-workspace/src/actions/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ impl Workspace {
self.notify_data(cx);
}

/// Update hook panel height for a project
pub fn update_hook_panel_height(&mut self, project_id: &str, height: f32, cx: &mut Context<Self>) {
self.data.hook_panel_heights.insert(project_id.to_string(), height);
self.notify_data(cx);
}

/// Get project width or default equal distribution
pub fn get_project_width(&self, project_id: &str, visible_count: usize) -> f32 {
self.data.project_widths
Expand Down Expand Up @@ -735,6 +741,7 @@ mod tests {
project_order: vec![],
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
}
}
Expand Down Expand Up @@ -829,6 +836,7 @@ mod gpui_tests {
project_order: vec![],
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/okena-workspace/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ impl HookRunner {
script.push_str(&format!("export {}='{}'; ", k, escaped_v));
}
script.push_str(command);
script.push_str("; exec \"${SHELL:-sh}\"");
// Capture exit code and report it via OSC title before exec-ing
// into the interactive shell. The PTY event loop detects titles
// matching __okena_hook_exit:<code> and updates hook status.
script.push_str("; __okena_rc=$?; printf '\\033]0;__okena_hook_exit:%d\\007' \"$__okena_rc\"; exec \"${SHELL:-sh}\"");
let shell = ShellType::for_command(script);
self.backend.create_terminal(cwd, Some(&shell))
} else {
Expand Down
4 changes: 4 additions & 0 deletions crates/okena-workspace/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ pub fn default_workspace() -> WorkspaceData {
project_order: vec![project_id],
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: Vec::new(),
}
}
Expand Down Expand Up @@ -504,6 +505,7 @@ mod tests {
project_order: order.into_iter().map(String::from).collect(),
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders,
}
}
Expand Down Expand Up @@ -686,6 +688,7 @@ mod tests {
project_order: vec![],
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
};
let migrated = migrate_workspace(data);
Expand All @@ -700,6 +703,7 @@ mod tests {
project_order: vec![],
project_widths: HashMap::new(),
service_panel_heights: HashMap::new(),
hook_panel_heights: HashMap::new(),
folders: vec![],
};
let migrated = migrate_workspace(data);
Expand Down
1 change: 1 addition & 0 deletions crates/okena-workspace/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub enum OverlayRequest {
position: gpui::Point<gpui::Pixels>,
},
ShowServiceLog { project_id: String, service_name: String },
ShowHookTerminal { project_id: String, terminal_id: String },
FileSearch { project_path: String },
ContentSearch { project_path: String },
FileBrowser { project_path: String },
Expand Down
Loading
Loading