Skip to content

Commit 773bb34

Browse files
committed
Fixed TUI tab selection bug
1 parent 30ce275 commit 773bb34

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

clients/tui/src/App.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,15 +1133,28 @@ function App({
11331133
inspectorStderrLogs,
11341134
]);
11351135

1136-
// Set focus to the default for the active tab whenever the tab changes
1136+
// Keep focus state consistent when switching tabs (only adjust if focus is already in tab content)
11371137
useEffect(() => {
11381138
if (activeTab === "messages") {
1139-
setFocus("messagesList");
1139+
if (focus === "tabContentList" || focus === "tabContentDetails") {
1140+
setFocus("messagesList");
1141+
}
11401142
} else if (activeTab === "requests") {
1141-
setFocus("requestsList");
1143+
if (focus === "tabContentList" || focus === "tabContentDetails") {
1144+
setFocus("requestsList");
1145+
}
11421146
} else {
1143-
setFocus("tabContentList");
1147+
if (
1148+
focus === "messagesList" ||
1149+
focus === "messagesDetail" ||
1150+
focus === "requestsList" ||
1151+
focus === "requestsDetail"
1152+
) {
1153+
setFocus("tabContentList");
1154+
}
11441155
}
1156+
// Intentionally not depending on focus to avoid loops
1157+
// eslint-disable-next-line react-hooks/exhaustive-deps
11451158
}, [activeTab]);
11461159

11471160
// Switch away from logging tab if server is not stdio

0 commit comments

Comments
 (0)