Skip to content
Open
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
39 changes: 31 additions & 8 deletions web/app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { useState } from "react";
import Link from "next/link";
import ProfileCombobox from "@/app/components/ProfileCombobox";
import History, { HistoryEntry } from "@/app/components/History";
Expand Down Expand Up @@ -61,6 +62,12 @@
handleHistoryLoad,
isCustomSelection,
}: SidebarProps) {
const [visibleKeys, setVisibleKeys] = useState<Record<string, boolean>>({});

const toggleKeyVisibility = (key: string) => {

Check warning on line 67 in web/app/components/Sidebar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/components/Sidebar.tsx#L67

Non-serializable expression must be wrapped with $(...)
setVisibleKeys((prev) => ({ ...prev, [key]: !prev[key] }));

Check warning on line 68 in web/app/components/Sidebar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/components/Sidebar.tsx#L68

Generic Object Injection Sink
};

return (
<aside
id="sidebar-navigation"
Expand Down Expand Up @@ -259,16 +266,32 @@
const value = apiKeys[key] || "";
const source = keySource[provider.sourceKey || provider.id];
const hasServer = source === "server";
const isVisible = !!visibleKeys[key];

Check warning on line 269 in web/app/components/Sidebar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/components/Sidebar.tsx#L269

Generic Object Injection Sink
const hasValue = !!value;

return (
<div key={provider.id} className="flex flex-col gap-1">
<label className="text-[10px] text-text-muted">{provider.label} {hasServer && !value && "(server)"}</label>
<input
type="password"
value={value}
onChange={(e) => handleKeyChange(key, e.target.value)}
placeholder={hasServer && !value ? "Using server key" : "sk-..."}
className="bg-[#141414] border-2 border-border-muted px-2 py-2 text-[12px] text-foreground placeholder:text-text-dim focus:border-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 min-h-[44px]"
/>
<label htmlFor={`input-${provider.id}`} className="text-[10px] text-text-muted">{provider.label} {hasServer && !value && "(server)"}</label>
<div className="relative flex items-center">
<input
id={`input-${provider.id}`}
type={isVisible ? "text" : "password"}
value={value}
onChange={(e) => handleKeyChange(key, e.target.value)}
placeholder={hasServer && !value ? "Using server key" : "sk-..."}
className="w-full bg-[#141414] border-2 border-border-muted pl-2 pr-12 py-2 text-[12px] text-foreground placeholder:text-text-dim focus:border-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 min-h-[44px]"
/>
{hasValue && (
<button
type="button"
onClick={() => toggleKeyVisibility(key)}

Check warning on line 287 in web/app/components/Sidebar.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/components/Sidebar.tsx#L287

Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
className="absolute right-2 px-2 py-1 text-[10px] text-text-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"
aria-label={isVisible ? "Hide key" : "Show key"}
>
{isVisible ? "Hide" : "Show"}
</button>
)}
</div>
</div>
);
})}
Expand Down
39 changes: 29 additions & 10 deletions web/app/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
});
const [keyStatus, setKeyStatus] = useState<KeyStatus>({});
const [saved, setSaved] = useState(false);
const [visibleKeys, setVisibleKeys] = useState<Record<string, boolean>>({});

useEffect(() => {
fetch("/api/key-status")
Expand Down Expand Up @@ -79,11 +80,15 @@
persistKeys(newKeys);
};

const toggleKeyVisibility = (key: string) => {

Check warning on line 83 in web/app/settings/page.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/settings/page.tsx#L83

Non-serializable expression must be wrapped with $(...)
setVisibleKeys((prev) => ({ ...prev, [key]: !prev[key] }));

Check warning on line 84 in web/app/settings/page.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/settings/page.tsx#L84

Generic Object Injection Sink
};

return (
<main className="min-h-screen bg-background text-foreground font-mono p-8">
<div className="max-w-xl">
<div className="mb-8">
<Link href="/" className="text-[11px] uppercase tracking-[0.1em] text-text-muted hover:text-accent">
<Link href="/" className="text-[11px] uppercase tracking-[0.1em] text-text-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2">
← Back
</Link>
</div>
Expand All @@ -98,11 +103,12 @@
const value = apiKeys[field.key] || "";
const localHasKey = !!value;
const serverHasKey = !!keyStatus[field.provider];
const isVisible = !!visibleKeys[field.key];

return (
<div key={field.key} className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<label className="text-[13px]">{field.label}</label>
<label htmlFor={`input-${field.key}`} className="text-[13px]">{field.label}</label>

Check warning on line 111 in web/app/settings/page.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/settings/page.tsx#L111

Invalid type "string | number | symbol" of template literal expression.
<div className="flex items-center gap-2">
{localHasKey ? (
<span className="text-[11px] text-accent">Local key</span>
Expand All @@ -114,20 +120,33 @@
{localHasKey && (
<button
onClick={() => clearKey(field.key)}
className="text-[11px] text-[#ff4444] hover:text-[#ff6666]"
className="text-[11px] text-[#ff4444] hover:text-[#ff6666] focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"
>
Remove
</button>
)}
</div>
</div>
<input
type="password"
value={value}
onChange={(e) => handleKeyChange(field.key, e.target.value)}
placeholder="sk-..."
className="bg-[#141414] border-2 border-border-muted px-3 py-2 text-[13px] text-foreground placeholder:text-text-dim focus:border-accent focus:outline-none"
/>
<div className="relative flex items-center">
<input
id={`input-${field.key}`}

Check warning on line 132 in web/app/settings/page.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/settings/page.tsx#L132

Invalid type "string | number | symbol" of template literal expression.
type={isVisible ? "text" : "password"}
value={value}
onChange={(e) => handleKeyChange(field.key, e.target.value)}
placeholder="sk-..."
className="w-full bg-[#141414] border-2 border-border-muted pl-3 pr-12 py-2 text-[13px] text-foreground placeholder:text-text-dim focus:border-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"
/>
{localHasKey && (
<button
type="button"
onClick={() => toggleKeyVisibility(field.key)}

Check warning on line 142 in web/app/settings/page.tsx

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

web/app/settings/page.tsx#L142

Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function.
className="absolute right-2 px-2 py-1 text-[11px] text-text-muted hover:text-accent focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"
aria-label={isVisible ? "Hide key" : "Show key"}
>
{isVisible ? "Hide" : "Show"}
</button>
)}
</div>
{serverHasKey && !localHasKey && (
<p className="text-[11px] text-text-muted">
Server key available. Enter your own to override.
Expand Down
1 change: 1 addition & 0 deletions web/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/types/root-params.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
4 changes: 2 additions & 2 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
Expand Down
Loading