add app context and KB grounding to autocomplete suggestions

This commit is contained in:
CREDO23 2026-04-03 21:34:01 +02:00
parent 080acf5e0a
commit 960b8fc012
7 changed files with 150 additions and 9 deletions

View file

@ -46,7 +46,7 @@ export default function SuggestionPage() {
}, [error]);
const fetchSuggestion = useCallback(
async (screenshot: string, searchSpaceId: string) => {
async (screenshot: string, searchSpaceId: string, appName?: string, windowTitle?: string) => {
abortRef.current?.abort();
const controller = new AbortController();
abortRef.current = controller;
@ -77,6 +77,8 @@ export default function SuggestionPage() {
body: JSON.stringify({
screenshot,
search_space_id: parseInt(searchSpaceId, 10),
app_name: appName || "",
window_title: windowTitle || "",
}),
signal: controller.signal,
},
@ -142,7 +144,7 @@ export default function SuggestionPage() {
const cleanup = window.electronAPI.onAutocompleteContext((data) => {
const searchSpaceId = data.searchSpaceId || "1";
if (data.screenshot) {
fetchSuggestion(data.screenshot, searchSpaceId);
fetchSuggestion(data.screenshot, searchSpaceId, data.appName, data.windowTitle);
}
});

View file

@ -23,7 +23,7 @@ interface ElectronAPI {
requestScreenRecording: () => Promise<void>;
restartApp: () => Promise<void>;
// Autocomplete
onAutocompleteContext: (callback: (data: { screenshot: string; searchSpaceId?: string }) => void) => () => void;
onAutocompleteContext: (callback: (data: { screenshot: string; searchSpaceId?: string; appName?: string; windowTitle?: string }) => void) => () => void;
acceptSuggestion: (text: string) => Promise<void>;
dismissSuggestion: () => Promise<void>;
setAutocompleteEnabled: (enabled: boolean) => Promise<void>;