-
Notifications
You must be signed in to change notification settings - Fork 0
Sync: dev with main #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vprashrex
wants to merge
11
commits into
main
Choose a base branch
from
feat/merge-main-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sync: dev with main #195
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5927a7d
Assessment: Assessment Pipeline (#122)
vprashrex 9383243
Chore: Assessment Fix (#147)
vprashrex 78a811d
Assessment: Delete Modal and Card UI Fix (#149)
vprashrex d56a54a
AI Assessment: Gemini Model list and configuration added (#153)
vprashrex 00d84ce
Assessment: Interactive Spreadsheet Preview for Assessment Results (#…
vprashrex e63d0af
Chore: Enhance spreadsheet state management with debouncing and schem…
vprashrex 26a1ef7
Assessment: L1 Eliminatory filters, Post-Processing & Results page (#…
vprashrex f059089
merge "main" branch to feature-branch
vprashrex 6c6859e
Merge branch 'main' into feat/merge-main-dev
vprashrex c63f4b0
feat: add hooks and types for prompt and configuration management
vprashrex 1358e1e
Merge branch 'main' into feat/merge-main-dev
Ayush8923 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| name: Deploy Kaapi Dev to EC2 | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - dev | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| environment: AWS_ENV | ||
|
|
||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| attestations: write | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v6 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws-region: ${{ secrets.AWS_REGION }} | ||
|
|
||
| - name: Deploy via SSM | ||
| id: ssm | ||
| env: | ||
| BUILD_DIRECTORY: ${{ secrets.DEV_BUILD_DIRECTORY }} | ||
| APP_NAME: ${{ secrets.DEV_PM2_APP_NAME }} | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| INSTANCE_ID: ${{ secrets.EC2_STAGING_INSTANCE_ID }} | ||
| ROOT_USER: ${{ secrets.USER }} | ||
| run: | | ||
| REMOTE_CMD="export HOME=/home/$ROOT_USER && export NVM_DIR="/home/$ROOT_USER/.nvm" && [ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" && git config --global --add safe.directory ${BUILD_DIRECTORY} && set -e && cd ${BUILD_DIRECTORY} && git pull origin dev && npm ci && npm run build && sudo -iu ${ROOT_USER} pm2 restart ${APP_NAME}" | ||
| CMD_ID=$(aws ssm send-command \ | ||
| --instance-ids "$INSTANCE_ID" \ | ||
| --document-name "AWS-RunShellScript" \ | ||
| --parameters commands="[\"$REMOTE_CMD\"]" \ | ||
| --region "$AWS_REGION" \ | ||
| --query 'Command.CommandId' \ | ||
| --output text) | ||
| echo "cmd_id=$CMD_ID" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Wait for SSM command to finish | ||
| env: | ||
| INSTANCE_ID: ${{ secrets.EC2_STAGING_INSTANCE_ID }} | ||
| CMD_ID: ${{ steps.ssm.outputs.cmd_id }} | ||
| run: | | ||
| WAIT_EXIT=0 | ||
| aws ssm wait command-executed \ | ||
| --command-id "$CMD_ID" \ | ||
| --instance-id "$INSTANCE_ID" || WAIT_EXIT=$? | ||
|
|
||
| aws ssm get-command-invocation \ | ||
| --command-id "$CMD_ID" \ | ||
| --instance-id "$INSTANCE_ID" \ | ||
| --query '{Status:Status,Stdout:StandardOutputContent,Stderr:StandardErrorContent}' \ | ||
| --output json | ||
|
|
||
| exit $WAIT_EXIT | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| "use client"; | ||
|
|
||
| import { Suspense } from "react"; | ||
| import { Loader } from "@/app/components/ui"; | ||
| import PageLayout from "@/app/components/assessment/PageLayout"; | ||
| import { useAssessmentWorkflow } from "@/app/hooks/useAssessmentWorkflow"; | ||
|
|
||
| function PageContent() { | ||
| const layoutProps = useAssessmentWorkflow(); | ||
| return <PageLayout {...layoutProps} />; | ||
| } | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <Suspense fallback={<Loader size="lg" message="Loading..." fullScreen />}> | ||
| <PageContent /> | ||
| </Suspense> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import { useParams, useSearchParams } from "next/navigation"; | ||
| import dynamic from "next/dynamic"; | ||
| import { Loader } from "@/app/components/ui"; | ||
| import { useToast } from "@/app/hooks/useToast"; | ||
| import { useAuth } from "@/app/lib/context/AuthContext"; | ||
| import { apiFetch } from "@/app/lib/apiClient"; | ||
| import { jsonResultsToTableData } from "@/app/lib/assessment/results"; | ||
| import { SPREADSHEET_PREVIEW_ROW_LIMIT } from "@/app/lib/assessment/constants"; | ||
|
|
||
| const SpreadsheetView = dynamic( | ||
| () => import("@/app/components/assessment/SpreadsheetView"), | ||
| { | ||
| ssr: false, | ||
| loading: () => ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <Loader size="lg" message="Loading spreadsheet..." /> | ||
| </div> | ||
| ), | ||
| }, | ||
| ); | ||
|
|
||
| export default function AssessmentResultsPage() { | ||
| const params = useParams<{ runId: string }>(); | ||
| const searchParams = useSearchParams(); | ||
| const toast = useToast(); | ||
| const { apiKeys, isAuthenticated, isHydrated } = useAuth(); | ||
| const apiKey = apiKeys[0]?.key ?? ""; | ||
|
|
||
| const [headers, setHeaders] = useState<string[] | null>(null); | ||
| const [rows, setRows] = useState<string[][] | null>(null); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| const runId = Number(params?.runId); | ||
| const title = searchParams.get("title") ?? `Run ${runId}`; | ||
|
|
||
| useEffect(() => { | ||
| if (!isHydrated) return; | ||
| if (!isAuthenticated) { | ||
| setError("You must be signed in to view this run."); | ||
| return; | ||
| } | ||
| if (!Number.isFinite(runId) || runId <= 0) { | ||
| setError("Invalid run id."); | ||
| return; | ||
| } | ||
|
|
||
| let cancelled = false; | ||
| (async () => { | ||
| try { | ||
| const json = await apiFetch< | ||
| { data?: Record<string, unknown>[] } | Record<string, unknown>[] | ||
| >(`/api/assessment/runs/${runId}/results?export_format=json`, apiKey); | ||
| const results: Record<string, unknown>[] = Array.isArray(json) | ||
| ? json | ||
| : json.data || []; | ||
| const table = jsonResultsToTableData(results, { | ||
| rowLimit: SPREADSHEET_PREVIEW_ROW_LIMIT, | ||
| }); | ||
| if (cancelled) return; | ||
| if (results.length > SPREADSHEET_PREVIEW_ROW_LIMIT) { | ||
| toast.warning( | ||
| `Preview capped at ${SPREADSHEET_PREVIEW_ROW_LIMIT} rows. Download CSV for full data.`, | ||
| ); | ||
| } | ||
| setHeaders(table.headers); | ||
| setRows(table.rows); | ||
| } catch (err) { | ||
| if (cancelled) return; | ||
| const msg = | ||
| err instanceof Error ? err.message : "Failed to load results"; | ||
| setError(msg); | ||
| toast.error(msg); | ||
| } | ||
| })(); | ||
|
|
||
| return () => { | ||
| cancelled = true; | ||
| }; | ||
| }, [apiKey, isAuthenticated, isHydrated, runId, toast]); | ||
|
|
||
| if (error) { | ||
| return ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <p className="text-sm text-text-secondary">{error}</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (!headers || !rows) { | ||
| return ( | ||
| <div className="w-full h-screen flex items-center justify-center bg-bg-primary"> | ||
| <Loader size="lg" message="Loading results..." /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <SpreadsheetView | ||
| runId={runId} | ||
| title={title} | ||
| subtitle={`${rows.length} rows · ${headers.length} columns`} | ||
| headers={headers} | ||
| rows={rows} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import "server-only"; | ||
|
|
||
| import { NextResponse } from "next/server"; | ||
| import { apiClient } from "@/app/lib/apiClient"; | ||
|
|
||
| const DOWNLOAD_CONTENT_TYPE_HINTS = [ | ||
| "text/csv", | ||
| "spreadsheetml", | ||
| "octet-stream", | ||
| "application/zip", | ||
| ]; | ||
|
|
||
| function isDownloadContentType(contentType: string): boolean { | ||
| return DOWNLOAD_CONTENT_TYPE_HINTS.some((hint) => contentType.includes(hint)); | ||
| } | ||
|
|
||
| async function safeParseJson( | ||
| response: Response, | ||
| ): Promise<Record<string, unknown> | unknown[] | null> { | ||
| const text = response.status === 204 ? "" : await response.text(); | ||
| if (!text) return null; | ||
|
|
||
| try { | ||
| return JSON.parse(text) as Record<string, unknown> | unknown[]; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| async function toDownloadResponse( | ||
| response: Response, | ||
| ): Promise<NextResponse | null> { | ||
| const contentType = response.headers.get("content-type") || ""; | ||
| if (!isDownloadContentType(contentType)) { | ||
| return null; | ||
| } | ||
|
|
||
| const blob = await response.blob(); | ||
| const headers = new Headers(); | ||
| headers.set("Content-Type", contentType); | ||
|
|
||
| const disposition = response.headers.get("content-disposition"); | ||
| if (disposition) { | ||
| headers.set("Content-Disposition", disposition); | ||
| } | ||
|
|
||
| return new NextResponse(blob, { status: response.status, headers }); | ||
| } | ||
|
|
||
| export function withQueryParams( | ||
| endpoint: string, | ||
| queryParams: URLSearchParams, | ||
| ): string { | ||
| const query = queryParams.toString(); | ||
| return query ? `${endpoint}?${query}` : endpoint; | ||
| } | ||
|
|
||
| export async function proxyJsonResponse( | ||
| request: Request, | ||
| endpoint: string, | ||
| init: RequestInit = {}, | ||
| ): Promise<NextResponse> { | ||
| const { status, data } = await apiClient(request, endpoint, init); | ||
| return NextResponse.json(data, { status }); | ||
| } | ||
|
|
||
| export async function proxyDownloadOrJsonResponse( | ||
| request: Request, | ||
| endpoint: string, | ||
| init: RequestInit = {}, | ||
| ): Promise<NextResponse> { | ||
| const response = await apiClient(request, endpoint, { | ||
| ...init, | ||
| responseType: "raw", | ||
| }); | ||
|
|
||
| const downloadResponse = await toDownloadResponse(response); | ||
| if (downloadResponse) { | ||
| return downloadResponse; | ||
| } | ||
|
|
||
| const data = await safeParseJson(response); | ||
| return NextResponse.json(data, { status: response.status }); | ||
| } | ||
|
|
||
| export function proxyErrorResponse( | ||
| logLabel: string, | ||
| error: unknown, | ||
| message = "Failed to forward request to backend", | ||
| ): NextResponse { | ||
| console.error(logLabel, error); | ||
| return NextResponse.json({ error: message }, { status: 500 }); | ||
| } |
32 changes: 32 additions & 0 deletions
32
app/api/assessment/assessments/[assessment_id]/results/route.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||
| // BFF proxy — GET /api/v1/assessment/assessments/:id/results (JSON or file download) | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| import { NextRequest } from "next/server"; | ||||
| import { | ||||
| proxyDownloadOrJsonResponse, | ||||
| proxyErrorResponse, | ||||
| withQueryParams, | ||||
| } from "@/app/api/_routeProxy"; | ||||
|
|
||||
| export async function GET( | ||||
| request: NextRequest, | ||||
| { params }: { params: Promise<{ assessment_id: string }> }, | ||||
| ) { | ||||
| try { | ||||
| const { assessment_id } = await params; | ||||
| const queryParams = new URLSearchParams(request.nextUrl.searchParams); | ||||
| queryParams.set("get_trace_info", "true"); | ||||
| return await proxyDownloadOrJsonResponse( | ||||
| request, | ||||
| withQueryParams( | ||||
| `/api/v1/assessment/assessments/${assessment_id}/results`, | ||||
| queryParams, | ||||
| ), | ||||
| { method: "GET" }, | ||||
| ); | ||||
| } catch (error: unknown) { | ||||
| return proxyErrorResponse( | ||||
| "Assessment results proxy error:", | ||||
| error, | ||||
| "Failed to forward request", | ||||
| ); | ||||
| } | ||||
| } | ||||
28 changes: 28 additions & 0 deletions
28
app/api/assessment/assessments/[assessment_id]/retry/route.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||
| // BFF proxy — POST /api/v1/assessment/assessments/:id/retry | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| import { NextRequest, NextResponse } from "next/server"; | ||||
| import { apiClient } from "@/app/lib/apiClient"; | ||||
| import type { RouteContext } from "@/app/lib/types/assessment"; | ||||
|
|
||||
| export async function POST( | ||||
| request: NextRequest, | ||||
| context: RouteContext<"assessment_id">, | ||||
| ) { | ||||
| try { | ||||
| const { assessment_id } = await context.params; | ||||
| const { status, data } = await apiClient( | ||||
| request, | ||||
| `/api/v1/assessment/assessments/${assessment_id}/retry`, | ||||
| { method: "POST" }, | ||||
| ); | ||||
|
|
||||
| return NextResponse.json(data, { status }); | ||||
| } catch (error: unknown) { | ||||
| console.error("Assessment retry proxy error:", error); | ||||
| return NextResponse.json( | ||||
| { | ||||
| error: "Failed to forward assessment retry request", | ||||
| }, | ||||
| { status: 500 }, | ||||
| ); | ||||
| } | ||||
| } | ||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix malformed shell quoting in
REMOTE_CMD.Line 38 has broken nested quoting around
NVM_DIR; this can fail the deploy step beforesend-commandsucceeds.Suggested patch
📝 Committable suggestion
🤖 Prompt for AI Agents