From 2cc672e7513aa800d3d1a9f77de114e762251f5c Mon Sep 17 00:00:00 2001 From: malice Date: Thu, 9 Jul 2026 22:41:06 -0600 Subject: [PATCH] fix(meshcore): room-picker toggle now opens the room dropdown (#111) The MeshCore routing cell's channel-vs-room toggle derived its mode solely from whether the value started with `room:`, and the Room button merely cleared the value -- so room mode was never entered, the room (the only writer of a + // `room:` value) can never appear, since a freshly-cleared cell isn't a room + // value. When a cell has no explicit entry, we derive its mode from the value + // (a `room:`-prefixed value → 'room', else 'channel'). + const [cellModeMap, setCellModeMap] = useState>({}) + const cellKey = (family: string, region: string) => `${family}|${region}` + const fetchConfig = useCallback(async () => { try { const [configRes, regionsRes] = await Promise.all([ @@ -464,8 +473,13 @@ export default function MeshCoreRouting() { mt: null, mc: null, min_severity: 'routine', enabled: true, } const mcVal = cell.mc ?? '' - const targetsRoom = isRoomValue(mcVal) - const room = targetsRoom ? roomByPubkey(roomPubkeyOf(mcVal)) : undefined + const ck = cellKey(key, region) + // Mode comes from explicit toggle state; when unset, derive + // it from the current value so existing `room:` cells load + // in room mode and everything else in channel mode. + const mode = cellModeMap[ck] ?? (isRoomValue(mcVal) ? 'room' : 'channel') + const targetsRoom = mode === 'room' + const room = isRoomValue(mcVal) ? roomByPubkey(roomPubkeyOf(mcVal)) : undefined return (
{region} @@ -475,8 +489,10 @@ export default function MeshCoreRouting() { type="button" title="Target a channel" onClick={() => { - // Switching to channel: clear a room value, keep a channel value. - if (targetsRoom) setMcForRegion(key, region, null) + // Enter channel mode explicitly. Clear any room + // value so the channel input starts empty. + setCellModeMap(m => ({ ...m, [ck]: 'channel' })) + if (isRoomValue(mcVal)) setMcForRegion(key, region, null) }} className={`px-1.5 py-1 flex items-center ${ !targetsRoom ? 'bg-accent text-white' : 'text-slate-500 hover:text-slate-300' @@ -487,11 +503,13 @@ export default function MeshCoreRouting() {