Skip to content

Commit 2e4d08f

Browse files
Merge pull request #346 from microsoft/dev
fix: Vite Version update & Show / hide Upload button
2 parents 6e1e66e + dc1e22f commit 2e4d08f

File tree

7 files changed

+1459
-1233
lines changed

7 files changed

+1459
-1233
lines changed

App/frontend-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"ts-node": "^10.9.2",
8989
"tslib": "^2.6.2",
9090
"typescript": "^5.8.2",
91-
"vite": "^6.2.0"
91+
"vite": "^6.2.6"
9292
},
9393
"volta": {
9494
"node": "18.16.0",

App/frontend-app/src/components/documentViewer/documentViewer.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const useStyles = makeStyles({
4141
...shorthands.padding("0px", "0px"),
4242
rowGap: "20px",
4343
},
44+
45+
aiKnowledgeTab:{
46+
height:"calc(100vh - 150px) !important",
47+
overflow:"auto"
48+
}
4449
});
4550

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

8086

@@ -90,6 +96,24 @@ export function DocDialog(
9096
setUrlWithSasToken(undefined);
9197
}
9298
}, [metadata]); // Only run when metadata changes
99+
100+
useEffect(() => {
101+
if (metadata && metadata.fileName.endsWith(".txt")) {
102+
fetch(metadata.document_url)
103+
.then((response) => response.text())
104+
.then((textContent) => {
105+
const blob = new Blob([textContent], { type: "text/plain" });
106+
const objectURL = URL.createObjectURL(blob);
107+
setIframeSrc(objectURL);
108+
109+
// Cleanup the object URL when component unmounts or metadata changes
110+
return () => URL.revokeObjectURL(objectURL);
111+
})
112+
.catch((error) => console.error("Error fetching text file:", error));
113+
} else {
114+
setIframeSrc(metadata?.document_url);
115+
}
116+
}, [metadata]);
93117

94118

95119
const downloadFile = () => {
@@ -236,7 +260,7 @@ export function DocDialog(
236260
<IFrameComponent
237261
className="h-[100%]"
238262
metadata={metadata}
239-
urlWithSasToken={urlWithSasToken}
263+
urlWithSasToken={iframeSrc}
240264
iframeKey={iframeKey}
241265
/>
242266
</div>
@@ -265,14 +289,17 @@ export function DocDialog(
265289
)}
266290

267291
{selectedTab === "AI Knowledge" && (
292+
<div className={`flex h-[150%] w-[200%] justify-between ${styles.aiKnowledgeTab}`}>
268293
<AIKnowledgeTab
269294
metadata={metadata?.keywords ? Object.fromEntries(
270295
Object.entries(metadata.keywords).map(([key, value]) => [
271296
key,
272297
Array.isArray(value) ? value : [value] // Ensure all values are arrays
273298
])
274299
) : {}}
300+
275301
/>
302+
</div>
276303
)}
277304

278305

App/frontend-app/src/components/sidecarCopilot/sidecar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export function SidecarCopilot({
164164
onSourceChange={handleSourceChange}
165165
disabled={disableSources}
166166
selectedDocuments={selectedDocuments}
167+
isSticky={false}
167168
/>
168169

169170
<CopilotProvider>

App/frontend-app/src/pages/home/home.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
5454
const navigate = useNavigate();
5555
const location = useLocation();
5656
const [reset, setReset] = useState(false); // State to trigger reset
57-
57+
const [clearSearchBox, setClearSearchBox] = useState(false);
5858
const [clearAllTriggered, setClearAllTriggered] = useState(false);
5959
const [clearFilters, setClearFilters] = useState(false);
6060
const [resetSearchBox, setResetSearchBox] = useState(false);
@@ -141,15 +141,16 @@ export function Home({ isSearchResultsPage }: HomeProps) {
141141

142142
useEffect(() => {
143143
if (searchBoxRef.current) {
144-
if (resetSearchBox) {
145-
144+
if (resetSearchBox && clearSearchBox) {
146145
searchBoxRef.current.reset();
147146
setResetSearchBox(false); // Reset the trigger
148147
} else {
149-
const urlQuery = searchParams.get("q");
150-
if (urlQuery) {
151-
const decodedQuery = decodeURIComponent(urlQuery);
152-
searchBoxRef.current.setValue(decodedQuery);
148+
if(!clearSearchBox){
149+
const urlQuery = searchParams.get("q");
150+
if (urlQuery) {
151+
const decodedQuery = decodeURIComponent(urlQuery);
152+
searchBoxRef.current.setValue(decodedQuery);
153+
}
153154
}
154155
}
155156
}
@@ -165,15 +166,24 @@ export function Home({ isSearchResultsPage }: HomeProps) {
165166
setSearchParams({}); // Clear all search params when there's no query
166167
}
167168
} else {
168-
const q = searchParams.get("q");
169-
if (q) {
170-
setQuery(decodeURIComponent(q));
169+
if(!clearSearchBox){
170+
const q = searchParams.get("q");
171+
if (q) {
172+
setQuery(decodeURIComponent(q));
173+
}
171174
}
172175
}
173176
}, [isSearchResultsPage, query, searchParams, setSearchParams]);
174177

178+
useEffect(() => {
179+
const q = searchParams.get("q");
180+
if(!q){
181+
setClearSearchBox(false)
182+
}
183+
},[searchParams])
184+
175185
function onSearchChanged(searchValue: string): void {
176-
if (searchValue) {
186+
if (searchValue) {
177187
setTextValue(searchValue);
178188
}
179189
if (searchValue) {
@@ -189,7 +199,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
189199
}
190200
} else {
191201
setSearchResultDocuments([]);
192-
setSearchParams("");
202+
setSearchParams({});
193203
setQuery(searchValue);
194204
}
195205
}
@@ -462,6 +472,7 @@ export function Home({ isSearchResultsPage }: HomeProps) {
462472
setSelectedDocuments([]);
463473
setClearAllTriggered(true); // Set this flag to true
464474
setClearFilters(true);
475+
setClearSearchBox(true);
465476
// Call loadDataAsync after clearing
466477
loadDataAsync();
467478
}, [/* dependencies */]);

App/frontend-app/src/types/searchRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface SearchRequest {
33
searchFacets: SearchFacet[];
44
currentPage: number;
55
incomingFilter: string;
6-
filters?: string[];
6+
filters?: { [key: string]: string };
77
parameters: {
88
scoringProfile: string;
99
inOrderBy: string[];

0 commit comments

Comments
 (0)