Skip to content

Commit aa18d08

Browse files
committed
feat(demo): enrich demo data and update screenshots
Expand auth.ts diff to fill viewport without scrolling (2 hunks with login/logout methods), add 3rd comment (suggestion, multi-line), increase file list to 8 entries, and replace all screenshots with updated captures.
1 parent 7345f1c commit aa18d08

6 files changed

Lines changed: 113 additions & 31 deletions

File tree

docs/screenshot-dark-split.png

208 KB
Loading

docs/screenshot-dark.png

219 KB
Loading

docs/screenshot-light-split.png

213 KB
Loading

docs/screenshot-light.png

230 KB
Loading

site/screenshot-dark.png

219 KB
Loading

src/lib/demo/demoData.ts

Lines changed: 113 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ export function createDemoStatus(): RepositoryStatus {
2020
{ path: 'src/auth/AuthProvider.tsx', status: 'modified', staged: true },
2121
{ path: 'src/auth/useAuth.ts', status: 'modified', staged: true },
2222
{ path: 'src/components/LoginForm.tsx', status: 'added', staged: true },
23+
{ path: 'src/hooks/useSession.ts', status: 'added', staged: true },
2324
{ path: 'src/api/auth.ts', status: 'modified', staged: false },
2425
{ path: 'src/types/user.ts', status: 'added', staged: false },
26+
{ path: 'src/middleware/withAuth.ts', status: 'added', staged: false },
2527
{ path: 'README.md', status: 'modified', staged: false },
2628
],
27-
stagedCount: 3,
28-
unstagedCount: 3,
29+
stagedCount: 4,
30+
unstagedCount: 4,
2931
};
3032
}
3133

