Skip to content

Commit 8206572

Browse files
authored
feat: enhance UI components and improve accessibility (#48)
- Updated typography styles across various components for better readability and consistency. - Changed heading levels and classes in DependencyDetails for improved semantic structure. - Refined button and text styles in HeaderControls and Header for a more cohesive design. - Enhanced error messages and loading indicators in MainContent for better user experience. - Improved session ID generation logic in utils for better uniqueness. - Added connection header to API requests for better performance. - Adjusted dropdown and tooltip components for improved usability and aesthetics. - Fixed minor bugs and improved overall code quality.
1 parent 69b62aa commit 8206572

30 files changed

Lines changed: 213 additions & 152 deletions

backend/config/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dotenv.config();
44

55
// Load environment variables with defaults
66
export const config = {
7-
port: parseInt(process.env.PORT ?? "4000", 10),
7+
port: parseInt(process.env.PORT ?? "8080", 10),
88
nodeEnv: process.env.NODE_ENV ?? "development",
99
openRouterApiKey: process.env.OPEN_ROUTER_KEY ?? "",
1010
defaultModel: process.env.DEFAULT_MODEL,

backend/prompts/schemas/inlineai-summary-schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"type": "object",
3-
"title": "Vulnerability Summary Schema",
4-
"description": "Schema for AI-generated vulnerability summaries with strict formatting and prioritization rules.",
53
"required": ["summary", "actionable_items", "explaination"],
64
"properties": {
75
"summary": {

backend/prompts/schemas/vulnerability-summary-schema.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
32
"type": "object",
4-
"title": "Vulnerability Summary Schema",
5-
"description": "Schema for one combined AI-generated vulnerabilities summary with strict formatting and prioritization rules.",
63
"required": [
74
"risk_score",
85
"risk_score_justification",
@@ -40,16 +37,13 @@
4037
},
4138
"impact": {
4239
"type": "string",
43-
"minLength": 50,
44-
"maxLength": 200,
45-
"description": "Description of potential impact (under 100 words). Focus on business and operational risk. **Do not repeat the summary** and **Bold** for critical information."
40+
"description": "Description of potential business and technical impact."
4641
},
4742
"affected_components": {
4843
"type": "array",
4944
"items": {
5045
"type": "string",
51-
"pattern": "^[a-zA-Z0-9._\\-]+(<[0-9]+\\.[0-9]+\\.[0-9]+)?$",
52-
"description": "List of affected components/packages. Each item can include a version constraint (or a range) in the Semantic Versioning format (from version1 to version2)."
46+
"description": "Affected component/package name, optionally with version."
5347
},
5448
"minItems": 1,
5549
"description": "List of affected components/packages along with optional version constraints."
@@ -63,15 +57,14 @@
6357
"type": "array",
6458
"items": {
6559
"type": "string",
66-
"pattern": ".*\\*\\*.*\\*\\*.*"
60+
"description": "Recommended action. Use **bold** for critical terms."
6761
},
6862
"minItems": 1,
6963
"description": "Ordered list of recommended actions. **Bold** the most critical information and <code></code> for commands. First action must be the primary fix."
7064
},
7165
"timeline": {
7266
"type": "string",
73-
"pattern": "^(Within|In|By)\\s+(\\d+\\s+(Hours?|Days?|Weeks?|Months?)|Immediately|ASAP)$",
74-
"description": "Estimated timeline for fix implementation. Exactly three words, title case. Examples: 'Within 2 Days', 'By 1 Week', 'Within X Hours'."
67+
"description": "Estimated timeline for fix. Examples: 'Within 24 Hours', 'Within 2 Days', 'Within 1 Week'."
7568
},
7669
"exploit_vector": {
7770
"type": "string",

backend/server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ app.post("/analyseFile", analysisRateLimiter, (req: Request, res: Response) => {
357357
const cachedFileDetails = await getCachedFileDetails(file);
358358
try {
359359
const analysisResults = await analysisService.analyseFile(cachedFileDetails);
360-
361360
res.json(analysisResults);
362361
} catch (error) {
363362
console.error("Error analysing file:", error);
@@ -378,10 +377,9 @@ app.post("/aiVulnSummary", aiRateLimiter, (req: Request, res: Response) => {
378377
console.log("Received aiVulnSummary request for:", vulnerabilities.name, "@", vulnerabilities.version);
379378
try {
380379
// Get credentials from session store
381-
const { apiKey, model } = getSessionCredentials(sessionId);
382-
console.log("Using credentials - apiKey:", apiKey ? "provided" : "default", "model:", model || "default");
380+
const { apiKey, model } = getSessionCredentials(sessionId);
383381
const service = getAiService(aiService, model, apiKey);
384-
// Pass only the vulnerabilities array to the service
382+
385383
console.log("Calling generateVulnerabilitySummary...");
386384
const summary = await service.generateVulnerabilitySummary(vulnerabilities.vulnerabilities);
387385
console.log("Got summary response, sending to client...");

backend/service/ai_service.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { AIUtils } from "../utils/ai_utils";
99
class AiService {
1010
private ai: OpenRouter;
1111
private defaultModel: string;
12+
private readonly summaryTimeoutMs = 300000;
13+
private readonly summaryMaxRetries = 3;
1214

1315
constructor(model?: string, apiKey?: string) {
1416
const key = apiKey ?? process.env.OPEN_ROUTER_KEY;
@@ -28,12 +30,19 @@ class AiService {
2830
"{{vulnerabilities}}",
2931
JSON.stringify(vulnerabilities),
3032
);
31-
console.log("Generating vulnerability summary with model:", model ?? this.defaultModel);
32-
return AIUtils.callAI(this.ai, systemPrompt, userPrompt, vulnerabilitySummarySchema, {
33-
model: model ?? this.defaultModel,
34-
schemaName: "vulnerability_summary",
35-
returnString: true,
36-
});
33+
const selectedModel = model ?? this.defaultModel;
34+
console.log("Generating vulnerability summary with model:", selectedModel);
35+
36+
return AIUtils.callAIWithRetry(
37+
() =>
38+
AIUtils.callAI(this.ai, systemPrompt, userPrompt, vulnerabilitySummarySchema, {
39+
model: selectedModel,
40+
schemaName: "vulnerability_summary",
41+
returnString: true,
42+
timeout: this.summaryTimeoutMs,
43+
}),
44+
this.summaryMaxRetries,
45+
);
3746
}
3847

3948
generateInlineResponse(

backend/utils/ai_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class AIUtils {
4545
responseFormat: {
4646
type: "json_schema",
4747
jsonSchema: {
48-
name: options.schemaName ?? "response",
48+
name: options.schemaName ?? "response_schema",
4949
strict: true,
5050
schema: jsonSchema,
5151
},

backend/utils/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ export const getAiService = (aiService: AiService, model?: string, apiKey?: stri
3838
let service = aiServiceCache.get(cacheKey);
3939

4040
if (!service) {
41+
console.log("Creating new AiService instance for model:", model ?? "default");
4142
service = new AiService(model, apiKey);
4243
aiServiceCache.set(cacheKey, service);
4344
}
44-
45+
console.log("Using AiService instance for model:", model ?? "default");
4546
return service;
4647
};
4748

src/app/globals.css

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
@theme inline {
1515
--color-background: var(--background);
1616
--color-foreground: var(--foreground);
17-
--font-sans: var(--font-geist-pixel-square);
17+
--font-sans: var(--font-geist-sans);
1818
--font-mono: var(--font-geist-mono);
19+
--font-pixel: var(--font-geist-pixel-square);
1920
--color-sidebar-ring: var(--sidebar-ring);
2021
--color-sidebar-border: var(--sidebar-border);
2122
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
@@ -191,6 +192,49 @@
191192
@apply border-border outline-ring/50;
192193
}
193194
body {
194-
@apply bg-background text-foreground;
195+
@apply bg-background text-foreground leading-relaxed;
196+
}
197+
h1,
198+
h2,
199+
h3,
200+
h4,
201+
h5,
202+
h6 {
203+
font-family: var(--font-geist-sans);
204+
font-weight: 700;
205+
letter-spacing: -0.015em;
206+
}
207+
strong,
208+
b {
209+
font-family: var(--font-geist-sans);
210+
font-weight: 700;
211+
}
212+
}
213+
214+
@layer utilities {
215+
.font-ui-pixel {
216+
font-family: var(--font-geist-pixel-square);
217+
letter-spacing: 0.01em;
218+
}
219+
220+
.font-ui-heading {
221+
font-family: var(--font-geist-sans);
222+
letter-spacing: -0.01em;
223+
}
224+
225+
.font-ui-strong {
226+
font-family: var(--font-geist-sans);
227+
font-weight: 700;
228+
}
229+
230+
.font-ui-mono {
231+
font-family: var(--font-geist-mono);
232+
letter-spacing: -0.01em;
233+
}
234+
235+
.font-ui-data {
236+
font-family: var(--font-geist-mono);
237+
font-variant-numeric: tabular-nums;
238+
letter-spacing: -0.01em;
195239
}
196240
}

src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function RootLayout({
9090
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
9191
<link rel="dns-prefetch" href="https://fonts.googleapis.com" />
9292
</head>
93-
<body className="flex h-screen flex-col bg-background bg-repeat bg-size-[300px_300px] bg-[url('/bg.svg')] bg-blend-multiply relative font-sans tracking-wide">
93+
<body className="relative flex h-screen flex-col bg-background bg-repeat bg-size-[300px_300px] bg-[url('/bg.svg')] bg-blend-multiply font-sans antialiased">
9494
<SpeedInsights />
9595
<ThemeProvider>
9696
<NetworkStatusProvider>

src/components/banner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const Banner = () => {
44
{/* Background SVG for large screens, hidden on small screens */}
55
<div className="relative flex flex-col items-center justify-evenly space-y-4 px-4 sm:px-0">
66
<div className="relative z-10 text-center">
7-
<h1 className="sm:text-6xl text-[40px] font-bold leading-10 tracking-tighter text-yellow-300">
8-
Scan and Secure your <em className="font-black tracking-light">Deps</em> !
7+
<h1 className="font-ui-heading sm:text-6xl text-[40px] font-black leading-10 tracking-tighter text-yellow-300">
8+
Scan and Secure your <em className="font-ui-pixel not-italic tracking-normal">Deps</em> !
99
</h1>
1010
</div>
1111
<div className="mx-auto max-w-4xl text-center">
12-
<p className="sm:mt-5 text-md ">
12+
<p className="sm:mt-5 sm:text-lg text-md leading-relaxed">
1313
Visualise, detect and fix dependency vulnerabilities of your codebase in one click.{" "}
1414
<br /> Free & Open Source!
1515
</p>

0 commit comments

Comments
 (0)