From 9c376e7e22fddce7fd5dc7955680bb7632275bdf Mon Sep 17 00:00:00 2001 From: Keerthan K <79328813+keerthnn@users.noreply.github.com> Date: Thu, 24 Sep 2026 14:26:47 +0530 Subject: [PATCH] snify dialog width increased. Fix for manual reloading in module description --- src/components/ReferenceSuggestionDialog.tsx | 5 ++-- src/components/SymbolicLinkPreview.tsx | 7 +++-- .../ModuleDefinitionsSection.tsx | 2 +- .../ModuleStatementsSection.tsx | 2 +- .../useModuleSniffyFlow.ts | 28 ++++++++++++++++++- .../useModuleStatementSemantics.ts | 27 +++++++++++++++++- src/hooks/useSniffyReferenceSuggestions.ts | 10 +++---- 7 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/components/ReferenceSuggestionDialog.tsx b/src/components/ReferenceSuggestionDialog.tsx index 00681db..caf289c 100644 --- a/src/components/ReferenceSuggestionDialog.tsx +++ b/src/components/ReferenceSuggestionDialog.tsx @@ -29,7 +29,7 @@ import { RenderSymbolicUri } from "./RenderUri"; import { SymbolicLinkPreview } from "./SymbolicLinkPreview"; const SNIFFY_REVIEW_DIALOG_HEIGHT = "90dvh"; -const SNIFFY_REVIEW_DIALOG_WIDTH = "50vw"; +const SNIFFY_REVIEW_DIALOG_WIDTH = "75vw"; type Props = { opened: boolean; @@ -230,10 +230,11 @@ export function ReferenceSuggestionDialog({ showRightLabel={false} /> - + diff --git a/src/components/SymbolicLinkPreview.tsx b/src/components/SymbolicLinkPreview.tsx index 472303d..37161c1 100644 --- a/src/components/SymbolicLinkPreview.tsx +++ b/src/components/SymbolicLinkPreview.tsx @@ -8,12 +8,15 @@ type SymbolicLinkPreviewProps = { uri: string; label?: string; compact?: boolean; + /** Let FloDown symref hover cards extend outside the preview box (e.g. sn-ify dialog). */ + allowHoverOverflow?: boolean; }; export function SymbolicLinkPreview({ uri, label, compact = false, + allowHoverOverflow = false, }: SymbolicLinkPreviewProps) { const text = (() => { if (label?.trim()) return label.trim(); @@ -57,8 +60,8 @@ export function SymbolicLinkPreview({ sniffyFlow.setSuggestOpen(false)} + onClose={sniffyFlow.closeSuggest} floDownBlockId={sniffyFlow.activeFloDownBlockId ?? ""} floDownBlockStatement={sniffyFlow.activeFloDownBlockStatement} declaredSymbolsInfo={sniffyFlow.activeDeclaredSymbolsInfo} diff --git a/src/components/module-descriptions/ModuleStatementsSection.tsx b/src/components/module-descriptions/ModuleStatementsSection.tsx index f54725a..e3b4a71 100644 --- a/src/components/module-descriptions/ModuleStatementsSection.tsx +++ b/src/components/module-descriptions/ModuleStatementsSection.tsx @@ -378,7 +378,7 @@ export function ModuleStatementsSection({ sniffyFlow.setSuggestOpen(false)} + onClose={sniffyFlow.closeSuggest} floDownBlockId={sniffyFlow.activeFloDownBlockId ?? ""} floDownBlockStatement={sniffyFlow.activeFloDownBlockStatement} declaredSymbolsInfo={sniffyFlow.activeDeclaredSymbolsInfo} diff --git a/src/hooks/module-descriptions/useModuleSniffyFlow.ts b/src/hooks/module-descriptions/useModuleSniffyFlow.ts index a4da6a3..bb64fcd 100644 --- a/src/hooks/module-descriptions/useModuleSniffyFlow.ts +++ b/src/hooks/module-descriptions/useModuleSniffyFlow.ts @@ -6,6 +6,7 @@ import { moduleDefinitionsToExtractedItems, type ModuleDefinitionBlock, } from "@/lib/moduleDefinitionExtracts"; +import { useRef } from "react"; type SniffyCatalog = Parameters< typeof useSniffyReferenceSuggestions @@ -26,12 +27,17 @@ export function useModuleSniffyFlow({ staticCatalogError: Error | null; retryStaticCatalog: () => Promise; }) { - return useSniffyReferenceSuggestions({ + const pendingPageRefreshRef = useRef(false); + + const sniffyFlow = useSniffyReferenceSuggestions({ floDownBlocks: extracts, catalog: sniffyCatalog, catalogLoading: staticCatalogLoading, catalogError: staticCatalogError, retryCatalog: retryStaticCatalog, + onSessionMutated: () => { + pendingPageRefreshRef.current = true; + }, invalidate: () => queryClient.invalidateQueries({ queryKey: ["module-description", moduleId], @@ -44,4 +50,24 @@ export function useModuleSniffyFlow({ return moduleDefinitionsToExtractedItems(blocks); }, }); + + async function handleRecomputeReferences(floDownBlockId: string) { + pendingPageRefreshRef.current = false; + await sniffyFlow.handleRecomputeReferences(floDownBlockId); + } + + function closeSuggest() { + sniffyFlow.setSuggestOpen(false); + if (!pendingPageRefreshRef.current) return; + pendingPageRefreshRef.current = false; + void queryClient.invalidateQueries({ + queryKey: ["module-description", moduleId], + }); + } + + return { + ...sniffyFlow, + handleRecomputeReferences, + closeSuggest, + }; } diff --git a/src/hooks/module-descriptions/useModuleStatementSemantics.ts b/src/hooks/module-descriptions/useModuleStatementSemantics.ts index 1d1000d..3f3d2d7 100644 --- a/src/hooks/module-descriptions/useModuleStatementSemantics.ts +++ b/src/hooks/module-descriptions/useModuleStatementSemantics.ts @@ -265,12 +265,17 @@ export function useModuleStatementSniffyFlow({ staticCatalogError: Error | null; retryStaticCatalog: () => Promise; }) { - return useSniffyReferenceSuggestions({ + const pendingPageRefreshRef = useRef(false); + + const sniffyFlow = useSniffyReferenceSuggestions({ floDownBlocks: extracts, catalog: sniffyCatalog, catalogLoading: staticCatalogLoading, catalogError: staticCatalogError, retryCatalog: retryStaticCatalog, + onSessionMutated: () => { + pendingPageRefreshRef.current = true; + }, invalidate: () => queryClient.invalidateQueries({ queryKey: ["module-description", moduleId], @@ -304,4 +309,24 @@ export function useModuleStatementSniffyFlow({ }); }, }); + + async function handleRecomputeReferences(floDownBlockId: string) { + pendingPageRefreshRef.current = false; + await sniffyFlow.handleRecomputeReferences(floDownBlockId); + } + + function closeSuggest() { + sniffyFlow.setSuggestOpen(false); + if (!pendingPageRefreshRef.current) return; + pendingPageRefreshRef.current = false; + void queryClient.invalidateQueries({ + queryKey: ["module-description", moduleId], + }); + } + + return { + ...sniffyFlow, + handleRecomputeReferences, + closeSuggest, + }; } diff --git a/src/hooks/useSniffyReferenceSuggestions.ts b/src/hooks/useSniffyReferenceSuggestions.ts index 5529d96..5d536ec 100644 --- a/src/hooks/useSniffyReferenceSuggestions.ts +++ b/src/hooks/useSniffyReferenceSuggestions.ts @@ -27,6 +27,7 @@ type UseSniffyReferenceSuggestionsParams = { selection: { text: string; startOffset: number; endOffset: number }; symRef: UnifiedSymbolicReference; }) => Promise; + onSessionMutated?: () => void; }; export function useSniffyReferenceSuggestions({ @@ -38,6 +39,7 @@ export function useSniffyReferenceSuggestions({ invalidate, refetchFloDownBlocks, applySymbolicRef, + onSessionMutated, }: UseSniffyReferenceSuggestionsParams) { const [suggestOpen, setSuggestOpen] = useState(false); const [suggestLoading, setSuggestLoading] = useState(false); @@ -172,12 +174,8 @@ export function useSniffyReferenceSuggestions({ }); } - setSuggestLoading(true); - try { - await reloadSniffySession(activeFloDownBlockId); - } finally { - setSuggestLoading(false); - } + await reloadSniffySession(activeFloDownBlockId); + onSessionMutated?.(); } return {