1+ //import { DraftStats } from '@/lib/enhancers/draftStats'
12import { GitPullRequestIcon , IssueOpenedIcon } from '@primer/octicons-react'
23import {
34 ArrowDown ,
@@ -13,96 +14,132 @@ import {
1314} from 'lucide-react'
1415import { useMemo , useState } from 'react'
1516
16- // Mock data generator
17- const generateMockDrafts = ( ) => [
17+ /*
18+ interface GitHubIssueAddCommentSpot extends CommentSpot {
19+ type: 'GH_ISSUE_ADD_COMMENT'
20+ domain: 'string'
21+ slug: string // owner/repo
22+ number: number // issue number, undefined for new issues
23+ title: string
24+ }
25+ export interface GitHubPRAddCommentSpot extends CommentSpot {
26+ type: 'GH_PR_ADD_COMMENT' // Override to narrow from string to specific union
27+ domain: string
28+ slug: string // owner/repo
29+ number: number // issue/PR number, undefined for new issues and PRs
30+ title: string
31+ }
32+ */
33+
34+ type DraftType = 'PR' | 'ISSUE' | 'REDDIT'
35+
36+ interface BaseDraft {
37+ id : string
38+ charCount : number
39+ codeCount : number
40+ content : string
41+ imageCount : number
42+ type : DraftType
43+ lastEdit : number
44+ linkCount : number
45+ title : string
46+ url : string
47+ }
48+
49+ interface GitHubDraft extends BaseDraft {
50+ repoSlug : string
51+ number : number
52+ }
53+
54+ interface RedditDraft extends BaseDraft {
55+ subreddit : string
56+ }
57+
58+ type Draft = GitHubDraft | RedditDraft
59+
60+ const isGitHubDraft = ( draft : Draft ) : draft is GitHubDraft => {
61+ return draft . type === 'PR' || draft . type === 'ISSUE'
62+ }
63+
64+ const isRedditDraft = ( draft : Draft ) : draft is RedditDraft => {
65+ return draft . type === 'REDDIT'
66+ }
67+
68+ const generateMockDrafts = ( ) : Draft [ ] => [
1869 {
1970 charCount : 245 ,
2071 codeCount : 3 ,
2172 content :
2273 'This PR addresses the memory leak issue reported in #1233. The problem was caused by event listeners not being properly disposed...' ,
2374 id : '1' ,
2475 imageCount : 2 ,
25- kind : 'PR' ,
2676 lastEdit : Date . now ( ) - 1000 * 60 * 30 ,
2777 linkCount : 2 ,
2878 number : 1234 ,
29- platform : 'GitHub' ,
30- private : true ,
3179 repoSlug : 'microsoft/vscode' ,
32- state : { type : 'open' } ,
3380 title : 'Fix memory leak in extension host' ,
81+ type : 'PR' ,
3482 url : 'https://github.com/microsoft/vscode/pull/1234' ,
35- } ,
83+ } satisfies GitHubDraft ,
3684 {
3785 charCount : 180 ,
3886 codeCount : 0 ,
3987 content :
4088 "I've been using GitLens for years and it's absolutely essential for my workflow. The inline blame annotations are incredibly helpful when..." ,
4189 id : '2' ,
4290 imageCount : 0 ,
43- kind : 'Comment' ,
4491 lastEdit : Date . now ( ) - 1000 * 60 * 60 * 2 ,
4592 linkCount : 1 ,
46- private : false ,
47- repoSlug : 'r/programming' ,
48- state : { type : 'post' } ,
93+ subreddit : 'programming' ,
4994 title : "Re: What's your favorite VS Code extension?" ,
95+ type : 'REDDIT' ,
5096 url : 'https://reddit.com/r/programming/comments/abc123' ,
51- } ,
97+ } satisfies RedditDraft ,
5298 {
5399 charCount : 456 ,
54100 codeCount : 1 ,
55101 content :
56102 "When using useEffect with async functions, the cleanup function doesn't seem to be called correctly in certain edge cases..." ,
57103 id : '3' ,
58104 imageCount : 0 ,
59- kind : 'Issue' ,
60105 lastEdit : Date . now ( ) - 1000 * 60 * 60 * 5 ,
61106 linkCount : 0 ,
62107 number : 5678 ,
63- platform : 'GitHub' ,
64- private : false ,
65108 repoSlug : 'facebook/react' ,
66- state : { type : 'open' } ,
67109 title : 'Unexpected behavior with useEffect cleanup' ,
110+ type : 'ISSUE' ,
68111 url : 'https://github.com/facebook/react/issues/5678' ,
69- } ,
112+ } satisfies GitHubDraft ,
70113 {
71114 charCount : 322 ,
72115 codeCount : 0 ,
73116 content :
74117 'LGTM! Just a few minor suggestions about the examples in the routing section. Consider adding more context about...' ,
75118 id : '4' ,
76119 imageCount : 4 ,
77- kind : 'PR' ,
78120 lastEdit : Date . now ( ) - 1000 * 60 * 60 * 24 ,
79121 linkCount : 3 ,
80122 number : 9012 ,
81- platform : 'GitHub' ,
82- private : true ,
83123 repoSlug : 'vercel/next.js' ,
84- state : { type : 'merged' } ,
85124 title : 'Update routing documentation' ,
125+ type : 'PR' ,
86126 url : 'https://github.com/vercel/next.js/pull/9012' ,
87- } ,
127+ } satisfies GitHubDraft ,
88128 {
89129 charCount : 678 ,
90130 codeCount : 7 ,
91131 content :
92132 'This PR implements ESM support in worker threads as discussed in the last TSC meeting. The implementation follows...' ,
93133 id : '5' ,
94134 imageCount : 1 ,
95- kind : 'PR' ,
96135 lastEdit : Date . now ( ) - 1000 * 60 * 60 * 48 ,
97136 linkCount : 5 ,
98137 number : 3456 ,
99- platform : 'GitHub' ,
100- private : false ,
101138 repoSlug : 'nodejs/node' ,
102- state : { type : 'closed' } ,
103139 title : 'Add support for ESM in worker threads' ,
140+ type : 'PR' ,
104141 url : 'https://github.com/nodejs/node/pull/3456' ,
105- } ,
142+ } satisfies GitHubDraft ,
106143]
107144
108145// Helper function for relative time
@@ -148,12 +185,8 @@ export const ClaudePrototype = () => {
148185 }
149186 if ( searchQuery ) {
150187 const query = searchQuery . toLowerCase ( )
151- filtered = filtered . filter (
152- ( d ) =>
153- d . title . toLowerCase ( ) . includes ( query ) ||
154- d . content . toLowerCase ( ) . includes ( query ) ||
155- d . repoSlug . toLowerCase ( ) . includes ( query ) ||
156- d . number ?. toString ( ) . includes ( query ) ,
188+ filtered = filtered . filter ( ( d ) =>
189+ Object . values ( d ) . some ( ( value ) => String ( value ) . toLowerCase ( ) . includes ( query ) ) ,
157190 )
158191 }
159192 // Sort
@@ -418,27 +451,32 @@ export const ClaudePrototype = () => {
418451 < div className = 'flex items-center justify-between gap-1.5 text-xs text-gray-600' >
419452 < div className = 'flex items-center gap-1.5 min-w-0 flex-1' >
420453 < span className = 'w-4 h-4 flex items-center justify-center flex-shrink-0' >
421- { draft . platform === 'GitHub' ? (
422- draft . kind === 'PR' ? (
423- < GitPullRequestIcon size = { 16 } />
424- ) : draft . kind === 'Issue' ? (
425- < IssueOpenedIcon size = { 16 } />
426- ) : (
427- '🐙'
428- )
429- ) : (
454+ { draft . type === 'PR' && < GitPullRequestIcon size = { 16 } /> }
455+ { draft . type === 'ISSUE' && < IssueOpenedIcon size = { 16 } /> }
456+ { draft . type === 'REDDIT' && (
430457 < img
431458 src = 'https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=128& frame = 1 & auto = webp & s = 400 b33e7080aa4996c405a96b3872a12f0e3b68d '
432459 alt = 'Reddit'
433460 className = 'w-4 h-4 rounded-full'
434461 />
435462 ) }
436463 </ span >
437- < a href = { draft . url } className = 'hover:underline truncate' >
438- { draft . repoSlug . startsWith ( 'r/' )
439- ? draft . repoSlug
440- : `#${ draft . number } ${ draft . repoSlug } ` }
441- </ a >
464+ { }
465+ { isGitHubDraft ( draft ) && (
466+ < >
467+ < a href = { 'TODO' } className = 'hover:underline' >
468+ #{ draft . number }
469+ </ a > { ' ' }
470+ < a href = 'TODO' className = 'hover:underline truncate' >
471+ { draft . repoSlug }
472+ </ a >
473+ </ >
474+ ) }
475+ { isRedditDraft ( draft ) && (
476+ < a href = { 'TODO' } className = 'hover:underline truncate' >
477+ r/{ draft . subreddit }
478+ </ a >
479+ ) }
442480 </ div >
443481 < div className = 'flex items-center gap-1 flex-shrink-0' >
444482 { draft . linkCount > 0 && (
0 commit comments