feat(console-web): synchronize Host state across tabs

- separate global Host state from tab-local shell and Page state
- replicate control-plane snapshots through a versioned BroadcastChannel
- handshake new tabs without publishing empty startup state
- reject self, stale, and malformed cross-tab messages
- suppress broadcast echoes while applying remote snapshots
- publish API snapshots and connection state atomically
- keep Page state private and update only mounted iframe documents
- test initial synchronization and protocol rejection paths
This commit is contained in:
Maofeng
2026-07-30 09:57:06 +08:00
parent 93f4a505ba
commit 88a7fba0b0
4 changed files with 338 additions and 11 deletions
+13 -4
View File
@@ -16,18 +16,27 @@ export type RuntimeAction = "start" | "stop" | "restart";
export type ServiceAction = "start" | "stop" | "restart";
export type PageLifecyclePhase = "activate" | "deactivate" | "dispose";
export type HostSharedState = {
// This is a serializable snapshot, never a Solid signal crossing realms.
view: View;
/**
* Control-plane state shared unconditionally between same-origin Host tabs.
*
* Navigation, search, dialogs, notifications and iframe caches are excluded:
* those values describe one browser tab rather than the Wasmeld runtime.
*/
export type HostGlobalState = {
snapshot: BackendSnapshot | null;
connection: ConnectionState;
query: string;
apiBase: string;
runtimeAction: RuntimeAction | null;
serviceAction: string | null;
deploymentAction: string | null;
};
export type HostSharedState = HostGlobalState & {
// This is a serializable snapshot, never a Solid signal crossing realms.
view: View;
query: string;
};
export type PageCommand =
| { type: "refresh" }
| { type: "navigate"; view: View }