mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 20:50:12 +00:00
feat: show P2P diagnostics in the status pane and log
Show expandable relay, peer, and sync observations below Stats and route Diag events to the existing Log Pane without notification or editor-status churn. Retain departed-peer evidence and replay logs recorded before the pane opens. Keep narrow panes usable with wrapping peer controls, readable device names, and larger buttons. Add browser regressions for disclosure, control bounds, button targets, and existing actions.
This commit is contained in:
1 parent
fc5f02ca3b
commit
cf527fbf86
22 files changed
+978
-88
No files matched your search
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html lang="en"><head><meta charset="utf-8"><title>P2P status pane layout fixture</title>
|
||||
<style>
|
||||
:root { --font-ui-small: 12px; --text-muted: #666; --text-normal: #222; --divider-color: #bbb; --size-4-1: 4px; --size-4-2: 8px; --background-secondary: #f4f4f4; --background-tertiary: #ddd; --interactive-normal: #eee; --interactive-hover: #ddd; --background-modifier-success: #bdb; --background-modifier-border: #ddd; --background-modifier-error: #ecc; }
|
||||
@media (prefers-color-scheme: dark) { :root { color-scheme: dark; --text-muted: #aaa; --text-normal: #ddd; --divider-color: #555; --background-secondary: #262626; --background-tertiary: #444; --interactive-normal: #333; --interactive-hover: #444; --background-modifier-success: #253f25; --background-modifier-border: #444; --background-modifier-error: #522; } }
|
||||
body { margin: 8px; font: 16px sans-serif; color: var(--text-normal); }
|
||||
#app { margin: 16px; }
|
||||
button, select { font: inherit; color: var(--text-normal); background: var(--interactive-normal); }
|
||||
button { padding: 4px 12px; white-space: nowrap; }
|
||||
</style></head>
|
||||
<body><div id="app"></div><output id="action"></output><script type="module" src="./main.ts"></script></body></html>
|
||||
@@ -0,0 +1,67 @@
|
||||
import { mount } from "svelte";
|
||||
import Pane from "../../../src/features/P2PSync/P2PReplicator/P2PServerStatusPane.svelte";
|
||||
import { eventHub } from "../../../src/common/events";
|
||||
import {
|
||||
EVENT_SERVER_STATUS,
|
||||
EVENT_P2P_REPLICATOR_STATUS,
|
||||
} from "@vrtmrz/livesync-commonlib/compat/replication/trystero/TrysteroReplicatorP2PServer";
|
||||
import { setGlobalLogFunction } from "octagonal-wheels/common/logger";
|
||||
|
||||
setGlobalLogFunction(() => undefined);
|
||||
const settings = { P2P_useDiagRTC: true, P2P_roomID: "fixture-room", remoteConfigurations: {} };
|
||||
const knownAdvertisements = [
|
||||
{ peerId: "permanent-peer", name: "Phone", platform: "mobile", isAccepted: true },
|
||||
{
|
||||
peerId: "session-peer",
|
||||
name: "LongDeviceNameWithoutWordBreaks".repeat(4),
|
||||
platform: "desktop",
|
||||
isTemporaryAccepted: true,
|
||||
},
|
||||
{ peerId: "new-peer", name: "New device", platform: "mobile" },
|
||||
{ peerId: "denied-peer", name: "Denied device", platform: "mobile", isTemporaryAccepted: false },
|
||||
];
|
||||
if (new URLSearchParams(location.search).has("preview")) {
|
||||
knownAdvertisements.splice(1, 1);
|
||||
knownAdvertisements.splice(2, 1);
|
||||
knownAdvertisements[0].name = "Android phone";
|
||||
knownAdvertisements[1].name = "MacBook Pro (Living room)";
|
||||
}
|
||||
const record = (action: unknown) => {
|
||||
document.querySelector("#action")!.textContent = JSON.stringify(action);
|
||||
};
|
||||
const p2p = {
|
||||
transportLifecycle: { connect: async () => undefined, disconnect: async () => undefined },
|
||||
changeRelay: { enableBroadcastChanges() {}, disableBroadcastChanges() {} },
|
||||
peerAdmission: {
|
||||
makeDecision: async (decision: unknown) => record(decision),
|
||||
revokeDecision: async (decision: unknown) => record(decision),
|
||||
},
|
||||
targetedTransfer: { synchroniseWithPeer: async (peerId: string) => record({ sync: peerId }) },
|
||||
diagnostics: {
|
||||
getDiagnosticSnapshot: () => ({ peer: { category: "peer", code: "peer-left", timestamp: 1_700_000_000_000 } }),
|
||||
onDiagnosticEvent: () => () => undefined,
|
||||
requestStatus: () => {
|
||||
eventHub.emitEvent(EVENT_SERVER_STATUS, {
|
||||
isConnected: true,
|
||||
knownAdvertisements,
|
||||
serverPeerId: "fixture-self",
|
||||
roomId: "fixture-room",
|
||||
diag: {
|
||||
totalNewConnections: 4,
|
||||
totalSuccessfulConnections: 2,
|
||||
totalFailedConnections: 1,
|
||||
totalClosedConnections: 1,
|
||||
details: {},
|
||||
},
|
||||
} as never);
|
||||
eventHub.emitEvent(EVENT_P2P_REPLICATOR_STATUS, {
|
||||
replicatingFrom: [],
|
||||
replicatingTo: [],
|
||||
watchingPeers: [],
|
||||
isBroadcasting: false,
|
||||
} as never);
|
||||
},
|
||||
},
|
||||
};
|
||||
const core = { services: { setting: { currentSettings: () => settings }, API: { showWindow: async () => undefined } } };
|
||||
mount(Pane, { target: document.querySelector("#app")!, props: { p2p: p2p as never, core: core as never } });
|
||||
Reference in new issue
Block a user