Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion App/frontend-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.8.2",
"vite": "^6.2.0"
"vite": "^6.2.6"
},
"volta": {
"node": "18.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const useStyles = makeStyles({
...shorthands.padding("0px", "0px"),
rowGap: "20px",
},

aiKnowledgeTab:{
height:"calc(100vh - 150px) !important",
overflow:"auto"
}
});

interface DocDialogProps {
Expand Down Expand Up @@ -75,6 +80,7 @@ export function DocDialog(
const [iframeKey, setIframeKey] = useState(0);
const [isExpanded, setIsExpanded] = useState(false);
const [clearedChatFlag, setClearChatFlag] = useState(clearChatFlag);
const [iframeSrc, setIframeSrc] = useState<string | undefined>(undefined);
// const [aiKnowledgeMetadata, setAIKnowledgeMetadata] = useState<Document | null>(null);


Expand All @@ -90,6 +96,24 @@ export function DocDialog(
setUrlWithSasToken(undefined);
}
}, [metadata]); // Only run when metadata changes

useEffect(() => {
if (metadata && metadata.fileName.endsWith(".txt")) {
fetch(metadata.document_url)
.then((response) => response.text())
.then((textContent) => {
const blob = new Blob([textContent], { type: "text/plain" });
const objectURL = URL.createObjectURL(blob);
setIframeSrc(objectURL);

// Cleanup the object URL when component unmounts or metadata changes
return () => URL.revokeObjectURL(objectURL);
})
.catch((error) => console.error("Error fetching text file:", error));
} else {
setIframeSrc(metadata?.document_url);
}
}, [metadata]);


const downloadFile = () => {
Expand Down Expand Up @@ -236,7 +260,7 @@ export function DocDialog(
<IFrameComponent
className="h-[100%]"
metadata={metadata}
urlWithSasToken={urlWithSasToken}
urlWithSasToken={iframeSrc}
iframeKey={iframeKey}
/>
</div>
Expand Down Expand Up @@ -265,14 +289,17 @@ export function DocDialog(
)}

{selectedTab === "AI Knowledge" && (
<div className={`flex h-[150%] w-[200%] justify-between ${styles.aiKnowledgeTab}`}>
<AIKnowledgeTab
metadata={metadata?.keywords ? Object.fromEntries(
Object.entries(metadata.keywords).map(([key, value]) => [
key,
Array.isArray(value) ? value : [value] // Ensure all values are arrays
])
) : {}}

/>
</div>
)}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function SidecarCopilot({
onSourceChange={handleSourceChange}
disabled={disableSources}
selectedDocuments={selectedDocuments}
isSticky={false}
/>

<CopilotProvider>
Expand Down
35 changes: 23 additions & 12 deletions App/frontend-app/src/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
const navigate = useNavigate();
const location = useLocation();
const [reset, setReset] = useState(false); // State to trigger reset

const [clearSearchBox, setClearSearchBox] = useState(false);
const [clearAllTriggered, setClearAllTriggered] = useState(false);
const [clearFilters, setClearFilters] = useState(false);
const [resetSearchBox, setResetSearchBox] = useState(false);
Expand Down Expand Up @@ -141,15 +141,16 @@ export function Home({ isSearchResultsPage }: HomeProps) {

useEffect(() => {
if (searchBoxRef.current) {
if (resetSearchBox) {

if (resetSearchBox && clearSearchBox) {
searchBoxRef.current.reset();
setResetSearchBox(false); // Reset the trigger
} else {
const urlQuery = searchParams.get("q");
if (urlQuery) {
const decodedQuery = decodeURIComponent(urlQuery);
searchBoxRef.current.setValue(decodedQuery);
if(!clearSearchBox){
const urlQuery = searchParams.get("q");
if (urlQuery) {
const decodedQuery = decodeURIComponent(urlQuery);
searchBoxRef.current.setValue(decodedQuery);
}
}
}
}
Expand All @@ -165,15 +166,24 @@ export function Home({ isSearchResultsPage }: HomeProps) {
setSearchParams({}); // Clear all search params when there's no query
}
} else {
const q = searchParams.get("q");
if (q) {
setQuery(decodeURIComponent(q));
if(!clearSearchBox){
const q = searchParams.get("q");
if (q) {
setQuery(decodeURIComponent(q));
}
}
}
}, [isSearchResultsPage, query, searchParams, setSearchParams]);

useEffect(() => {
const q = searchParams.get("q");
if(!q){
setClearSearchBox(false)
}
},[searchParams])

function onSearchChanged(searchValue: string): void {
if (searchValue) {
if (searchValue) {
setTextValue(searchValue);
}
if (searchValue) {
Expand All @@ -189,7 +199,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
}
} else {
setSearchResultDocuments([]);
setSearchParams("");
setSearchParams({});
setQuery(searchValue);
}
}
Expand Down Expand Up @@ -462,6 +472,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
setSelectedDocuments([]);
setClearAllTriggered(true); // Set this flag to true
setClearFilters(true);
setClearSearchBox(true);
// Call loadDataAsync after clearing
loadDataAsync();
}, [/* dependencies */]);
Expand Down
2 changes: 1 addition & 1 deletion App/frontend-app/src/types/searchRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface SearchRequest {
searchFacets: SearchFacet[];
currentPage: number;
incomingFilter: string;
filters?: string[];
filters?: { [key: string]: string };
parameters: {
scoringProfile: string;
inOrderBy: string[];
Expand Down
Loading