mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
feat: show P2P transfer and comparison progress
Show per-peer document revision counts and brief directional comparison labels in both P2P panes and the editor status. Use the P2P projection for the main status bar when P2P is the selected remote. Retain labelled sequence progress for peers without statistics, and keep adjunct P2P counters separate from the selected remote. Requires the additive P2P statistics API in vrtmrz/livesync-commonlib@be7bd0988e. Consumer checks passed against a packed candidate; pin the published package before integration.
This commit is contained in:
1 parent
3a897fcfc2
commit
fc5f02ca3b
6 files changed
+395
-6
No files matched your search
@@ -13,6 +13,7 @@
|
||||
import { delay, fireAndForget } from "octagonal-wheels/promises";
|
||||
import P2PServerStatusCard from "./P2PServerStatusCard.svelte";
|
||||
import { $msg as translateMessage } from "@/common/translation";
|
||||
import { observeP2PDiagnosticsProgress, type P2PStatusProjection } from "@/modules/features/P2PStatusLabel";
|
||||
|
||||
interface Props {
|
||||
p2p: P2PServiceViews;
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
let serverInfo = $state<P2PServerInfo | undefined>(undefined);
|
||||
let syncingPeerId = $state<string | null>(null);
|
||||
let peerProgress = $state<P2PStatusProjection["peers"]>(new Map());
|
||||
|
||||
const logLevel = $derived(showResult ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO);
|
||||
async function requestServerStatus() {
|
||||
@@ -34,6 +36,9 @@
|
||||
eventHub.emitEvent(EVENT_REQUEST_STATUS);
|
||||
}
|
||||
onMount(() => {
|
||||
const unsubscribeProgress = observeP2PDiagnosticsProgress(p2p.diagnostics, (snapshot) => {
|
||||
peerProgress = snapshot.peers;
|
||||
});
|
||||
// ServerStatus
|
||||
const unsubscribe = eventHub.onEvent(EVENT_SERVER_STATUS, (status) => {
|
||||
serverInfo = status;
|
||||
@@ -42,7 +47,10 @@
|
||||
await delay(100);
|
||||
await requestServerStatus();
|
||||
});
|
||||
return unsubscribe;
|
||||
return () => {
|
||||
unsubscribe();
|
||||
unsubscribeProgress();
|
||||
};
|
||||
});
|
||||
|
||||
async function handleSync(peerId: string) {
|
||||
@@ -109,6 +117,14 @@
|
||||
<div class="peer-item">
|
||||
<div class="peer-info">
|
||||
<div class="peer-name">{peer.name}</div>
|
||||
{#if peerProgress.has(peer.peerId)}
|
||||
<div
|
||||
class="peer-progress"
|
||||
title="↑↓: transferred document revisions (seq for older peers); ⏩: compared changes-feed entries"
|
||||
>
|
||||
{peerProgress.get(peer.peerId)?.message}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="peer-meta">
|
||||
<span class="badge">{peer.platform}</span>
|
||||
<span class="peer-id-mini" title={peer.peerId}>
|
||||
@@ -176,6 +192,12 @@
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.peer-progress {
|
||||
color: var(--text-muted);
|
||||
font-size: var(--font-ui-small);
|
||||
font-variant-numeric: tabular-nums;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.p2p-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
import { SetupManager } from "@/modules/features/SetupManager";
|
||||
import { Menu } from "@/deps";
|
||||
import { $msg as translateMessage } from "@/common/translation";
|
||||
import { observeP2PDiagnosticsProgress, type P2PStatusProjection } from "@/modules/features/P2PStatusLabel";
|
||||
import {
|
||||
hasExactP2PPeer,
|
||||
togglePersistedP2PPeer,
|
||||
@@ -42,6 +43,7 @@
|
||||
let decidingPeerId = $state<string | null>(null);
|
||||
let replicatingPeerId = $state<string | null>(null);
|
||||
let communicatingUntil = $state<Record<string, number>>({});
|
||||
let peerProgress = $state<P2PStatusProjection["peers"]>(new Map());
|
||||
const COMMUNICATION_HOLD_MS = 2500;
|
||||
// Later setting changes arrive through EVENT_SETTING_SAVED; these values only seed local state at mount time.
|
||||
const readCurrentSettings = () => core.services.setting.currentSettings();
|
||||
@@ -125,6 +127,9 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const unsubscribeProgress = observeP2PDiagnosticsProgress(p2p.diagnostics, (snapshot) => {
|
||||
peerProgress = snapshot.peers;
|
||||
});
|
||||
const unsubscribe = eventHub.onEvent(EVENT_SERVER_STATUS, (status) => {
|
||||
serverInfo = status;
|
||||
});
|
||||
@@ -159,6 +164,7 @@
|
||||
});
|
||||
|
||||
return () => {
|
||||
unsubscribeProgress();
|
||||
unsubscribe();
|
||||
unsubscribeReplicatorStatus();
|
||||
unsubscribeReplicatorProgress();
|
||||
@@ -477,6 +483,14 @@
|
||||
<div class="peer-meta">
|
||||
<span class="badge">{peer.platform}</span>
|
||||
</div>
|
||||
{#if peerProgress.has(peer.peerId)}
|
||||
<div
|
||||
class="peer-progress"
|
||||
title="↑↓: transferred document revisions (seq for older peers); ⏩: compared changes-feed entries"
|
||||
>
|
||||
{peerProgress.get(peer.peerId)?.message}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="peer-actions">
|
||||
{#if isAccepted(peer)}
|
||||
@@ -605,6 +619,12 @@
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.peer-progress {
|
||||
color: var(--text-muted);
|
||||
font-size: var(--font-ui-small);
|
||||
font-variant-numeric: tabular-nums;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.p2p-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in new issue
Block a user