Skip to content

The agent that grows with you

style(tui): the delete hook takes the possibly-missing row, keeping the picker's key handler under its complexity cap

yoniebans048b20eab4a8
diff --git a/ui-tui/src/components/activeSessionSwitcher.tsx b/ui-tui/src/components/activeSessionSwitcher.tsx
index ef24326660e..ec3b905dbfe 100644
--- a/ui-tui/src/components/activeSessionSwitcher.tsx
+++ b/ui-tui/src/components/activeSessionSwitcher.tsx
@@ -596,12 +596,8 @@ export function ActiveSessionSwitcher({
// other key cancels the prompt (mirrors the standalone resume picker).
if (confirmDelete !== null) {
if (ch?.toLowerCase() === 'd') {
- const target = history.find(h => h.id === confirmDelete)
setConfirmDelete(null)
-
- if (target) {
- performDelete(target)
- }
+ performDelete(history.find(h => h.id === confirmDelete))
} else {
setConfirmDelete(null)
}
diff --git a/ui-tui/src/hooks/useSessionDelete.ts b/ui-tui/src/hooks/useSessionDelete.ts
index 94fff15b27d..b4643a71a61 100644
--- a/ui-tui/src/hooks/useSessionDelete.ts
+++ b/ui-tui/src/hooks/useSessionDelete.ts
@@ -25,8 +25,8 @@ export function useSessionDelete(
}
const performDelete = useCallback(
- (target: SessionListRow) => {
- if (deletingRef.current) {
+ (target: SessionListRow | undefined) => {
+ if (!target || deletingRef.current) {
return
}
@@ -55,7 +55,7 @@ export function useSessionDelete(
settle()
})
- .catch((e: unknown) => {
+ .catch(rejection => {
// The revision read attached this view to a session it was not showing; a refused
// delete hands it back closed so it does not reappear in the live section.
if (readSubscription) {
@@ -68,7 +68,7 @@ export function useSessionDelete(
.catch(() => undefined)
}
- onError(rpcErrorMessage(e))
+ onError(rpcErrorMessage(rejection))
settle()
})
},