mirror of
https://github.com/block/buzz.git
synced 2026-11-25 02:31:36 +00:00
Adds a 'serverless' workspace mode that points the desktop app at any generic public Nostr relay (e.g. wss://relay.damus.io) with zero Sprout server infrastructure — no Postgres, no HTTP /query|/events bridge, no NIP-98 auth. Reuses Sprout's native event kinds (39000 channel metadata, 39002 membership, kind 9 messages, h-tag scoping); 'serverless' is purely a transport + auth concern, so the server-mode path is untouched. Transport: reads/writes go over plain WebSocket (REQ/EOSE, EVENT/OK) instead of the HTTP bridge; NIP-42 AUTH is answered only if the relay challenges. Desktop backend: - AppState.serverless flag + is_serverless(); apply_workspace gains a flag - ws_relay.rs: query_relay_ws / submit_event_ws / publish_signed_event_ws - relay.rs: query_relay/submit_event + agent profile sync branch to WS - events.rs: build_channel_metadata_serverless (39000) + members (39002) - create_channel/open_dm publish those events directly (DM ids = UUIDv5 over sorted participants so both sides converge without a server) - managed agents inherit SPROUT_SERVERLESS into the ACP subprocess env Agents (full support, not a follow-up): - sprout-acp: RestClient + HarnessRelay gain serverless mode; query/submit use plain WS, NIP-42 handshake skipped on (re)connect; SPROUT_SERVERLESS env/arg - sprout-cli: SproutClient serverless WS query/submit; --serverless flag, to_ws_url helper, NetworkMsg error variant - npub respond-to permissions are in-process and work unchanged Frontend: - Workspace.mode + workspaceMode()/isServerlessWorkspace() helpers - relayClient.setServerless() skips the AUTH-wait on connect; late challenges still answered so writes succeed on relays that require auth - ServerlessContext/useIsServerless() hides search, pulse, projects, workflows - Serverless toggle in the Add Workspace dialog and Welcome screen Docs: docs/SPROUT_LITE_MODE.md updated with the implementation + testing steps.
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
|
|
import { TopbarSearch } from "@/features/search/ui/TopbarSearch";
|
|
import { useIsServerless } from "@/features/workspaces/ServerlessContext";
|
|
import type { Channel, SearchHit } from "@/shared/api/types";
|
|
import { Button } from "@/shared/ui/button";
|
|
import { SidebarTrigger, useSidebar } from "@/shared/ui/sidebar";
|
|
|
|
type AppTopChromeProps = {
|
|
canGoBack: boolean;
|
|
canGoForward: boolean;
|
|
channels: Channel[];
|
|
currentPubkey?: string;
|
|
onGoBack: () => void;
|
|
onGoForward: () => void;
|
|
onOpenChannel: (channelId: string) => void;
|
|
onOpenResult: (hit: SearchHit) => void;
|
|
searchFocusRequest: number;
|
|
};
|
|
|
|
function GlobalTopDivider() {
|
|
const { state } = useSidebar();
|
|
|
|
return (
|
|
<div
|
|
aria-hidden="true"
|
|
className="pointer-events-none fixed right-0 top-10 z-50 h-px bg-border/35"
|
|
style={{ left: state === "expanded" ? "var(--sidebar-width)" : 0 }}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function AppTopChrome({
|
|
canGoBack,
|
|
canGoForward,
|
|
channels,
|
|
currentPubkey,
|
|
onGoBack,
|
|
onGoForward,
|
|
onOpenChannel,
|
|
onOpenResult,
|
|
searchFocusRequest,
|
|
}: AppTopChromeProps) {
|
|
// Search is Typesense-backed on the Sprout relay; a generic relay can't
|
|
// serve it. Hide the search bar in serverless mode.
|
|
const serverless = useIsServerless();
|
|
return (
|
|
<>
|
|
<div
|
|
aria-hidden="true"
|
|
className="fixed inset-x-0 top-0 z-20 h-10 cursor-default select-none"
|
|
data-tauri-drag-region
|
|
/>
|
|
<GlobalTopDivider />
|
|
<div className="fixed left-[80px] top-[9px] z-[80] flex items-center gap-0.5">
|
|
<SidebarTrigger className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground" />
|
|
<Button
|
|
aria-label="Go back"
|
|
className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground"
|
|
data-testid="global-back"
|
|
disabled={!canGoBack}
|
|
onClick={onGoBack}
|
|
size="icon"
|
|
variant="ghost"
|
|
>
|
|
<ChevronLeft className="h-3 w-3" />
|
|
</Button>
|
|
<Button
|
|
aria-label="Go forward"
|
|
className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground"
|
|
data-testid="global-forward"
|
|
disabled={!canGoForward}
|
|
onClick={onGoForward}
|
|
size="icon"
|
|
variant="ghost"
|
|
>
|
|
<ChevronRight className="h-3 w-3" />
|
|
</Button>
|
|
</div>
|
|
{!serverless && (
|
|
<TopbarSearch
|
|
channels={channels}
|
|
className="fixed left-1/2 top-[7px] z-[80] hidden w-[300px] max-w-[34vw] -translate-x-1/2 md:block lg:w-[360px] lg:max-w-[38vw] xl:w-[420px] xl:max-w-[42vw] 2xl:w-[480px] 2xl:max-w-[44vw]"
|
|
currentPubkey={currentPubkey}
|
|
focusRequest={searchFocusRequest}
|
|
onOpenChannel={onOpenChannel}
|
|
onOpenResult={onOpenResult}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|