xonecas.io
53129
Pa

PAT / commit 525982e

fix: pre-commit, format everything

xonecas2025-12-19 525982e5c235c68ef423c21e0c64f337060a0db1 parent a726b30

10 files changed

.husky/pre-commit+5−2
@@ -1,5 +1,8 @@
1-# Run lint-staged (will fail if prettier or eslint fail)
2-npx lint-staged || exit 1
1+# Run format check
2+npm run format:check || exit 1
3+
4+# Run lint check
5+npm run lint || exit 1
36
47 # Run TypeScript type checking (will fail on type errors)
58 npm run typecheck || exit 1
app/api/models/route.ts+4−1
@@ -11,7 +11,10 @@ export async function GET() {
1111 }));
1212 return NextResponse.json({ models });
1313 } catch (err) {
14- debug(`[Models API] Error fetching models:`, err instanceof Error ? err.message : "Unknown error");
14+ debug(
15+ `[Models API] Error fetching models:`,
16+ err instanceof Error ? err.message : "Unknown error"
17+ );
1518 return NextResponse.json({ error: "Failed to fetch models" }, { status: 500 });
1619 }
1720 }
app/api/threads/[id]/messages/route.ts+6−3
@@ -15,11 +15,14 @@ export async function GET(request: Request, { params }: { params: Promise<{ id:
1515
1616 const url = new URL(request.url);
1717 const optionalRolesParam = url.searchParams.get("optional_roles");
18-
18+
1919 const allowedRoles: string[] = ["user", "assistant"];
20-
20+
2121 if (optionalRolesParam) {
22- const optionalRoles = optionalRolesParam.split(",").map((r) => r.trim()).filter(Boolean);
22+ const optionalRoles = optionalRolesParam
23+ .split(",")
24+ .map((r) => r.trim())
25+ .filter(Boolean);
2326 const validOptionalRoles = optionalRoles.filter((r) => ["system", "tool"].includes(r));
2427 allowedRoles.push(...validOptionalRoles);
2528 }
app/api/threads/route.ts+8−2
@@ -55,7 +55,10 @@ export async function POST(request: Request) {
5555 systemMessage: systemMessage[0],
5656 });
5757 } catch (err) {
58- debug(`[Threads API] Error creating thread:`, err instanceof Error ? err.message : "Unknown error");
58+ debug(
59+ `[Threads API] Error creating thread:`,
60+ err instanceof Error ? err.message : "Unknown error"
61+ );
5962 return NextResponse.json({ error: "Failed to create thread" }, { status: 500 });
6063 }
6164 }
@@ -79,7 +82,10 @@ export async function GET(request: Request) {
7982
8083 return NextResponse.json({ threads: threadsList, hasMore, totalCount });
8184 } catch (err) {
82- debug(`[Threads API] Error fetching threads:`, err instanceof Error ? err.message : "Unknown error");
85+ debug(
86+ `[Threads API] Error fetching threads:`,
87+ err instanceof Error ? err.message : "Unknown error"
88+ );
8389 return NextResponse.json({ error: "Failed to get threads" }, { status: 500 });
8490 }
8591 }
package.json+0−10
@@ -54,18 +54,8 @@
5454 "eslint-config-next": "^16.0.10",
5555 "eslint-config-prettier": "^10.1.8",
5656 "husky": "^9.1.7",
57- "lint-staged": "^16.2.7",
5857 "prettier": "^3.2.5",
5958 "prettier-plugin-tailwindcss": "^0.5.11",
6059 "vitest": "^4.0.16"
61- },
62- "lint-staged": {
63- "*.{ts,tsx,js,jsx,mjs,cjs}": [
64- "prettier --write",
65- "eslint --fix"
66- ],
67- "*.{json,md,css,html,yml,yaml}": [
68- "prettier --write"
69- ]
7060 }
7161 }
src/hooks/useMessageDisplaySettings.ts+3−2
@@ -16,8 +16,9 @@ const DEFAULT_SETTINGS: MessageDisplaySettings = {
1616 */
1717 export function useMessageDisplaySettings(): [
1818 MessageDisplaySettings,
19- (value: MessageDisplaySettings | ((prev: MessageDisplaySettings) => MessageDisplaySettings)) => void
19+ (
20+ value: MessageDisplaySettings | ((prev: MessageDisplaySettings) => MessageDisplaySettings)
21+ ) => void,
2022 ] {
2123 return useLocalStorage<MessageDisplaySettings>("messageDisplaySettings", DEFAULT_SETTINGS);
2224 }
23-
src/lib/errors.ts+0−1
@@ -30,4 +30,3 @@ export function handleError(error: unknown, onError?: (error: string) => void):
3030 export function getParseErrorMessage(parseError: unknown): string {
3131 return `Failed to parse error response: ${getErrorMessage(parseError, "Invalid JSON")}`;
3232 }
33-
src/lib/ollama/chat/message-persistence.ts+3−1
@@ -50,7 +50,9 @@ export interface SaveToolMessageParams {
5050 * @param params.toolName - Name of the tool that was called
5151 * @returns Promise that resolves with the saved message ID and content
5252 */
53-export async function saveToolMessage(params: SaveToolMessageParams): Promise<{ id: number; content: string; createdAt: Date }> {
53+export async function saveToolMessage(
54+ params: SaveToolMessageParams
55+): Promise<{ id: number; content: string; createdAt: Date }> {
5456 const { threadId, content, toolName } = params;
5557
5658 const savedMessage = await db
src/tests/lib/ollama/chat/assistant-response.test.ts+3−1
@@ -24,7 +24,9 @@ vi.mock("@/src/lib/ollama/chat/abort-handler", () => ({
2424
2525 vi.mock("@/src/lib/ollama/chat/message-persistence", () => ({
2626 saveAssistantMessage: vi.fn().mockResolvedValue(undefined),
27- saveToolMessage: vi.fn().mockResolvedValue({ id: 1, content: "[tool]\nresult", createdAt: new Date() }),
27+ saveToolMessage: vi
28+ .fn()
29+ .mockResolvedValue({ id: 1, content: "[tool]\nresult", createdAt: new Date() }),
2830 extractToolCounts: vi.fn(),
2931 }));
3032
tsconfig.tsbuildinfo+1−1
@@ -1 +1 @@
1-{"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.es2021.d.ts","./node_modules/typescript/lib/lib.es2022.d.ts","./node_modules/typescript/lib/lib.es2023.d.ts","./node_m …
1+{"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.es2021.d.ts","./node_modules/typescript/lib/lib.es2022.d.ts","./node_modules/typescript/lib/lib.es2023.d.ts","./node_m …