fix(app): avoid infinite render loop in FilePanel zustand selector

The selector returned a freshly constructed authority object each call, so
useSyncExternalStore saw a new reference every render and force-rerendered,
producing a maximum update depth crash. Select the specific workspace
descriptor (stable reference) and derive the authority via useMemo.
This commit is contained in:
Mohamed Boudra
2026-04-16 20:18:56 +07:00
parent 213767e3d5
commit 827092a246

View File

@@ -1,3 +1,4 @@
import { useMemo } from "react";
import { Text, View } from "react-native";
import { FileText } from "lucide-react-native";
import invariant from "tiny-invariant";
@@ -20,12 +21,10 @@ function useFilePanelDescriptor(target: { kind: "file"; path: string }) {
function FilePanel() {
const { serverId, workspaceId, target } = usePaneContext();
const authority = useSessionStore((state) =>
resolveWorkspaceExecutionAuthority({
workspaces: state.sessions[serverId]?.workspaces,
workspaceId,
}),
const workspace = useSessionStore(
(state) => state.sessions[serverId]?.workspaces.get(workspaceId) ?? null,
);
const authority = useMemo(() => resolveWorkspaceExecutionAuthority({ workspace }), [workspace]);
invariant(target.kind === "file", "FilePanel requires file target");
if (!authority) {
return (