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