Skip to content

Commit d1132b1

Browse files
committed
Move our claude prototype to the real actual CommentSpots we're working with.
1 parent 666c3ab commit d1132b1

File tree

5 files changed

+29
-37
lines changed

5 files changed

+29
-37
lines changed

browser-extension/src/lib/enhancers/github/githubIssueAddComment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { githubHighlighter } from './githubHighlighter'
77

88
export interface GitHubIssueAddCommentSpot extends CommentSpot {
99
type: 'GH_ISSUE_ADD_COMMENT'
10+
title: string
1011
domain: string
1112
slug: string // owner/repo
1213
number: number // issue number, undefined for new issues
@@ -32,10 +33,12 @@ export class GitHubIssueAddCommentEnhancer implements CommentEnhancer<GitHubIssu
3233
const slug = `${owner}/${repo}`
3334
const number = parseInt(numberStr!, 10)
3435
const unique_key = `github.com:${slug}:${number}`
36+
const title = 'TODO_TITLE'
3537
return {
3638
domain: 'github.com',
3739
number,
3840
slug,
41+
title,
3942
type: 'GH_ISSUE_ADD_COMMENT',
4043
unique_key,
4144
}

browser-extension/src/lib/enhancers/github/githubPRAddComment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { githubHighlighter } from './githubHighlighter'
77

88
export interface GitHubPRAddCommentSpot extends CommentSpot {
99
type: 'GH_PR_ADD_COMMENT' // Override to narrow from string to specific union
10+
title: string
1011
domain: string
1112
slug: string // owner/repo
1213
number: number // issue/PR number, undefined for new issues and PRs
@@ -36,10 +37,12 @@ export class GitHubPRAddCommentEnhancer implements CommentEnhancer<GitHubPRAddCo
3637
const slug = `${owner}/${repo}`
3738
const number = parseInt(numberStr!, 10)
3839
const unique_key = `github.com:${slug}:${number}`
40+
const title = 'TODO_TITLE'
3941
return {
4042
domain: 'github.com',
4143
number,
4244
slug,
45+
title,
4346
type: 'GH_PR_ADD_COMMENT',
4447
unique_key,
4548
}

browser-extension/tests/lib/enhancers/github.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('github', () => {
1717
"domain": "github.com",
1818
"number": 517,
1919
"slug": "diffplug/selfie",
20+
"title": "TODO_TITLE",
2021
"type": "GH_PR_ADD_COMMENT",
2122
"unique_key": "github.com:diffplug/selfie:517",
2223
}
@@ -47,6 +48,7 @@ describe('github', () => {
4748
"domain": "github.com",
4849
"number": 523,
4950
"slug": "diffplug/selfie",
51+
"title": "TODO_TITLE",
5052
"type": "GH_ISSUE_ADD_COMMENT",
5153
"unique_key": "github.com:diffplug/selfie:523",
5254
}

browser-extension/tests/playground/claude.tsx

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { useMemo, useState } from 'react'
1919
import { twMerge } from 'tailwind-merge'
2020
import type { CommentSpot } from '@/lib/enhancer'
2121
import type { DraftStats } from '@/lib/enhancers/draftStats'
22+
import type { GitHubIssueAddCommentSpot } from '@/lib/enhancers/github/githubIssueAddComment'
23+
import type { GitHubPRAddCommentSpot } from '@/lib/enhancers/github/githubPRAddComment'
2224

2325
interface FilterState {
2426
sentFilter: 'both' | 'sent' | 'unsent'
@@ -146,30 +148,6 @@ const MultiSegment = <T,>({ segments, value, onValueChange }: MultiSegmentProps<
146148
)
147149
}
148150

149-
/*
150-
interface GitHubIssueAddCommentSpot extends CommentSpot {
151-
type: 'GH_ISSUE_ADD_COMMENT'
152-
domain: 'string'
153-
slug: string // owner/repo
154-
number: number // issue number, undefined for new issues
155-
title: string
156-
}
157-
export interface GitHubPRAddCommentSpot extends CommentSpot {
158-
type: 'GH_PR_ADD_COMMENT' // Override to narrow from string to specific union
159-
domain: string
160-
slug: string // owner/repo
161-
number: number // issue/PR number, undefined for new issues and PRs
162-
title: string
163-
}
164-
*/
165-
166-
interface GitHubSpot extends CommentSpot {
167-
title: string
168-
slug: string
169-
number: number
170-
type: 'PR' | 'ISSUE'
171-
}
172-
173151
interface RedditSpot extends CommentSpot {
174152
title: string
175153
subreddit: string
@@ -190,10 +168,10 @@ interface CommentTableRow {
190168
isTrashed: boolean
191169
}
192170

193-
type GitHubOrReddit = GitHubSpot | RedditSpot
171+
type GitHubOrReddit = GitHubIssueAddCommentSpot | GitHubPRAddCommentSpot | RedditSpot
194172

195-
const isGitHubDraft = (spot: GitHubOrReddit): spot is GitHubSpot => {
196-
return spot.type === 'PR' || spot.type === 'ISSUE'
173+
const isGitHubDraft = (spot: GitHubOrReddit): spot is GitHubIssueAddCommentSpot => {
174+
return spot.type === 'GH_PR_ADD_COMMENT' || spot.type === 'GH_ISSUE_ADD_COMMENT'
197175
}
198176

199177
const isRedditDraft = (spot: GitHubOrReddit): spot is RedditSpot => {
@@ -227,12 +205,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
227205
time: Date.now() - 1000 * 60 * 30,
228206
},
229207
spot: {
208+
domain: 'github.com',
230209
number: 1234,
231210
slug: 'microsoft/vscode',
232211
title: "Fix memory leak in extension host (why is this so hard! It's been months!)",
233-
type: 'PR',
212+
type: 'GH_PR_ADD_COMMENT',
234213
unique_key: '1',
235-
} satisfies GitHubSpot,
214+
} satisfies GitHubPRAddCommentSpot,
236215
},
237216
{
238217
isOpenTab: false,
@@ -277,12 +256,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
277256
time: Date.now() - 1000 * 60 * 60 * 5,
278257
},
279258
spot: {
259+
domain: 'github.com',
280260
number: 5678,
281261
slug: 'facebook/react',
282262
title: 'Unexpected behavior with useEffect cleanup',
283-
type: 'ISSUE',
263+
type: 'GH_ISSUE_ADD_COMMENT',
284264
unique_key: '3',
285-
} satisfies GitHubSpot,
265+
} satisfies GitHubIssueAddCommentSpot,
286266
},
287267
{
288268
isOpenTab: false,
@@ -312,12 +292,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
312292
time: Date.now() - 1000 * 60 * 60 * 24,
313293
},
314294
spot: {
295+
domain: 'github',
315296
number: 9012,
316297
slug: 'vercel/next.js',
317298
title: 'Update routing documentation',
318-
type: 'PR',
299+
type: 'GH_PR_ADD_COMMENT',
319300
unique_key: '4',
320-
} satisfies GitHubSpot,
301+
} satisfies GitHubPRAddCommentSpot,
321302
},
322303
{
323304
isOpenTab: true,
@@ -352,12 +333,13 @@ const generateMockDrafts = (): CommentTableRow[] => [
352333
time: Date.now() - 1000 * 60 * 60 * 48,
353334
},
354335
spot: {
336+
domain: 'github.com',
355337
number: 3456,
356338
slug: 'nodejs/node',
357339
title: 'Add support for ESM in worker threads',
358-
type: 'PR',
340+
type: 'GH_PR_ADD_COMMENT',
359341
unique_key: '5',
360-
} satisfies GitHubSpot,
342+
} satisfies GitHubPRAddCommentSpot,
361343
},
362344
]
363345

