Skip to content

Conversation

@wzulfikar
Copy link
Owner

@wzulfikar wzulfikar commented Nov 12, 2025

Integrate changes from zed-industries#42387 to implement agent tabs.

ux-zed-multitabs.mov.mp4

@wzulfikar wzulfikar changed the base branch from zd-main to main November 12, 2025 14:00
@wzulfikar wzulfikar changed the base branch from main to zd-main November 12, 2025 14:00
@wzulfikar wzulfikar changed the title add tabs Add agent tabs Nov 12, 2025
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted tab-related codes here to reduce chance of conflicts when syncing with upstream

/// Removes the currently selected thread.
RemoveSelectedThread,
/// Closes the currently active thread tab.
CloseActiveThreadTab,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example in keymap:

image

Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025
Repository owner deleted a comment from github-actions bot Nov 12, 2025

// Methods to manage tabs in AgentPanel
impl AgentPanel {
fn active_tab(&self) -> &AgentPanelTab {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential panic risk in active_tab() method. The unwrap_or_else(|| &self.tabs[0]) could panic if self.tabs is empty. Consider handling this case more explicitly.

let removed_id = id;
self.tabs.remove(removed_id);
let new_id = if self.active_tab_id == removed_id {
removed_id.min(self.tabs.len() - 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential panic risk in remove_tab_by_id() method at line 2440. The expression removed_id.min(self.tabs.len() - 1) could panic if self.tabs becomes empty after removal. Consider checking if self.tabs is empty before calculating new_id.

@wzulfikar wzulfikar merged commit 8acb116 into zd-main Nov 12, 2025
18 of 19 checks passed
fn active_tab(&self) -> &AgentPanelTab {
self.tabs
.get(self.active_tab_id)
.unwrap_or_else(|| &self.tabs[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indexing could panic if tabs is empty. Consider adding a guard or using .get() with proper error handling.


pub fn session_id(&self, cx: &App) -> Option<acp::SessionId> {
if let Some(thread) = self.thread() {
Some(thread.read(cx).session_id().clone())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using .map() instead of .clone() inside the closure since session_id() already returns a reference that can be cloned if needed.

let removed_id = id;
self.tabs.remove(removed_id);
let new_id = if self.active_tab_id == removed_id {
removed_id.min(self.tabs.len() - 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a guard to ensure tabs.len() - 1 doesn't underflow when tabs is empty.

}

fn set_active_tab_by_id(&mut self, new_id: TabId, window: &mut Window, cx: &mut Context<Self>) {
// TODO: need to check the total items in the list, if it is equal to 1, we should overlay it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO comment should be addressed before merging - consider implementing the logic to overlay when there is only one tab.

Repository owner deleted a comment from github-actions bot Nov 13, 2025
Repository owner deleted a comment from github-actions bot Nov 13, 2025
Repository owner deleted a comment from github-actions bot Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants