Skip to content

Commit b40387a

Browse files
Enhance NetworkStatusPanel with extended peer metadata and local agent details; refactor
1 parent 3384654 commit b40387a

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

ui/src/lib/NetworkStatusPanel.svelte

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,25 @@
9898
$: totalMsgRecv = connections.reduce((s, c) => s + c.recv_message_count, 0);
9999
$: hasRecvData = totalRecv > 0 || totalMsgRecv > 0;
100100
101+
// Runtime fields not yet exposed in @holochain/client typings
102+
type PeerMetaExt = PeerMeta & {
103+
dht_op_count?: number;
104+
storage_arc?: [number, number];
105+
is_tombstone?: boolean;
106+
};
107+
101108
$: peerMetaEntries = conversationInfo?.metrics
102-
? Object.entries(conversationInfo.metrics.gossip_state_summary?.peer_meta || {})
109+
? (Object.entries(
110+
conversationInfo.metrics.gossip_state_summary?.peer_meta || {},
111+
) as [string, PeerMetaExt][])
103112
: [];
104113
114+
$: localOpCountDisplay =
115+
(conversationInfo?.metrics?.gossip_state_summary as any)?.local_op_count ?? "?";
116+
117+
type LocalAgentExt = { agent: Uint8Array; storage_arc?: [number, number]; target_arc?: [number, number] };
118+
$: localAgentsExt = (conversationInfo?.localAgents ?? []) as unknown as LocalAgentExt[];
119+
105120
$: allKnownPeerKeys = (() => {
106121
if (!stats.metricsPerDna) return [];
107122
const keys = new Set<string>();
@@ -234,7 +249,7 @@
234249
{#if conversationInfo.metrics?.gossip_state_summary}
235250
<div class="flex justify-between">
236251
<span class="text-neutral-400">Local Ops</span>
237-
<span>{conversationInfo.metrics.gossip_state_summary["local_op_count"] ?? "?"}</span>
252+
<span>{localOpCountDisplay}</span>
238253
</div>
239254
{/if}
240255
{#if conversationInfo.peersBehindCount > 0}
@@ -264,12 +279,12 @@
264279
</div>
265280

266281
<!-- Local agent arcs -->
267-
{#if detailed && conversationInfo.localAgents.length > 0}
282+
{#if detailed && localAgentsExt.length > 0}
268283
<div class="mb-3 space-y-1 border-t border-neutral-700 pt-3">
269284
<div class="font-medium text-xs uppercase tracking-wide text-neutral-500">
270285
Local Agents
271286
</div>
272-
{#each conversationInfo.localAgents as agent}
287+
{#each localAgentsExt as agent}
273288
<div class="rounded bg-neutral-800 p-2 text-xs space-y-0.5">
274289
<div class="font-mono text-neutral-500" title={encodeHashToBase64(agent.agent)}>
275290
{displayAgent(encodeHashToBase64(agent.agent))}

ui/src/lib/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ export enum Alignment {
369369
}
370370

371371
export type CellIdB64 = string;
372-
export type ActionHashB64 = string;
373372

374373
export interface LocalFile {
375374
file: File;

ui/src/routes/+layout.svelte

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,15 @@
324324
await conversationMessageStore.initialize();
325325
326326
// Initialize signal handler
327-
createSignalHandler(relayClient, conversationStore, conversationMessageStore, onlinePeers);
328-
329-
isStoresSetup = true;
330-
331327
createSignalHandler(
332328
relayClient,
333329
conversationStore,
334330
conversationMessageStore,
335331
conferenceStore,
332+
onlinePeers,
336333
);
334+
335+
isStoresSetup = true;
337336
} catch (e) {
338337
console.error("Failed to init stores", e);
339338
toast.error(`${$t("common.stores_setup_error")}: ${e}`);

ui/src/routes/conversations/[id]/ConversationMessages.svelte

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,7 @@
106106
107107
// Reset the locks for the next time the user scrolls up
108108
shouldMaintainScroll = false;
109-
110-
const newScrollHeight = containerEl.scrollHeight;
111-
112-
const heightDifference =
113-
newScrollHeight - previousScrollHeight + (!isFirstFetch ? 20 * 40 : 0);
114-
115-
if (isFirstFetch) isFirstFetch = false;
116-
117-
containerEl.scrollTop = heightDifference;
109+
previousScrollHeight = 0;
118110
}
119111
});
120112

ui/src/store/ConversationMessageStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
type ActionHashB64,
1818
type CellId,
1919
type HoloHash,
20-
type Record,
2120
} from "@holochain/client";
2221
import { difference, flatten, range, sortBy, sum } from "lodash-es";
2322
import type { ConversationStore } from "./ConversationStore";
@@ -67,6 +66,7 @@ export interface ConversationMessageStore extends GenericKeyKeyValueStore<Messag
6766
files: LocalFile[],
6867
replyTo?: ActionHashB64,
6968
) => Promise<void>;
69+
sendJoinNotice: (key1: CellIdB64) => Promise<void>;
7070
getReplyCount: (key1: CellIdB64, messageHash: ActionHashB64) => Promise<number>;
7171
deleteMessage: (key1: CellIdB64, messageContent: string) => Promise<void>;
7272
handleMessageSignalReceived: (key1: CellIdB64, signal: MessageSignal) => Promise<void>;
@@ -1134,7 +1134,7 @@ export interface CellConversationMessageStore
11341134
sendJoinNotice: () => Promise<void>;
11351135
handleMessageSignalReceived: (signal: MessageSignal) => Promise<void>;
11361136
getReplyCount: (messageHash: ActionHashB64) => Promise<number>;
1137-
debugGetAllMessages: () => Promise<Record[]>;
1137+
debugGetAllMessages: () => Promise<MessageRecord[]>;
11381138
}
11391139

11401140
export function deriveCellConversationMessageStore(

0 commit comments

Comments
 (0)