32-
// Sample diff for AuthProvider.tsx
34+
// Sample diff for the selected file
3335
export function createDemoFileDiff(file: FileEntry): FileDiff {
3436
const diffs: Record<string, FileDiff> = {
3537
'src/auth/AuthProvider.tsx': {
@@ -216,81 +218,148 @@ export function createDemoFileDiff(file: FileEntry): FileDiff {
216218
status: 'modified',
217219
hunks: [
218220
{
219-
header: '@@ -8,6 +8,22 @@',
220-
oldStart: 8,
221-
oldLines: 6,
222-
newStart: 8,
223-
newLines: 22,
221+
header: '@@ -1,4 +1,7 @@',
222+
oldStart: 1,
223+
oldLines: 4,
224+
newStart: 1,
225+
newLines: 7,
224226
lines: [
225227
{
226228
lineType: 'context',
229+
content: "import type { LoginResponse } from '../types/user';",
230+
oldLineNo: 1,
231+
newLineNo: 1,
232+
},
233+
{
234+
lineType: 'addition',
235+
content: "import type { TokenPair, User } from '../types/user';",
236+
newLineNo: 2,
237+
},
238+
{ lineType: 'context', content: '', oldLineNo: 2, newLineNo: 3 },
239+
{
240+
lineType: 'deletion',
241+
content: 'const API_URL = process.env.API_URL;',
242+
oldLineNo: 3,
243+
},
244+
{
245+
lineType: 'addition',
227246
content: 'const API_URL = import.meta.env.VITE_API_URL;',
228-
oldLineNo: 8,
229-
newLineNo: 8,
247+
newLineNo: 4,
248+
},
249+
{
250+
lineType: 'addition',
251+
content: "const TOKEN_KEY = 'auth_token';",
252+
newLineNo: 5,
253+
},
254+
{
255+
lineType: 'addition',
256+
content: "const REFRESH_KEY = 'refresh_token';",
257+
newLineNo: 6,
230258
},
231-
{ lineType: 'context', content: '', oldLineNo: 9, newLineNo: 9 },
259+
{ lineType: 'context', content: '', oldLineNo: 4, newLineNo: 7 },
260+
],
261+
},
262+
{
263+
header: '@@ -5,3 +8,20 @@',
264+
oldStart: 5,
265+
oldLines: 3,
266+
newStart: 8,
267+
newLines: 20,
268+
lines: [
232269
{
233270
lineType: 'context',
234271
content: 'export const authApi = {',
235-
oldLineNo: 10,
236-
newLineNo: 10,
272+
oldLineNo: 5,
273+
newLineNo: 8,
274+
},
275+
{
276+
lineType: 'deletion',
277+
content: ' // TODO: implement auth methods',
278+
oldLineNo: 6,
237279
},
238280
{
239281
lineType: 'addition',
240-
content: ' async login(email: string, password: string) {',
241-
newLineNo: 11,
282+
content:
283+
' async login(email: string, password: string): Promise<LoginResponse> {',
284+
newLineNo: 9,
242285
},
243286
{
244287
lineType: 'addition',
245288
content:
246289
' const response = await fetch(`${API_URL}/auth/login`, {',
247-
newLineNo: 12,
290+
newLineNo: 10,
248291
},
249292
{
250293
lineType: 'addition',
251294
content: " method: 'POST',",
252-
newLineNo: 13,
295+
newLineNo: 11,
253296
},
254297
{
255298
lineType: 'addition',
256299
content: " headers: { 'Content-Type': 'application/json' },",
257-
newLineNo: 14,
300+
newLineNo: 12,
258301
},
259302
{
260303
lineType: 'addition',
261304
content: ' body: JSON.stringify({ email, password }),',
262-
newLineNo: 15,
305+
newLineNo: 13,
263306
},
264-
{ lineType: 'addition', content: ' });', newLineNo: 16 },
307+
{ lineType: 'addition', content: ' });', newLineNo: 14 },
265308
{
266309
lineType: 'addition',
267310
content: " if (!response.ok) throw new Error('Login failed');",
311+
newLineNo: 15,
312+
},
313+
{
314+
lineType: 'addition',
315+
content: ' const data = await response.json();',
316+
newLineNo: 16,
317+
},
318+
{
319+
lineType: 'addition',
320+
content: ' localStorage.setItem(TOKEN_KEY, data.tokens.access);',
268321
newLineNo: 17,
269322
},
270323
{
271324
lineType: 'addition',
272-
content: ' return response.json();',
325+
content:
326+
' localStorage.setItem(REFRESH_KEY, data.tokens.refresh);',
273327
newLineNo: 18,
274328
},
275-
{ lineType: 'addition', content: ' },', newLineNo: 19 },
276-
{ lineType: 'addition', content: '', newLineNo: 20 },
277329
{
278330
lineType: 'addition',
279-
content: ' async logout() {',
280-
newLineNo: 21,
331+
content: ' return data;',
332+
newLineNo: 19,
333+
},
334+
{ lineType: 'addition', content: ' },', newLineNo: 20 },
335+
{ lineType: 'addition', content: '', newLineNo: 21 },
336+
{
337+
lineType: 'addition',
338+
content: ' async logout(): Promise<void> {',
339+
newLineNo: 22,
281340
},
282341
{
283342
lineType: 'addition',
284343
content:
285344
" await fetch(`${API_URL}/auth/logout`, { method: 'POST' });",
286-
newLineNo: 22,
345+
newLineNo: 23,
346+
},
347+
{
348+
lineType: 'addition',
349+
content: ' localStorage.removeItem(TOKEN_KEY);',
350+
newLineNo: 24,
351+
},
352+
{
353+
lineType: 'addition',
354+
content: ' localStorage.removeItem(REFRESH_KEY);',
355+
newLineNo: 25,
287356
},
288-
{ lineType: 'addition', content: ' },', newLineNo: 23 },
357+
{ lineType: 'addition', content: ' },', newLineNo: 26 },
289358
{
290359
lineType: 'context',
291360
content: '};',
292-
oldLineNo: 11,
293-
newLineNo: 24,
361+
oldLineNo: 7,
362+
newLineNo: 27,
294363
},
295364
],
296365
},
@@ -415,12 +484,25 @@ export function createDemoComments(): Record<string, Comment[]> {
415484
{
416485
id: 'demo-2',
417486
filePath: 'src/api/auth.ts',
418-
startLine: 17,
419-
endLine: 17,
487+
startLine: 15,
488+
endLine: 15,
420489
content:
421490
'Should we include more specific error messages based on the response status code?',
422491
category: 'question',
423492
codeSnippet: " if (!response.ok) throw new Error('Login failed');",
493+
createdAt: now - 120000,
494+
isOld: false,
495+
},
496+
{
497+
id: 'demo-3',
498+
filePath: 'src/api/auth.ts',
499+
startLine: 17,
500+
endLine: 18,
501+
content:
502+
'Consider using httpOnly cookies instead of localStorage for tokens — localStorage is vulnerable to XSS attacks.',
503+
category: 'suggestion',
504+
codeSnippet:
505+
' localStorage.setItem(TOKEN_KEY, data.tokens.access);\n localStorage.setItem(REFRESH_KEY, data.tokens.refresh);',
424506
createdAt: now - 50000,
425507
isOld: false,
426508
},

0 commit comments

Comments
 (0)