Skip to content

Commit 856f3c5

Browse files
committed
starting point
1 parent b9e79d3 commit 856f3c5

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

browser-extension/tests/playground/claude.tsx

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//import { DraftStats } from '@/lib/enhancers/draftStats'
2+
import { CommentSpot } from '@/lib/enhancer'
3+
import { DraftStats } from '@/lib/enhancers/draftStats'
24
import { GitPullRequestIcon, IssueOpenedIcon } from '@primer/octicons-react'
35
import { Clock, Code, Filter, Image, Link, Search, TextSelect } from 'lucide-react'
46
import { useMemo, useState } from 'react'
@@ -21,29 +23,37 @@ export interface GitHubPRAddCommentSpot extends CommentSpot {
2123
*/
2224

2325
type DraftType = 'PR' | 'ISSUE' | 'REDDIT'
26+
type DraftState = 'EDITING' | 'ABANDONED' | 'SENT'
27+
type TabState = 'OPEN_NOW' | 'CLOSED'
2428

25-
interface BaseDraft {
26-
id: string
29+
interface BaseDraft extends CommentSpot {
2730
charCount: number
2831
codeCount: number
2932
content: string
3033
imageCount: number
3134
type: DraftType
3235
lastEdit: number
3336
linkCount: number
34-
title: string
35-
url: string
3637
}
3738

3839
interface GitHubDraft extends BaseDraft {
39-
repoSlug: string
40+
title: string
41+
slug: string
4042
number: number
4143
}
4244

4345
interface RedditDraft extends BaseDraft {
46+
title: string
4447
subreddit: string
4548
}
4649

50+
interface LatestDraft {
51+
spot: BaseDraft,
52+
draft: string,
53+
time: number
54+
draftStats: DraftStats
55+
}
56+
4757
type Draft = GitHubDraft | RedditDraft
4858

4959
const isGitHubDraft = (draft: Draft): draft is GitHubDraft => {
@@ -60,74 +70,69 @@ const generateMockDrafts = (): Draft[] => [
6070
codeCount: 3,
6171
content:
6272
'This PR addresses the memory leak issue reported in #1233. The problem was caused by event listeners not being properly disposed...',
63-
id: '1',
73+
unique_key: '1',
6474
imageCount: 2,
6575
lastEdit: Date.now() - 1000 * 60 * 30,
6676
linkCount: 2,
6777
number: 1234,
68-
repoSlug: 'microsoft/vscode',
78+
slug: 'microsoft/vscode',
6979
title: 'Fix memory leak in extension host',
7080
type: 'PR',
71-
url: 'https://github.com/microsoft/vscode/pull/1234',
7281
} satisfies GitHubDraft,
7382
{
7483
charCount: 180,
7584
codeCount: 0,
7685
content:
7786
"I've been using GitLens for years and it's absolutely essential for my workflow. The inline blame annotations are incredibly helpful when...",
78-
id: '2',
87+
unique_key: '2',
7988
imageCount: 0,
8089
lastEdit: Date.now() - 1000 * 60 * 60 * 2,
8190
linkCount: 1,
8291
subreddit: 'programming',
8392
title: "Re: What's your favorite VS Code extension?",
8493
type: 'REDDIT',
85-
url: 'https://reddit.com/r/programming/comments/abc123',
8694
} satisfies RedditDraft,
8795
{
8896
charCount: 456,
8997
codeCount: 1,
9098
content:
9199
"When using useEffect with async functions, the cleanup function doesn't seem to be called correctly in certain edge cases...",
92-
id: '3',
100+
unique_key: '3',
93101
imageCount: 0,
94102
lastEdit: Date.now() - 1000 * 60 * 60 * 5,
95103
linkCount: 0,
96104
number: 5678,
97-
repoSlug: 'facebook/react',
105+
slug: 'facebook/react',
98106
title: 'Unexpected behavior with useEffect cleanup',
99107
type: 'ISSUE',
100-
url: 'https://github.com/facebook/react/issues/5678',
101108
} satisfies GitHubDraft,
102109
{
103110
charCount: 322,
104111
codeCount: 0,
105112
content:
106113
'LGTM! Just a few minor suggestions about the examples in the routing section. Consider adding more context about...',
107-
id: '4',
114+
unique_key: '4',
108115
imageCount: 4,
109116
lastEdit: Date.now() - 1000 * 60 * 60 * 24,
110117
linkCount: 3,
111118
number: 9012,
112-
repoSlug: 'vercel/next.js',
119+
slug: 'vercel/next.js',
113120
title: 'Update routing documentation',
114121
type: 'PR',
115-
url: 'https://github.com/vercel/next.js/pull/9012',
116122
} satisfies GitHubDraft,
117123
{
118124
charCount: 678,
119125
codeCount: 7,
120126
content:
121127
'This PR implements ESM support in worker threads as discussed in the last TSC meeting. The implementation follows...',
122-
id: '5',
128+
unique_key: '5',
123129
imageCount: 1,
124130
lastEdit: Date.now() - 1000 * 60 * 60 * 48,
125131
linkCount: 5,
126132
number: 3456,
127-
repoSlug: 'nodejs/node',
133+
slug: 'nodejs/node',
128134
title: 'Add support for ESM in worker threads',
129135
type: 'PR',
130-
url: 'https://github.com/nodejs/node/pull/3456',
131136
} satisfies GitHubDraft,
132137
]
133138

@@ -204,7 +209,7 @@ export const ClaudePrototype = () => {
204209
if (selectedIds.size === filteredDrafts.length && filteredDrafts.length > 0) {
205210
setSelectedIds(new Set())
206211
} else {
207-
setSelectedIds(new Set(filteredDrafts.map((d) => d.id)))
212+
setSelectedIds(new Set(filteredDrafts.map((d) => d.unique_key)))
208213
}
209214
}
210215

@@ -421,12 +426,12 @@ function commentRow(
421426
_handleTrash: (draft: { charCount: number; id: string }) => void,
422427
) {
423428
return (
424-
<tr key={draft.id} className='hover:bg-gray-50'>
429+
<tr key={draft.unique_key} className='hover:bg-gray-50'>
425430
<td className='px-3 py-3'>
426431
<input
427432
type='checkbox'
428-
checked={selectedIds.has(draft.id)}
429-
onChange={() => toggleSelection(draft.id)}
433+
checked={selectedIds.has(draft.unique_key)}
434+
onChange={() => toggleSelection(draft.unique_key)}
430435
className='rounded'
431436
/>
432437
</td>
@@ -451,7 +456,7 @@ function commentRow(
451456
<>
452457
#{draft.number}
453458
<a href='TODO' className='hover:underline truncate'>
454-
{draft.repoSlug}
459+
{draft.slug}
455460
</a>
456461
</>
457462
)}

0 commit comments

Comments
 (0)