From f0c97518797ca1139038b8d48983ae3e8f482f5b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 11 Jul 2026 17:55:44 -0500 Subject: [PATCH] refac --- cptr/frontend/src/lib/apis/files.ts | 5 +- .../src/lib/components/FileBrowser.svelte | 88 ++++++++++++++++--- cptr/frontend/src/lib/i18n/locales/de.json | 4 +- cptr/frontend/src/lib/i18n/locales/en.json | 4 +- cptr/frontend/src/lib/i18n/locales/es.json | 4 +- cptr/frontend/src/lib/i18n/locales/fr.json | 4 +- cptr/frontend/src/lib/i18n/locales/ja.json | 4 +- cptr/frontend/src/lib/i18n/locales/ko.json | 4 +- cptr/frontend/src/lib/i18n/locales/pt-BR.json | 4 +- cptr/frontend/src/lib/i18n/locales/ru.json | 4 +- cptr/frontend/src/lib/i18n/locales/zh-CN.json | 4 +- cptr/frontend/src/lib/i18n/locales/zh-TW.json | 4 +- cptr/frontend/src/routes/+page.svelte | 5 +- cptr/routers/workspace.py | 26 ++++-- 14 files changed, 133 insertions(+), 31 deletions(-) diff --git a/cptr/frontend/src/lib/apis/files.ts b/cptr/frontend/src/lib/apis/files.ts index 0162f66..d29e01a 100644 --- a/cptr/frontend/src/lib/apis/files.ts +++ b/cptr/frontend/src/lib/apis/files.ts @@ -50,15 +50,16 @@ export type FileMatch = { name_match: boolean; content_matches: ContentMatch[]; }; -export type FileMatches = { results: FileMatch[]; truncated: boolean }; +export type FileMatches = { results: FileMatch[]; next_offset: number | null }; export const getFileMatches = ( query: string, path: string, showHidden: boolean, + offset = 0, signal?: AbortSignal ) => fetchJSON( - `/api/workspace/files/matches?query=${encodeURIComponent(query)}&path=${encodeURIComponent(path)}&show_hidden=${showHidden}`, + `/api/workspace/files/matches?query=${encodeURIComponent(query)}&path=${encodeURIComponent(path)}&show_hidden=${showHidden}&offset=${offset}`, { signal } ); diff --git a/cptr/frontend/src/lib/components/FileBrowser.svelte b/cptr/frontend/src/lib/components/FileBrowser.svelte index abf7f07..265fd9c 100644 --- a/cptr/frontend/src/lib/components/FileBrowser.svelte +++ b/cptr/frontend/src/lib/components/FileBrowser.svelte @@ -2,6 +2,7 @@ // Module-level cache: survives component destroy/create cycles const _treeExpandedCache = new Map(); const _treeContentsCache = new Map(); + const _searchQueryCache = new Map();