@@ -609,8 +591,8 @@ function commentRow(
609591
<div className='flex items-center justify-between gap-1.5 text-xs text-gray-600'>
610592
<div className='flex items-center gap-1.5 min-w-0 flex-1'>
611593
<span className='w-4 h-4 flex items-center justify-center flex-shrink-0'>
612-
{row.spot.type === 'PR' && <GitPullRequestIcon size={16} />}
613-
{row.spot.type === 'ISSUE' && <IssueOpenedIcon size={16} />}
594+
{row.spot.type === 'GH_PR_ADD_COMMENT' && <GitPullRequestIcon size={16} />}
595+
{row.spot.type === 'GH_ISSUE_ADD_COMMENT' && <IssueOpenedIcon size={16} />}
614596
{row.spot.type === 'REDDIT' && (
615597
<img
616598
src='https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png?width=128&frame=1&auto=webp&s=400b33e7080aa4996c405a96b3872a12f0e3b68d'

browser-extension/tests/playground/replica.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ const gh_pr: GitHubPRAddCommentSpot = {
99
domain: 'github.com',
1010
number: 517,
1111
slug: 'diffplug/selfie',
12+
title: 'wowza',
1213
type: 'GH_PR_ADD_COMMENT',
1314
unique_key: 'github.com:diffplug/selfie:517',
1415
}
1516
const gh_issue: GitHubIssueAddCommentSpot = {
1617
domain: 'github.com',
1718
number: 523,
1819
slug: 'diffplug/selfie',
20+
title: 'whoa',
1921
type: 'GH_ISSUE_ADD_COMMENT',
2022
unique_key: 'github.com:diffplug/selfie:523',
2123
}

0 commit comments

Comments
 (0)