fix(desktop): pass-2 correction C7 — degraded results observable + AppShell composite key

spawn_event_sync returns Result<(), String> so dispatch failure can be captured
by the workspace-apply post-commit section rather than being silently ignored.
The value is always Ok(()) since tauri::async_runtime::spawn is infallible; this
establishes the typed interface for future signaling.

try_regenerate_nest returns Result<(), String> instead of swallowing errors.
All fire-and-forget callers updated to .ok() to explicitly discard the Result.

apply_workspace post-commit:
- try_regenerate_nest moved out of the spawn_blocking closure into the async
  post-commit section so its Result can populate the degraded vec.
- spawn_event_sync Result captured; dispatch failure pushed to degraded.
- Nest failure reported as 'nest context regeneration failed: ...' degradation.

useCommunityInit.ts: post-commit degraded items now emit a toast.warning (8 s)
via sonner so the user sees partial failures. Previously only console.warn.

AppShell.tsx: useManagedAgentRuntimeReconciliation key changed from
String(reinitKey) to `${activeCommunity?.id}-${reinitKey}`. A same-relay
identity swap (new communityId, unchanged reinitKey) now correctly re-triggers
runtime reconciliation. Destructured activeCommunity and reinitKey from
communitiesHook and updated two other call sites for consistency.

dead pub use exports in migration.rs removed (fold, backfill, detach, strip,
materialize — all now accessed only through scoped _in_dir/_at variants).

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
2026-08-03 02:45:35 -04:00
co-authored by Will Pfleger
parent 18c4be359d
commit 372b0fabd9
14 changed files with 40 additions and 27 deletions
+5 -7
View File
@@ -109,6 +109,7 @@ export function AppShell() {
useTauriWindowDrag();
useWebviewScrollBoundaryLock();
const communitiesHook = useCommunities();
const { activeCommunity, reinitKey } = communitiesHook;
const hasCommunityRail = communitiesHook.communities.length > 1;
const addCommunityDialog = useAddCommunityDialogState();
const [isChannelManagementOpen, setIsChannelManagementOpen] =
@@ -123,7 +124,7 @@ export function AppShell() {
const mainInsetRef = React.useRef<HTMLElement>(null);
const location = useLocation();
const queryClient = useQueryClient();
useManagedAgentRuntimeReconciliation(String(communitiesHook.reinitKey)); // re-runs on workspace switch
useManagedAgentRuntimeReconciliation(`${activeCommunity?.id}-${reinitKey}`);
const {
goAgents,
goChannel,
@@ -168,10 +169,7 @@ export function AppShell() {
const { starredChannelIds, starChannel, unstarChannel } = useChannelStars(
identityQuery.data?.pubkey,
);
usePersonaSync(
identityQuery.data?.pubkey,
communitiesHook.activeCommunity?.relayUrl,
);
usePersonaSync(identityQuery.data?.pubkey, activeCommunity?.relayUrl);
useAgentsDataRefresh();
// Chunk F: auto-restart drifted idle agents (per-agent opt-out, default ON).
useAutoRestartPolicy();
@@ -231,8 +229,8 @@ export function AppShell() {
: undefined;
const relayConnectionCard = useSidebarRelayConnectionCard(
channelsErrorMessage,
communitiesHook.activeCommunity?.relayUrl,
`${communitiesHook.activeCommunity?.id ?? "none"}-${communitiesHook.reinitKey}`,
activeCommunity?.relayUrl,
`${activeCommunity?.id ?? "none"}-${reinitKey}`,
);
const memberChannels = React.useMemo(
() => channels.filter((channel) => channel.isMember),
@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { isTauri } from "@tauri-apps/api/core";
import { isMacPlatform } from "@/shared/lib/platform";
import { toast } from "sonner";
import { relayClient } from "@/shared/api/relayClient";
import { resetRateLimitGate } from "@/shared/api/relayRateLimitGate";
@@ -238,13 +239,19 @@ export function useCommunityInit(
return;
}
// Workspace applied. Log any post-commit degradation (informational —
// the workspace IS active; these are best-effort post-commit steps).
// Workspace applied. Surface any post-commit degradation as a
// user-visible warning toast — the workspace IS active, but some
// best-effort post-commit steps failed (nest, event-sync, restore).
if (applyResult.degraded.length > 0) {
const reason = applyResult.degraded.join("; ");
console.warn(
"[useCommunityInit] workspace applied with degradation:",
applyResult.degraded,
);
toast.warning("Workspace applied with partial failures", {
description: reason,
duration: 8000,
});
}
} catch (error) {
// A bad `repos_dir` no longer reaches here — `apply_workspace` treats