Skip to content

Commit a647512

Browse files
committed
Pull generateMockDrafts out of claude.tsx into replicaData.tsx
1 parent d1132b1 commit a647512

File tree

2 files changed

+199
-199
lines changed

2 files changed

+199
-199
lines changed

browser-extension/tests/playground/claude.tsx

Lines changed: 6 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ import {
1717
} from 'lucide-react'
1818
import { useMemo, useState } from 'react'
1919
import { twMerge } from 'tailwind-merge'
20-
import type { CommentSpot } from '@/lib/enhancer'
21-
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'
20+
import {
21+
type CommentTableRow,
22+
generateMockDrafts,
23+
isGitHubDraft,
24+
isRedditDraft,
25+
} from './replicaData'
2426

2527
interface FilterState {
2628
sentFilter: 'both' | 'sent' | 'unsent'
@@ -148,201 +150,6 @@ const MultiSegment = <T,>({ segments, value, onValueChange }: MultiSegmentProps<
148150
)
149151
}
150152

151-
interface RedditSpot extends CommentSpot {
152-
title: string
153-
subreddit: string
154-
type: 'REDDIT'
155-
}
156-
157-
interface Draft {
158-
content: string
159-
time: number
160-
stats: DraftStats
161-
}
162-
163-
interface CommentTableRow {
164-
spot: GitHubOrReddit
165-
latestDraft: Draft
166-
isOpenTab: boolean
167-
isSent: boolean
168-
isTrashed: boolean
169-
}
170-
171-
type GitHubOrReddit = GitHubIssueAddCommentSpot | GitHubPRAddCommentSpot | RedditSpot
172-
173-
const isGitHubDraft = (spot: GitHubOrReddit): spot is GitHubIssueAddCommentSpot => {
174-
return spot.type === 'GH_PR_ADD_COMMENT' || spot.type === 'GH_ISSUE_ADD_COMMENT'
175-
}
176-
177-
const isRedditDraft = (spot: GitHubOrReddit): spot is RedditSpot => {
178-
return spot.type === 'REDDIT'
179-
}
180-
181-
const generateMockDrafts = (): CommentTableRow[] => [
182-
{
183-
isOpenTab: true,
184-
isSent: false,
185-
isTrashed: false,
186-
latestDraft: {
187-
content:
188-
'This PR addresses the memory leak issue reported in #1233. The problem was caused by event listeners not being properly disposed...',
189-
stats: {
190-
charCount: 245,
191-
codeBlocks: [
192-
{ code: 'const listener = () => {}', language: 'typescript' },
193-
{ code: 'element.removeEventListener()', language: 'javascript' },
194-
{ code: 'dispose()', language: 'typescript' },
195-
],
196-
images: [
197-
{ url: 'https://example.com/image1.png' },
198-
{ url: 'https://example.com/image2.png' },
199-
],
200-
links: [
201-
{ text: 'Issue #1233', url: 'https://github.com/microsoft/vscode/issues/1233' },
202-
{ text: 'Documentation', url: 'https://docs.microsoft.com' },
203-
],
204-
},
205-
time: Date.now() - 1000 * 60 * 30,
206-
},
207-
spot: {
208-
domain: 'github.com',
209-
number: 1234,
210-
slug: 'microsoft/vscode',
211-
title: "Fix memory leak in extension host (why is this so hard! It's been months!)",
212-
type: 'GH_PR_ADD_COMMENT',
213-
unique_key: '1',
214-
} satisfies GitHubPRAddCommentSpot,
215-
},
216-
{
217-
isOpenTab: false,
218-
isSent: false,
219-
isTrashed: false,
220-
latestDraft: {
221-
content:
222-
"I've been using GitLens for years and it's absolutely essential for my workflow. The inline blame annotations are incredibly helpful when...",
223-
stats: {
224-
charCount: 180,
225-
codeBlocks: [],
226-
images: [],
227-
links: [
228-
{
229-
text: 'GitLens',
230-
url: 'https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens',
231-
},
232-
],
233-
},
234-
time: Date.now() - 1000 * 60 * 60 * 2,
235-
},
236-
spot: {
237-
subreddit: 'programming',
238-
title: "Re: What's your favorite VS Code extension?",
239-
type: 'REDDIT',
240-
unique_key: '2',
241-
} satisfies RedditSpot,
242-
},
243-
{
244-
isOpenTab: true,
245-
isSent: false,
246-
isTrashed: false,
247-
latestDraft: {
248-
content:
249-
"When using useEffect with async functions, the cleanup function doesn't seem to be called correctly in certain edge cases...",
250-
stats: {
251-
charCount: 456,
252-
codeBlocks: [{ code: 'useEffect(() => { /* async code */ }, [])', language: 'javascript' }],
253-
images: [],
254-
links: [],
255-
},
256-
time: Date.now() - 1000 * 60 * 60 * 5,
257-
},
258-
spot: {
259-
domain: 'github.com',
260-
number: 5678,
261-
slug: 'facebook/react',
262-
title: 'Unexpected behavior with useEffect cleanup',
263-
type: 'GH_ISSUE_ADD_COMMENT',
264-
unique_key: '3',
265-
} satisfies GitHubIssueAddCommentSpot,
266-
},
267-
{
268-
isOpenTab: false,
269-
isSent: true,
270-
isTrashed: false,
271-
latestDraft: {
272-
content:
273-
'LGTM! Just a few minor suggestions about the examples in the routing section. Consider adding more context about...',
274-
stats: {
275-
charCount: 322,
276-
codeBlocks: [],
277-
images: [
278-
{ url: 'routing-diagram.png' },
279-
{ url: 'example-1.png' },
280-
{ url: 'example-2.png' },
281-
{ url: 'architecture.png' },
282-
],
283-
links: [
284-
{ text: 'Routing docs', url: 'https://nextjs.org/docs/routing' },
285-
{ text: 'Examples', url: 'https://github.com/vercel/next.js/tree/main/examples' },
286-
{
287-
text: 'Migration guide',
288-
url: 'https://nextjs.org/docs/app/building-your-application/upgrading',
289-
},
290-
],
291-
},
292-
time: Date.now() - 1000 * 60 * 60 * 24,
293-
},
294-
spot: {
295-
domain: 'github',
296-
number: 9012,
297-
slug: 'vercel/next.js',
298-
title: 'Update routing documentation',
299-
type: 'GH_PR_ADD_COMMENT',
300-
unique_key: '4',
301-
} satisfies GitHubPRAddCommentSpot,
302-
},
303-
{
304-
isOpenTab: true,
305-
isSent: false,
306-
isTrashed: true,
307-
latestDraft: {
308-
content:
309-
'This PR implements ESM support in worker threads as discussed in the last TSC meeting. The implementation follows...',
310-
stats: {
311-
charCount: 678,
312-
codeBlocks: [
313-
{ code: 'import { Worker } from "worker_threads"', language: 'javascript' },
314-
{ code: 'new Worker("./worker.mjs", { type: "module" })', language: 'javascript' },
315-
{ code: 'import { parentPort } from "worker_threads"', language: 'javascript' },
316-
{ code: 'interface WorkerOptions { type: "module" }', language: 'typescript' },
317-
{ code: 'await import("./dynamic-module.mjs")', language: 'javascript' },
318-
{ code: 'export default function workerTask() {}', language: 'javascript' },
319-
{ code: 'const result = await workerPromise', language: 'javascript' },
320-
],
321-
images: [{ alt: 'ESM Worker Architecture', url: 'worker-architecture.png' }],
322-
links: [
323-
{
324-
text: 'TSC Meeting Notes',
325-
url: 'https://github.com/nodejs/TSC/blob/main/meetings/2023-11-01.md',
326-
},
327-
{ text: 'ESM Spec', url: 'https://tc39.es/ecma262/' },
328-
{ text: 'Worker Threads docs', url: 'https://nodejs.org/api/worker_threads.html' },
329-
{ text: 'Implementation guide', url: 'https://nodejs.org/api/esm.html' },
330-
{ text: 'Related issue', url: 'https://github.com/nodejs/node/issues/30682' },
331-
],
332-
},
333-
time: Date.now() - 1000 * 60 * 60 * 48,
334-
},
335-
spot: {
336-
domain: 'github.com',
337-
number: 3456,
338-
slug: 'nodejs/node',
339-
title: 'Add support for ESM in worker threads',
340-
type: 'GH_PR_ADD_COMMENT',
341-
unique_key: '5',
342-
} satisfies GitHubPRAddCommentSpot,
343-
},
344-
]
345-
346153
// Helper function for relative time
347154
const timeAgo = (date: Date | number) => {
348155
const timestamp = typeof date === 'number' ? date : date.getTime()

0 commit comments

Comments
 (0)