Skip to content

Commit fb139f4

Browse files
committed
WIP
1 parent bf80939 commit fb139f4

File tree

20 files changed

+74
-65
lines changed

20 files changed

+74
-65
lines changed

apps/web/client/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
33
* for Docker builds.
44
*/
5-
import { NextConfig } from 'next';
5+
import type { NextConfig } from 'next';
66
import createNextIntlPlugin from 'next-intl/plugin';
77
import path from 'node:path';
88
import './src/env';

apps/web/client/src/app/callback/github/install/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default function GitHubInstallCallbackPage() {
2020
const handleInstallationCallback = api.github.handleInstallationCallbackUrl.useMutation();
2121

2222
useEffect(() => {
23+
if (!searchParams) return;
24+
2325
const installationId = searchParams.get('installation_id');
2426
const setupAction = searchParams.get('setup_action');
2527
const stateParam = searchParams.get('state');

apps/web/client/src/app/invitation/[id]/_components/auth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const HandleAuth = () => {
1212
const searchParams = useSearchParams();
1313

1414
const handleLogin = () => {
15-
const currentUrl = `${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
15+
const currentUrl = `${pathname}${searchParams && searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
1616
router.push(`${Routes.LOGIN}?${getReturnUrlQueryParam(currentUrl)}`);
1717
}
1818

apps/web/client/src/app/invitation/[id]/_components/main.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function Main({ invitationId }: { invitationId: string }) {
1515
const router = useRouter();
1616
const pathname = usePathname();
1717
const searchParams = useSearchParams();
18-
const token = useSearchParams().get('token');
18+
const token = searchParams?.get('token') ?? null;
1919
const { data: invitation, isLoading: loadingInvitation, error: getInvitationError } = api.invitation.getWithoutToken.useQuery({
2020
id: invitationId,
2121
});
@@ -35,7 +35,7 @@ export function Main({ invitationId }: { invitationId: string }) {
3535
// Clear analytics/feedback identities before signing out
3636
void resetTelemetry();
3737
await supabase.auth.signOut();
38-
const currentUrl = `${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
38+
const currentUrl = `${pathname}${searchParams && searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
3939
router.push(`${Routes.LOGIN}?${getReturnUrlQueryParam(currentUrl)}`);
4040
}
4141

apps/web/client/src/app/login/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export default function LoginPage() {
1515
const isDev = process.env.NODE_ENV === 'development';
1616
const t = useTranslations();
1717
const backgroundUrl = useGetBackground('login');
18-
const returnUrl = useSearchParams().get(LocalForageKeys.RETURN_URL);
18+
const searchParams = useSearchParams();
19+
const returnUrl = searchParams?.get(LocalForageKeys.RETURN_URL) ?? null;
1920

2021
return (
2122
<div className="flex h-screen w-screen justify-center">

apps/web/client/src/components/ui/avatar-dropdown/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const CurrentUserAvatar = ({ className }: { className?: string }) => {
3636
// Clear analytics/feedback identities before signing out
3737
void resetTelemetry();
3838
await supabase.auth.signOut();
39-
const returnUrl = `${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
39+
const returnUrl = `${pathname}${searchParams && searchParams.toString() ? `?${searchParams.toString()}` : ''}`;
4040
router.push(`${Routes.LOGIN}?${getReturnUrlQueryParam(returnUrl)}`);
4141
};
4242

apps/web/client/test/cache/file-cache.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('FileCacheManager', () => {
1818
let mockWriteFile: any;
1919

2020
beforeEach(async () => {
21-
fileCacheManager = new FileCacheManager();
21+
fileCacheManager = new FileCacheManager('test-project', 'test-branch');
2222
await fileCacheManager.init();
2323

2424
mockReadFile = mock(async (path: string): Promise<SandboxFile | null> => {
@@ -73,11 +73,11 @@ describe('FileCacheManager', () => {
7373
expect(retrieved).toEqual(binaryFile);
7474
});
7575

76-
test('should handle files with null content', () => {
76+
test('should handle files with empty content', () => {
7777
const emptyFile: SandboxFile = {
7878
type: 'text',
7979
path: 'empty.tsx',
80-
content: null
80+
content: ''
8181
};
8282

8383
fileCacheManager.setFile(emptyFile);
@@ -138,8 +138,8 @@ describe('FileCacheManager', () => {
138138
};
139139

140140
const unloadedFile: SandboxFile = {
141-
type: 'text',
142-
path: 'unloaded.tsx',
141+
type: 'binary',
142+
path: 'unloaded.png',
143143
content: null
144144
};
145145

apps/web/client/test/messages.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe('Localization Files', () => {
228228
const matches = [...value.matchAll(placeholderRegex)];
229229

230230
if (matches.length > 0) {
231-
const placeholders = new Set(matches.map((m) => m[1]));
231+
const placeholders = new Set(matches.map((m) => m[1]).filter((p): p is string => p !== undefined));
232232
keysWithPlaceholders.set(key, placeholders);
233233
}
234234
}
@@ -251,7 +251,7 @@ describe('Localization Files', () => {
251251
} // Already checked in previous tests
252252

253253
const matches = [...value.matchAll(placeholderRegex)];
254-
const actualPlaceholders = new Set(matches.map((m) => m[1]));
254+
const actualPlaceholders = new Set(matches.map((m) => m[1]).filter((p): p is string => p !== undefined));
255255

256256
const missing = [...refPlaceholders].filter((p) => !actualPlaceholders.has(p));
257257
const extra = [...actualPlaceholders].filter((p) => !refPlaceholders.has(p));

apps/web/client/test/pages/helper.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('scanAppDirectory', () => {
1616
readDir: mock((dir: string) => {
1717
if (dir === 'app') {
1818
return Promise.resolve([
19-
{ name: 'page.tsx', type: 'file', isSymlink: false }
19+
{ name: 'page.tsx', type: 'file' as const, isSymlink: false }
2020
]);
2121
}
2222
return Promise.resolve([]);
@@ -29,16 +29,16 @@ describe('scanAppDirectory', () => {
2929
};
3030

3131
const result = await scanAppDirectory(mockSandboxManager as any, 'app');
32-
32+
3333
expect(result).toHaveLength(1);
34-
expect(result[0].name).toBe('Home'); // Root page is named "Home"
35-
expect(result[0].path).toBe('/'); // Root page has path "/"
34+
expect(result[0]?.name).toBe('Home'); // Root page is named "Home"
35+
expect(result[0]?.path).toBe('/'); // Root page has path "/"
3636
});
3737

3838
test('should handle directory with only page file', async () => {
3939
const mockSandboxManager: MockSandboxManager = {
4040
readDir: mock(() => Promise.resolve([
41-
{ name: 'page.tsx', type: 'file', isSymlink: false }
41+
{ name: 'page.tsx', type: 'file' as const, isSymlink: false }
4242
])),
4343
readFile: mock((path: string) => {
4444
return Promise.resolve('export default function Page() { return <div>Test</div>; }');
@@ -47,17 +47,17 @@ describe('scanAppDirectory', () => {
4747
};
4848

4949
const result = await scanAppDirectory(mockSandboxManager as any, 'app');
50-
50+
5151
expect(result).toHaveLength(1);
52-
expect(result[0].name).toBe('Home');
53-
expect(result[0].path).toBe('/');
52+
expect(result[0]?.name).toBe('Home');
53+
expect(result[0]?.path).toBe('/');
5454
});
5555

5656
test('should handle directories without page files', async () => {
5757
const mockSandboxManager: MockSandboxManager = {
5858
readDir: mock(() => Promise.resolve([
59-
{ name: 'components', type: 'directory', isSymlink: false },
60-
{ name: 'utils', type: 'directory', isSymlink: false }
59+
{ name: 'components', type: 'directory' as const, isSymlink: false },
60+
{ name: 'utils', type: 'directory' as const, isSymlink: false }
6161
])),
6262
readFile: mock((path: string) => {
6363
return Promise.resolve('export default function Page() { return <div>Test</div>; }');
@@ -66,7 +66,7 @@ describe('scanAppDirectory', () => {
6666
};
6767

6868
const result = await scanAppDirectory(mockSandboxManager as any, 'app');
69-
69+
7070
// Should return empty array when no page files found
7171
expect(result).toEqual([]);
7272
});
@@ -88,7 +88,7 @@ describe('scanAppDirectory', () => {
8888
test('should handle file read errors gracefully', async () => {
8989
const mockSandboxManager: MockSandboxManager = {
9090
readDir: mock(() => Promise.resolve([
91-
{ name: 'page.tsx', type: 'file', isSymlink: false }
91+
{ name: 'page.tsx', type: 'file' as const, isSymlink: false }
9292
])),
9393
readFile: mock(() => {
9494
throw new Error('File read error');
@@ -97,11 +97,11 @@ describe('scanAppDirectory', () => {
9797
};
9898

9999
const result = await scanAppDirectory(mockSandboxManager as any, 'app');
100-
100+
101101
// Should still return page structure even if file reading fails
102102
expect(result).toHaveLength(1);
103-
expect(result[0].name).toBe('Home'); // Root page is named "Home"
104-
expect(result[0].path).toBe('/'); // Root page path
103+
expect(result[0]?.name).toBe('Home'); // Root page is named "Home"
104+
expect(result[0]?.path).toBe('/'); // Root page path
105105
});
106106

107107
test('should handle directory read errors', async () => {

apps/web/client/tsconfig.json

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@
44
"baseUrl": ".",
55
"allowArbitraryExtensions": true,
66
"paths": {
7-
"@/*": [
8-
"./src/*"
9-
],
10-
"/*": [
11-
"./*"
12-
],
13-
"~/*": [
14-
"./src/*"
15-
]
7+
"@/*": ["./src/*"],
8+
"/*": ["./*"],
9+
"~/*": ["./src/*"]
1610
}
1711
},
1812
"include": [
1913
"src",
20-
"tests",
14+
"test",
15+
"next-env.d.ts",
16+
"next.config.ts",
2117
".next/types/**/*.ts",
22-
"messages/en.d.json.ts",
23-
"../../../packages/file-system/src/code-fs.ts"
18+
"messages/en.d.json.ts"
2419
],
25-
"exclude": [
26-
"node_modules",
27-
".next"
28-
]
29-
}
20+
"exclude": ["node_modules", ".next"]
21+
}

0 commit comments

Comments
 (0)