Skip to content

Commit 826ca20

Browse files
Felipe Gobbiclaude
andcommitted
fix: address CodeRabbit round 4 findings
- Guard onMarkAsRead behind reply handler existence check - Disable reply composer when session is unavailable - Use groupId consistently in collapse filtering and T-key toggle - Align slash-command key handler with rendered list ordering (fuzzyMatchWithScore + sort by score) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0a2758 commit 826ca20

3 files changed

Lines changed: 30 additions & 19 deletions

File tree

src/renderer/components/AgentInbox/FocusModeView.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -751,20 +751,16 @@ export default function FocusModeView({
751751

752752
const handleQuickReply = useCallback(() => {
753753
const text = replyText.trim();
754-
if (!text) return;
755-
if (onQuickReply) {
756-
onQuickReply(item.sessionId, item.tabId, text);
757-
}
754+
if (!text || !onQuickReply) return;
755+
onQuickReply(item.sessionId, item.tabId, text);
758756
onMarkAsRead?.(item.sessionId, item.tabId);
759757
setReplyText('');
760758
}, [replyText, item, onQuickReply, onMarkAsRead]);
761759

762760
const handleOpenAndReply = useCallback(() => {
763761
const text = replyText.trim();
764-
if (!text) return;
765-
if (onOpenAndReply) {
766-
onOpenAndReply(item.sessionId, item.tabId, text);
767-
}
762+
if (!text || !onOpenAndReply) return;
763+
onOpenAndReply(item.sessionId, item.tabId, text);
768764
onMarkAsRead?.(item.sessionId, item.tabId);
769765
}, [replyText, item, onOpenAndReply, onMarkAsRead]);
770766

@@ -1039,6 +1035,7 @@ export default function FocusModeView({
10391035
<textarea
10401036
ref={replyInputRef}
10411037
value={replyText}
1038+
disabled={!sessionExists}
10421039
onChange={(e) => setReplyText(e.target.value)}
10431040
onKeyDown={(e) => {
10441041
if (e.key === 'Enter') {
@@ -1067,7 +1064,7 @@ export default function FocusModeView({
10671064
// CRITICAL: Prevent focus-mode keyboard shortcuts from firing while typing
10681065
e.stopPropagation();
10691066
}}
1070-
placeholder="Reply to agent..."
1067+
placeholder={sessionExists ? 'Reply to agent...' : 'Session unavailable'}
10711068
rows={1}
10721069
aria-label="Reply to agent"
10731070
className="flex-1 resize-none rounded-lg px-3 py-2 text-sm outline-none"
@@ -1088,7 +1085,7 @@ export default function FocusModeView({
10881085
{/* Quick Reply button (primary) */}
10891086
<button
10901087
onClick={handleQuickReply}
1091-
disabled={!replyText.trim()}
1088+
disabled={!sessionExists || !replyText.trim()}
10921089
className="p-2 rounded-lg transition-colors flex-shrink-0"
10931090
style={{
10941091
backgroundColor: replyText.trim()
@@ -1104,7 +1101,7 @@ export default function FocusModeView({
11041101
{/* Open & Reply button (secondary) */}
11051102
<button
11061103
onClick={handleOpenAndReply}
1107-
disabled={!replyText.trim()}
1104+
disabled={!sessionExists || !replyText.trim()}
11081105
className="p-1.5 rounded-lg transition-colors flex-shrink-0 text-xs"
11091106
style={{
11101107
border: `1px solid ${theme.colors.border}`,

src/renderer/components/AgentInbox/InboxListView.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,9 @@ export default function InboxListView({
560560
return allRows.filter((row) => {
561561
if (row.type === 'header') return true;
562562
const collapseKey =
563-
sortMode === 'byAgent' ? row.item.sessionId : (row.item.groupName ?? 'Ungrouped');
563+
sortMode === 'byAgent'
564+
? row.item.sessionId
565+
: (row.item.groupId ?? row.item.groupName ?? 'Ungrouped');
564566
return !collapsedGroups.has(collapseKey);
565567
});
566568
}, [allRows, collapsedGroups, sortMode]);
@@ -886,7 +888,9 @@ export default function InboxListView({
886888
toggleGroup(row.groupKey);
887889
} else {
888890
const groupKey =
889-
sortMode === 'byAgent' ? row.item.sessionId : (row.item.groupName ?? 'Ungrouped');
891+
sortMode === 'byAgent'
892+
? row.item.sessionId
893+
: (row.item.groupId ?? row.item.groupName ?? 'Ungrouped');
890894
toggleGroup(groupKey);
891895
}
892896
}

src/renderer/hooks/input/useInputKeyDown.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { useCallback } from 'react';
1313
import type { TabCompletionSuggestion, TabCompletionFilter } from '../input/useTabCompletion';
1414
import type { AtMentionSuggestion } from '../input/useAtMentionCompletion';
15-
import { fuzzyMatch } from '../../utils/search';
15+
import { fuzzyMatchWithScore } from '../../utils/search';
1616
import { useInputContext } from '../../contexts/InputContext';
1717
import { useSessionStore, selectActiveSession } from '../../stores/sessionStore';
1818
import { useUIStore } from '../../stores/uiStore';
@@ -206,11 +206,21 @@ export function useInputKeyDown(deps: InputKeyDownDeps): InputKeyDownReturn {
206206
// Handle slash command autocomplete
207207
if (slashCommandOpen) {
208208
const isTerminalMode = activeSession?.inputMode === 'terminal';
209-
const filteredCommands = allSlashCommands.filter((cmd) => {
210-
if ('terminalOnly' in cmd && cmd.terminalOnly && !isTerminalMode) return false;
211-
if ('aiOnly' in cmd && cmd.aiOnly && isTerminalMode) return false;
212-
return fuzzyMatch(cmd.command, inputValue);
213-
});
209+
const inputLower = inputValue.toLowerCase();
210+
const filteredCommands = allSlashCommands
211+
.map((cmd) => {
212+
if ('terminalOnly' in cmd && cmd.terminalOnly && !isTerminalMode) return null;
213+
if ('aiOnly' in cmd && cmd.aiOnly && isTerminalMode) return null;
214+
const result = fuzzyMatchWithScore(cmd.command, inputLower);
215+
if (!result.matches) return null;
216+
return { cmd, score: result.score };
217+
})
218+
.filter(
219+
(item): item is { cmd: (typeof allSlashCommands)[number]; score: number } =>
220+
item !== null
221+
)
222+
.sort((a, b) => b.score - a.score)
223+
.map((item) => item.cmd);
214224

215225
if (e.key === 'ArrowDown') {
216226
e.preventDefault();

0 commit comments

Comments
 (0)