Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions reticulum-sidecar/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,31 @@ Listed in `scripts/lib/ratspeak-overlay-apply-list.sh` and `RATSPEAK_PATCH_ENTRI

When ratspeak/rsReticulum matches Python pathless-LINK attached-only (or equivalent) on floated `origin/main`, remove this patch and the apply step.

## rsReticulum-announce-rebroadcast-exclude-rf.patch

With `enable_transport`, rsReticulum enqueues rebroadcasted mesh announces onto every eligible OUT iface, including flow-controlled BLE RNodes. Host TX mpsc fills while FC drains slowly (overnight / busy TCP mesh). Skip RF sinks (`iface_is_pathless_link_rf_sink` from pathless-link overlay) in `broadcast_announce_on_interfaces` only. Local discovery announces still use `broadcast_local_announce_on_interfaces` (RNode included).

| Field | Value |
| ----- | ----- |
| **Base commit** | floated `origin/main` after pathless-link-exclude-rf (regenerate; record short SHA in PR) |
| **Upstream PR** | none yet (mesh-client-local) |
| **Depends on** | `rsReticulum-pathless-link-exclude-rf.patch` |

**Touches:** `crates/rns-transport/src/actor/mod.rs`

### Apply locally

```bash
./scripts/apply-rsReticulum-pathless-link-exclude-rf.sh
./scripts/apply-rsReticulum-announce-rebroadcast-exclude-rf.sh
```

Listed in `scripts/lib/ratspeak-overlay-apply-list.sh` and `RATSPEAK_PATCH_ENTRIES` in `scripts/update.sh`.

### Sunset

When ratspeak/rsReticulum rate-limits or excludes RF for announce rebroadcast equivalently on floated `origin/main`, remove this patch and the apply step.

## rsLXMF-propagation-client-abort-transfer.patch

Adds `PropagationClient::abort_transfer` so Cancel / mid-transfer abort leaves the client **Idle**. Without it, a cancelled Sync can leave `/get` stuck busy and the next Sync returns `PROPAGATION_RETRIEVE_BUSY` forever (or Auto falsely concludes there are no PNs).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From: mesh-client
Subject: Exclude RF sinks from announce rebroadcast enqueue

With enable_transport, rebroadcasted mesh announces were enqueued onto every
eligible OUT iface including flow-controlled BLE RNodes. Host TX mpsc filled
while FC drained slowly. Local announces still use
broadcast_local_announce_on_interfaces (unchanged). Requires
iface_is_pathless_link_rf_sink from pathless-link-exclude-rf overlay.

--- a/crates/rns-transport/src/actor/mod.rs
+++ b/crates/rns-transport/src/actor/mod.rs
@@ -1577,6 +1577,11 @@
/// optionally one). Eligibility mirrors Python's AP/roaming/boundary mode
/// gates. Enqueueing lets `process_announce_queues` apply ANNOUNCE_CAP
/// spacing and hop priority.
+ ///
+ /// Flow-controlled RF sinks (RNode / low-bitrate) are skipped for
+ /// *rebroadcast* — transport-enabled leaves otherwise enqueue every mesh
+ /// announce onto BLE RNodes and fill the host TX queue while FC drains
+ /// slowly. Local announces still use [`broadcast_local_announce_on_interfaces`].
fn broadcast_announce_on_interfaces(&mut self, raw: &[u8], except: Option<InterfaceId>) {
let destination_hash = rns_wire::header::PacketHeader::unpack(raw)
.ok()
@@ -1588,10 +1593,20 @@
// shared Arc for free.
let shared = Bytes::copy_from_slice(raw);

- let ids: Vec<InterfaceId> = self
+ // Collect candidates before interface_allows_announce borrows self.
+ let candidate_ids: Vec<InterfaceId> = self
.interfaces
- .keys()
- .copied()
+ .iter()
+ .filter_map(|(&id, entry)| {
+ if except == Some(id) || iface_is_pathless_link_rf_sink(entry) {
+ None
+ } else {
+ Some(id)
+ }
+ })
+ .collect();
+ let ids: Vec<InterfaceId> = candidate_ids
+ .into_iter()
.filter(|id| self.interface_allows_announce(*id, &destination_hash, except))
.collect();

40 changes: 40 additions & 0 deletions scripts/apply-rsReticulum-announce-rebroadcast-exclude-rf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Apply mesh-client rsReticulum announce-rebroadcast RF exclusion overlay.
# Transport-mode announce rebroadcast must not enqueue onto flow-controlled RNodes.
# Requires pathless-link-exclude-rf (iface_is_pathless_link_rf_sink) applied first.
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
# shellcheck source=lib/apply-ratspeak-overlay.sh
source "${SCRIPT_DIR}/lib/apply-ratspeak-overlay.sh"
PATCH_FILE="${REPO_ROOT}/reticulum-sidecar/patches/rsReticulum-announce-rebroadcast-exclude-rf.patch"
RNS_DIR="${RS_RETICULUM_DIR:-${REPO_ROOT}/.rsstack/rsReticulum}"
MOD_RS="${RNS_DIR}/crates/rns-transport/src/actor/mod.rs"

if ! git -C "${RNS_DIR}" rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "error: rsReticulum not found at ${RNS_DIR}" >&2
echo "Clone: git clone https://github.com/ratspeak/rsReticulum.git ${RNS_DIR}" >&2
exit 1
fi

if [[ ! -f "${PATCH_FILE}" ]]; then
echo "error: patch not found at ${PATCH_FILE}" >&2
exit 1
fi

if [[ ! -f "${MOD_RS}" ]] || ! grep -q 'iface_is_pathless_link_rf_sink' "${MOD_RS}"; then
echo "error: pathless-link-exclude-rf overlay required first" >&2
echo "Run: ./scripts/apply-rsReticulum-pathless-link-exclude-rf.sh" >&2
exit 1
fi

if grep -q 'Flow-controlled RF sinks (RNode / low-bitrate) are skipped for' "${MOD_RS}"; then
echo "announce-rebroadcast-exclude-rf overlay already applied on rsReticulum @ $(git -C "${RNS_DIR}" rev-parse --short HEAD)"
exit 0
fi

if apply_ratspeak_overlay_or_die "${RNS_DIR}" "${PATCH_FILE}" "announce-rebroadcast-exclude-rf"; then
exit 0
fi
exit 1
1 change: 1 addition & 0 deletions scripts/lib/ratspeak-overlay-apply-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RS_RETICULUM_APPLY_SCRIPTS=(
apply-rsReticulum-inbound-raw-saturation-log.sh
apply-rsReticulum-interface-tx-queue-stats.sh
apply-rsReticulum-pathless-link-exclude-rf.sh
apply-rsReticulum-announce-rebroadcast-exclude-rf.sh
)

RS_LXMF_APPLY_SCRIPTS=(
Expand Down
1 change: 1 addition & 0 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ check_ratspeak_patches() {
'rsReticulum-inbound-raw-saturation-log.patch|ratspeak/rsReticulum||rsReticulum inbound-raw saturation log|'
'rsReticulum-interface-tx-queue-stats.patch|ratspeak/rsReticulum||rsReticulum interface TX queue stats|'
'rsReticulum-pathless-link-exclude-rf.patch|ratspeak/rsReticulum||rsReticulum pathless Link exclude RF sinks|'
'rsReticulum-announce-rebroadcast-exclude-rf.patch|ratspeak/rsReticulum||rsReticulum announce rebroadcast exclude RF sinks|'
'rsLXMF-propagation-sync-peering.patch|ratspeak/rsLXMF|4|rsLXMF propagation sync peering|https://github.com/ratspeak/rsLXMF/pull/4'
'rsLXMF-propagation-node-policy-setters.patch|ratspeak/rsLXMF|6|rsLXMF PropagationNode policy setters|https://github.com/ratspeak/rsLXMF/pull/6'
'rsLXMF-propagation-node-deferred-messagestore-load.patch|ratspeak/rsLXMF||rsLXMF PropagationNode deferred messagestore load|'
Expand Down
77 changes: 74 additions & 3 deletions src/renderer/components/RrcPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ describe('RrcPanel', () => {
expect(window.electronAPI.reticulum.rrc.setNickname).toHaveBeenCalled();
});
await waitFor(() => {
expect(whoSendCalls().some((args) => (args[0] as { body?: string }).body === '/who')).toBe(
true,
);
expect(
whoSendCalls().some((args) => (args[0] as { body?: string }).body === '/who general'),
).toBe(true);
});
});

Expand Down Expand Up @@ -749,6 +749,77 @@ describe('RrcPanel', () => {
).toBe(false);
});

it('expands IRC-style /op into rrcd room-first body before send', async () => {
const user = userEvent.setup();
const store = useRrcSessionStore.getState();
store.applyStatus('active', hubA, 'Hub A');
store.roomJoined('general', [
{ identity_hash: 'cccccccccccccccccccccccccccccccc', nickname: 'Alice' },
]);
store.setActiveRoom('general');
vi.mocked(window.electronAPI.reticulum.rrc.send).mockClear();
vi.mocked(window.electronAPI.reticulum.rrc.send).mockResolvedValue({ ok: true });

render(<RrcPanel isActive />);
await waitFor(() => {
expect(whoSendCalls().length).toBeGreaterThan(0);
});
vi.mocked(window.electronAPI.reticulum.rrc.send).mockClear();

const composer = screen.getByRole('textbox', { name: /Message or \/command/i });
await user.clear(composer);
await user.type(composer, '/op alice');
await user.click(screen.getByRole('button', { name: 'Send' }));

await waitFor(() => {
expect(vi.mocked(window.electronAPI.reticulum.rrc.send)).toHaveBeenCalledWith(
expect.objectContaining({
hub_dest_hash: hubA,
room: 'general',
body: '/op general alice',
type: 'msg',
}),
);
});
});

it('expands bare /who to include the focused room and omits K_ROOM', async () => {
const user = userEvent.setup();
const store = useRrcSessionStore.getState();
store.applyStatus('active', hubA, 'Hub A');
store.roomJoined('general', [
{ identity_hash: 'cccccccccccccccccccccccccccccccc', nickname: 'Alice' },
]);
store.setActiveRoom('general');
vi.mocked(window.electronAPI.reticulum.rrc.send).mockClear();
vi.mocked(window.electronAPI.reticulum.rrc.send).mockResolvedValue({ ok: true });

render(<RrcPanel isActive />);
await waitFor(() => {
expect(whoSendCalls().length).toBeGreaterThan(0);
});
vi.mocked(window.electronAPI.reticulum.rrc.send).mockClear();

const composer = screen.getByRole('textbox', { name: /Message or \/command/i });
await user.clear(composer);
await user.type(composer, '/who');
await user.click(screen.getByRole('button', { name: 'Send' }));

await waitFor(() => {
expect(vi.mocked(window.electronAPI.reticulum.rrc.send)).toHaveBeenCalledWith(
expect.objectContaining({
hub_dest_hash: hubA,
body: '/who general',
type: 'msg',
}),
);
});
const call = vi.mocked(window.electronAPI.reticulum.rrc.send).mock.calls.at(-1)?.[0] as {
room?: string;
};
expect(call.room).toBeUndefined();
});

it('sends one /who per hub when switching focus', async () => {
const store = useRrcSessionStore.getState();
store.applyStatus('active', hubA, 'Hub A');
Expand Down
25 changes: 18 additions & 7 deletions src/renderer/components/RrcPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
toggleRrcRoomFavourite,
} from '@/renderer/lib/rrcRoomPrefs';
import {
expandRrcHubSlashBody,
parseRrcSlashInput,
resolveRrcMsgTarget,
RRC_HELP_I18N_KEYS,
Expand Down Expand Up @@ -247,13 +248,18 @@ export default function RrcPanel({ isActive, alwaysShowMessageActions = false }:
const sendHubCommand = useCallback(
async (body: string) => {
if (status !== 'active' || !hubDestHash) return;
const isWho = /^\s*\/who(?:\s|$)/i.test(body);
const expanded = expandRrcHubSlashBody(body, activeRoom);
const isWho = /^\s*\/(?:who|names)(?:\s|$)/i.test(expanded);
const hubRoom =
!isWho && activeRoom && !activeRoom.startsWith('[') && !isRrcDmRoom(activeRoom)
? activeRoom
: undefined;
const whoForceRoom = isWho
? resolveRrcWhoTranscriptForceRoom(body, activeRoom, rooms.keys())
? resolveRrcWhoTranscriptForceRoom(
expanded.replace(/^\s*\/names\b/i, '/who'),
activeRoom,
rooms.keys(),
)
: null;
if (whoForceRoom) {
useRrcSessionStore.getState().reserveWhoTranscriptForce(whoForceRoom, hubDestHash);
Expand All @@ -262,7 +268,7 @@ export default function RrcPanel({ isActive, alwaysShowMessageActions = false }:
const res = await rrcSendBounded({
hub_dest_hash: hubDestHash,
room: hubRoom,
body,
body: expanded,
type: 'msg',
});
if (!res.ok && whoForceRoom) {
Expand Down Expand Up @@ -830,9 +836,14 @@ export default function RrcPanel({ isActive, alwaysShowMessageActions = false }:
useRrcSessionStore.getState().setError(t('rrc.sendFailed'));
return;
}
const isWho = /^\s*\/who(?:\s|$)/i.test(parsed.body);
const expanded = expandRrcHubSlashBody(parsed.body, activeRoom);
const isWho = /^\s*\/(?:who|names)(?:\s|$)/i.test(expanded);
const whoForceRoom = isWho
? resolveRrcWhoTranscriptForceRoom(parsed.body, activeRoom, rooms.keys())
? resolveRrcWhoTranscriptForceRoom(
expanded.replace(/^\s*\/names\b/i, '/who'),
activeRoom,
rooms.keys(),
)
: null;
if (whoForceRoom) {
useRrcSessionStore.getState().reserveWhoTranscriptForce(whoForceRoom, hubDestHash);
Expand All @@ -845,7 +856,7 @@ export default function RrcPanel({ isActive, alwaysShowMessageActions = false }:
!isWho && activeRoom && !activeRoom.startsWith('[') && !isRrcDmRoom(activeRoom)
? activeRoom
: undefined,
body: parsed.body,
body: expanded,
type: 'msg',
});
} catch (e) {
Expand All @@ -861,7 +872,7 @@ export default function RrcPanel({ isActive, alwaysShowMessageActions = false }:
useRrcSessionStore.getState().setError(res.error ?? t('rrc.sendFailed'));
return;
}
appendSystemLines([t('rrc.slash.commandSent', { cmd: parsed.body })]);
appendSystemLines([t('rrc.slash.commandSent', { cmd: expanded })]);
setDraft('');
return;
}
Expand Down
20 changes: 20 additions & 0 deletions src/renderer/lib/rrcMessageDisplay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RRC_HUB_STREAM_ROOM } from '@/renderer/stores/rrcSessionStore';

import {
parseRrcWhisperEcho,
resolveRrcHubScopedNoticeRoom,
resolveRrcInboundChatRoom,
shouldDisplayRrcChatMessage,
shouldDropEmptyRrcInbound,
Expand Down Expand Up @@ -40,6 +41,25 @@ describe('resolveRrcInboundChatRoom', () => {
});
});

describe('resolveRrcHubScopedNoticeRoom', () => {
it('keeps non-empty K_ROOM unchanged', () => {
expect(resolveRrcHubScopedNoticeRoom('lobby', 'general')).toBe('lobby');
});

it('surfaces empty K_ROOM into the focused real room', () => {
expect(resolveRrcHubScopedNoticeRoom('', 'general')).toBe('general');
expect(resolveRrcHubScopedNoticeRoom(undefined, '#Lobby')).toBe('#Lobby');
});

it('keeps [hub] when focus is synthetic or a DM', () => {
expect(resolveRrcHubScopedNoticeRoom('', '[hub]')).toBe(RRC_HUB_STREAM_ROOM);
expect(resolveRrcHubScopedNoticeRoom('', '@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toBe(
RRC_HUB_STREAM_ROOM,
);
expect(resolveRrcHubScopedNoticeRoom('', null)).toBe(RRC_HUB_STREAM_ROOM);
});
});

describe('shouldShowRrcWhoTranscript', () => {
it('allows the first /who snapshot per room and hides later ones', () => {
const shown = new Set<string>();
Expand Down
17 changes: 17 additions & 0 deletions src/renderer/lib/rrcMessageDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isRrcDmRoom } from '@/renderer/lib/rrcDmRoom';
import { RRC_HUB_STREAM_ROOM, rrcRoomMatchKey } from '@/renderer/lib/rrcRoomName';
import type { RrcChatMessage } from '@/shared/rrc-types';

Expand Down Expand Up @@ -29,6 +30,22 @@ export function resolveRrcInboundChatRoom(wireRoom: string | null | undefined):
return room || RRC_HUB_STREAM_ROOM;
}

/**
* Hub-global NOTICE/ERROR often arrive with empty K_ROOM. While the user is focused
* on a real joined room, surface those replies there so slash-command output is visible
* without switching to `[hub]`. Synthetic / DM focus keeps `[hub]`.
*/
export function resolveRrcHubScopedNoticeRoom(
wireRoom: string | null | undefined,
activeRoom: string | null | undefined,
): string {
const resolved = resolveRrcInboundChatRoom(wireRoom);
if (resolved !== RRC_HUB_STREAM_ROOM) return resolved;
const focused = activeRoom?.trim() ?? '';
if (!focused || focused.startsWith('[') || isRrcDmRoom(focused)) return resolved;
return focused;
}

/**
* First `/who` NOTICE per room join may appear in chat; later snapshots update the
* nicklist only. `shownMatchKeys` holds `rrcRoomMatchKey` values already shown.
Expand Down
Loading