Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit be03ca0

Browse files
staticoclaude
andcommitted
Fix chat selection bugs and preserve node selection on updates
- Chat message filter in input handler now matches ChatPanel (broadcast only), fixing: up arrow needing multiple presses, selecting past last message, and 'n' navigating to wrong node - Node selection is preserved by tracking selected node number across list updates instead of relying on index alone Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2c9b833 commit be03ca0

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/ui/App.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,25 @@ export function App({ address, packetStore, nodeStore, skipConfig = false, skipN
18761876
return getSortedNodes(filtered, nodesSortKey, nodesSortAscending);
18771877
}, [nodes, nodesFilter, nodesSortKey, nodesSortAscending, getSortedNodes]);
18781878

1879+
// Preserve node selection across list updates by tracking selected node number
1880+
const selectedNodeNumRef = useRef<number | null>(null);
1881+
// Keep ref in sync with current selection
1882+
if (filteredNodes[selectedNodeIndex]) {
1883+
selectedNodeNumRef.current = filteredNodes[selectedNodeIndex].num;
1884+
}
1885+
useEffect(() => {
1886+
const prev = selectedNodeNumRef.current;
1887+
if (prev != null && filteredNodes.length > 0) {
1888+
const newIndex = filteredNodes.findIndex(n => n.num === prev);
1889+
if (newIndex >= 0) {
1890+
setSelectedNodeIndex(newIndex);
1891+
} else {
1892+
// Node disappeared (filtered out) — clamp to valid range
1893+
setSelectedNodeIndex(i => Math.min(i, filteredNodes.length - 1));
1894+
}
1895+
}
1896+
}, [filteredNodes]);
1897+
18791898
// Build flat config rows
18801899
const flatConfigRows = useMemo(() =>
18811900
buildFlatRows(configStore, configChannels, configOwner, localMeshViewUrl, configFilter || undefined),
@@ -2308,7 +2327,7 @@ export function App({ address, packetStore, nodeStore, skipConfig = false, skipN
23082327
}
23092328
}
23102329
} else if (mode === "chat") {
2311-
const channelMessages = messages.filter((m) => m.channel === chatChannel);
2330+
const channelMessages = messages.filter((m) => m.channel === chatChannel && m.toNode === 0xffffffff);
23122331
const emojiCount = 17; // FIRMWARE_EMOJIS.length
23132332

23142333
// Emoji selector mode

0 commit comments

Comments
 (0)