Skip to content

Commit dacbe6d

Browse files
Format context selector
1 parent 5d33702 commit dacbe6d

1 file changed

Lines changed: 10 additions & 31 deletions

File tree

src/components/ai-chat/context-selector.tsx

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export function ContextSelector({
105105
}: Omit<ContextSelectorProps, "allProjectFiles">) {
106106
const [searchTerm, setSearchTerm] = useState("");
107107
const dropdownRef = useRef<HTMLDivElement>(null);
108-
const [allFiles, setAllFiles] = useState<
109-
Array<{ name: string; path: string; isDir: boolean }>
110-
>([]);
108+
const [allFiles, setAllFiles] = useState<Array<{ name: string; path: string; isDir: boolean }>>(
109+
[],
110+
);
111111

112112
// Get rootFolderPath from project store and file system store
113113
const { rootFolderPath } = useProjectStore();
@@ -133,12 +133,8 @@ export function ContextSelector({
133133
const normalizedRootPath = rootFolderPath.replace(/\\/g, "/");
134134

135135
if (normalizedFullPath.startsWith(normalizedRootPath)) {
136-
const relativePath = normalizedFullPath.substring(
137-
normalizedRootPath.length,
138-
);
139-
return relativePath.startsWith("/")
140-
? relativePath.substring(1)
141-
: relativePath;
136+
const relativePath = normalizedFullPath.substring(normalizedRootPath.length);
137+
return relativePath.startsWith("/") ? relativePath.substring(1) : relativePath;
142138
}
143139

144140
return fullPath;
@@ -330,9 +326,7 @@ export function ContextSelector({
330326
<div className="py-1" role="listbox" aria-label="Files and buffers">
331327
{allItems.length === 0 ? (
332328
<div className="px-3 py-2 text-center font-mono text-text-lighter text-xs">
333-
{searchTerm
334-
? "No matching files found"
335-
: "No files available"}
329+
{searchTerm ? "No matching files found" : "No files available"}
336330
</div>
337331
) : (
338332
allItems.map((item) => (
@@ -354,15 +348,9 @@ export function ContextSelector({
354348
<div className="flex min-w-0 flex-1 items-center gap-2">
355349
{item.type === "buffer" ? (
356350
item.isSQLite ? (
357-
<Database
358-
size={10}
359-
className="flex-shrink-0 text-text-lighter"
360-
/>
351+
<Database size={10} className="flex-shrink-0 text-text-lighter" />
361352
) : (
362-
<FileText
363-
size={10}
364-
className="flex-shrink-0 text-text-lighter"
365-
/>
353+
<FileText size={10} className="flex-shrink-0 text-text-lighter" />
366354
)
367355
) : (
368356
<FileIcon
@@ -441,10 +429,7 @@ export function ContextSelector({
441429
{item.name}
442430
</span>
443431
{item.type === "buffer" && item.isDirty && (
444-
<span
445-
className="text-[8px] text-yellow-500"
446-
title="Unsaved changes"
447-
>
432+
<span className="text-[8px] text-yellow-500" title="Unsaved changes">
448433
449434
</span>
450435
)}
@@ -460,13 +445,7 @@ export function ContextSelector({
460445
aria-label={`Remove ${item.name} from context`}
461446
tabIndex={0}
462447
>
463-
<svg
464-
width="8"
465-
height="8"
466-
viewBox="0 0 16 16"
467-
fill="currentColor"
468-
aria-hidden="true"
469-
>
448+
<svg width="8" height="8" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
470449
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z" />
471450
</svg>
472451
</button>

0 commit comments

Comments
 (0)