MCPcopy Create free account
hub / github.com/block/buzz / handleMockCommand

Function handleMockCommand

desktop/src/testing/e2eBridge.ts:7858–8735  ·  view source on GitHub ↗
(command: string, payload: unknown)

Source from the content-addressed store, hash-verified

7856 deviceName: state === "running" ? "Mock desktop" : null,
7857 });
7858 const handleMockCommand = async (command: string, payload: unknown) => {
7859 const activeConfig = getConfig();
7860 const identity = getActiveIdentity(activeConfig);
7861 window.__BUZZ_E2E_COMMANDS__?.push(command);
7862 const loggedPayload = (() => {
7863 try {
7864 return JSON.parse(JSON.stringify(payload ?? null));
7865 } catch {
7866 return null;
7867 }
7868 })();
7869 window.__BUZZ_E2E_COMMAND_PAYLOADS__?.push({
7870 command,
7871 payload: loggedPayload,
7872 });
7873 window.__BUZZ_E2E_COMMAND_LOG__?.push({ command, payload });
7874
7875 switch (command) {
7876 case "mesh_availability":
7877 return {
7878 capable: true,
7879 admitted: mockMeshState.admitted,
7880 available: mockMeshState.admitted,
7881 reason: mockMeshState.admitted ? null : mockMeshState.denyReason,
7882 models: mockMeshState.models,
7883 serveTargets: mockMeshState.models.map((model) => ({
7884 modelId: model.id,
7885 modelName: model.name,
7886 endpointAddr: "mock-endpoint-addr",
7887 nodeName: "Mock desktop",
7888 capacity: { vramGb: null },
7889 reporterPubkey:
7890 activeConfig?.mock?.meshReporterPubkey ??
7891 identity?.pubkey ??
7892 DEFAULT_MOCK_IDENTITY.pubkey,
7893 endpointId: "mock-endpoint-id",
7894 deviceId: "mock-endpoint-id",
7895 deviceName: "Mock desktop",
7896 })),
7897 };
7898 case "mesh_installed_models":
7899 return mockMeshState.models;
7900 case "mesh_node_status":
7901 return meshNodeStatus(mockMeshState.nodeState, mockMeshState.nodeMode);
7902 case "mesh_start_node": {
7903 const req = (
7904 payload as { request?: { mode?: "serve" | "client" } } | null
7905 )?.request;
7906 mockMeshState.nodeState = "running";
7907 mockMeshState.nodeMode = req?.mode ?? "serve";
7908 return meshNodeStatus(mockMeshState.nodeState, mockMeshState.nodeMode);
7909 }
7910 case "mesh_stop_node":
7911 mockMeshState.nodeState = "off";
7912 mockMeshState.nodeMode = null;
7913 return meshNodeStatus("off", null);
7914 case "mesh_ensure_client_node":
7915 // The invariant under test: membership is the only factor. A

Callers 1

Calls 15

getConfigFunction · 0.85
getActiveIdentityFunction · 0.85
importMockIdentityFunction · 0.85
handleGetProfileFunction · 0.85
handleUpdateProfileFunction · 0.85
handleGetUserProfileFunction · 0.85
handleGetUsersBatchFunction · 0.85
handleGetUserNotesFunction · 0.85
handleGetGlobalNotesFunction · 0.85
handleGetNotesTimelineFunction · 0.85
handleGetNoteFunction · 0.85
handleGetNoteReactionsFunction · 0.85

Tested by

no test coverage detected