mirror of
https://github.com/block/buzz.git
synced 2026-11-25 10:42:26 +00:00
## Summary
Old Buzz desktop clients now check a community’s public requirement
before each connection. An explicit `requires_nip_fi: true` shows an
upgrade screen with a fixed https://buzz.xyz download action and manual
fallback. Missing or false requirements, and failed discovery, preserve
normal connection behavior.
Retry, community navigation and address editing preserve keys and saved
communities. Changing an address cancels the old onboarding transaction
and fences pending profile checks. Native discovery sends no
credentials, follows no redirects, and limits requests to five seconds
and 256 KiB. Wire fixtures are exported from main `6b8a72e835` with
reproducible provenance.
### Related issue
[BUZZ-517](https://linear.app/squareup/issue/BUZZ-517/v0-clients-show-an-upgrade-screen-for-communities-requiring-nip-fi).
Related: [#8984](https://github.com/block/buzz/pull/8984) contains
mobile parser preparation;
[#8920](https://github.com/block/buzz/pull/8920) repairs relay rejection
messages.
### Rollout
There is no client flag. The upgrade screen appears only when the relay
advertises `requires_nip_fi: true`. Public auto-update delivery requires
a desktop release containing this change and promotion to the [OSS
auto-update
feed](aa749a862e/RELEASING.md (promote-an-oss-desktop-release-to-auto-update)).
In Shadow mode, requiring a community activates the screen; making it
optional restores normal connections. Global Enforce requires every
community regardless of that setting. Rollback must restore an effective
non-required policy. The optional and required outcomes are demonstrated
by Brad’s two manual cases below.
### Testing
At `71689b4708`, Honor’s isolated browser journeys passed 3/3 with zero
retries and verified served assets, including the fixed
`https://buzz.xyz` opener and manual fallback. McKeon independently
built and passed the same three journeys at the previous head
`8caa25260b` with the repository command: `CI=1 pnpm --dir desktop
build:e2e`, then `CI=1 pnpm --dir desktop exec playwright test
relay-entry-guidance.spec.ts --project=smoke`. Native IPC was mocked.
Brad [tested the running pre-rebase app
locally](https://github.com/block/buzz/pull/9033#issuecomment-6662960875):
an optional bb-public community in Shadow connected without a message;
required bb-block staging showed the upgrade message. These results
apply to that running app, not the rebased head.
Before:

After:

Generated with Codex
---------
Signed-off-by: Brad Seiler <seiler@squareup.com>
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
79 lines
3.1 KiB
TypeScript
79 lines
3.1 KiB
TypeScript
import * as React from "react";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
|
|
import { startBootWarm } from "@/features/agents/acpRuntimesQuery";
|
|
import { setDesktopAppBadge } from "@/features/notifications/lib/desktop";
|
|
import { useForegroundQueryRefresh } from "@/features/workflows/hooks";
|
|
import { useRelayResumeTriggers } from "@/shared/api/useRelayResumeTriggers";
|
|
|
|
type AppShellLifecycleEffectsOptions = {
|
|
desktopBadgeEnabled: boolean;
|
|
homeBadgeCountExcludingHighPriority: number;
|
|
topLevelUnreadChannelIds: ReadonlySet<string>;
|
|
unreadChannelNotificationCount: number;
|
|
};
|
|
|
|
export function useAppShellLifecycleEffects({
|
|
desktopBadgeEnabled,
|
|
homeBadgeCountExcludingHighPriority,
|
|
topLevelUnreadChannelIds,
|
|
unreadChannelNotificationCount,
|
|
}: AppShellLifecycleEffectsOptions) {
|
|
// Event-driven reconnect: network online / focus / visibility short-circuit
|
|
// the backoff timer when the relay session is degraded (CMD+R gap G1).
|
|
useRelayResumeTriggers();
|
|
useForegroundQueryRefresh();
|
|
|
|
// Warm the ACP runtime catalog once at app launch. The shared runtime-catalog
|
|
// cache is in-memory only, so it starts cold every boot; the cheap discovery
|
|
// path reports every harness as "(not installed)" until a forced pass warms
|
|
// it. The create/edit picker and Agents > Agent defaults surfaces read that
|
|
// cheap path, so without this warm they render all-missing (and block agent
|
|
// save) until the user visits Settings > Agents — the accidental workaround.
|
|
// `startBootWarm` drives the module-level boot-warm gate (once per launch, so
|
|
// this remounting effect never re-fires the probe) which makes those cheap
|
|
// surfaces show loading/retryable-error instead of blessing the cold catalog,
|
|
// and swallows the probe's own errors so a failure leaves the last good
|
|
// catalog in place without an unhandled rejection.
|
|
const queryClient = useQueryClient();
|
|
React.useEffect(() => {
|
|
void startBootWarm(queryClient);
|
|
}, [queryClient]);
|
|
|
|
// Prevent webview file:/// navigation on file drop outside the composer.
|
|
// Scoped to file drags only (text drag-and-drop into inputs still works).
|
|
// Composer's onDrop fires first (React synthetic before window bubble).
|
|
React.useEffect(() => {
|
|
function preventNavigation(e: DragEvent) {
|
|
if (e.dataTransfer?.types.includes("Files")) {
|
|
e.preventDefault();
|
|
}
|
|
}
|
|
window.addEventListener("dragover", preventNavigation);
|
|
window.addEventListener("drop", preventNavigation);
|
|
return () => {
|
|
window.removeEventListener("dragover", preventNavigation);
|
|
window.removeEventListener("drop", preventNavigation);
|
|
};
|
|
}, []);
|
|
|
|
React.useEffect(() => {
|
|
if (!desktopBadgeEnabled) {
|
|
return;
|
|
}
|
|
|
|
const count =
|
|
unreadChannelNotificationCount + homeBadgeCountExcludingHighPriority;
|
|
void setDesktopAppBadge(
|
|
count
|
|
? { kind: "count", count }
|
|
: { kind: topLevelUnreadChannelIds.size ? "dot" : "none" },
|
|
);
|
|
}, [
|
|
desktopBadgeEnabled,
|
|
homeBadgeCountExcludingHighPriority,
|
|
topLevelUnreadChannelIds,
|
|
unreadChannelNotificationCount,
|
|
]);
|
|
}
|