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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
id: 01M4YQFNJCJ32A99NQC28NQ6T9
anchor: function unreachable
created: 2026-10-15T02:50:26Z
norm: '1'
sig: dafb01d962243d11
body_hash: b1750761c8fca9d0
raw_hash: 4da6cfbe96c64428
lines: 93-97
---

without a team directory, a peer's last answer is the only record of its channels; dropping it on disconnect hides open conversations
9 changes: 7 additions & 2 deletions apps/host/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ function local(): Listing[] {
});
}

/** Channels only the directory knows: their host is unreachable, unless they are hosted. */
/** Channels only the directory or a peer's last answer knows: their host is unreachable, unless they are hosted. */
function listed(seen: Set<string>): Listing[] {
return directory.read().channels.filter((value) => !seen.has(value.id) && value.host !== name)
return [...directory.read().channels, ...peers.unreachable()]
.filter((value) => {
if (seen.has(value.id) || value.host === name) return false;
seen.add(value.id);
return true;
})
.map((value) =>
Object.assign({}, value, {
state: value.state === "archived" || value.hosted ? value.state : "offline" as const,
Expand Down
10 changes: 10 additions & 0 deletions apps/host/src/peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Peer = { machine: Machine; client: GatewayClient; github?: string };
/** One listing connection per online peer, kept only while the peer answers. */
const hosts = new Map<string, Peer>();
const listeners = new Set<() => void>();
/** Each peer's channels as it last answered, listed as offline while the peer is unreachable. */
const remembered = new Map<string, Listing[]>();

function emit() {
for (const listener of listeners) listener();
Expand Down Expand Up @@ -58,6 +60,7 @@ async function discover(signal: AbortSignal) {
});
status = client.status;
}
if (client.status === "open") remembered.set(name, client.channels);
emit();
});
hosts.set(name, host);
Expand Down Expand Up @@ -86,6 +89,13 @@ export function listings(): Listing[] {
);
}

/** Channels of peers that answered before but are unreachable now. */
export function unreachable(): Listing[] {
return [...remembered].flatMap(([name, channels]) =>
hosts.get(name)?.client.status === "open" ? [] : channels
);
}

/** Reachable peers' owners' GitHub logins. */
export function people(): People {
const people: People = {};
Expand Down