Skip to content

Commit b72fabe

Browse files
committed
Fix lint warnings and stabilize Cloudflare transcript-format tests.
Make lint-driven cleanup changes across route and utility modules, and isolate transcript formatting tests from local Cloudflare credentials by setting mock env values explicitly. Made-with: Cursor
1 parent 746edad commit b72fabe

20 files changed

Lines changed: 67 additions & 47 deletions

app/bootstrap.client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {}

app/components/calls/recording-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export function RecordingForm({
136136
? {
137137
...prev,
138138
errors: {
139-
...(prev.errors ?? {}),
139+
...prev.errors,
140140
generalError: undefined,
141141
[field]: null,
142142
} as RecordingFormData['errors'],

app/other-routes.server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ const pathedRoutes: Record<string, Handler> = {
1818
},
1919
}
2020

21-
const routes: Array<Handler> = [
22-
...Object.entries(pathedRoutes).map(([path, handler]) => {
21+
const routes: Array<Handler> = Object.entries(pathedRoutes).map(
22+
([path, handler]) => {
2323
return (request: Request, remixContext: EntryContext) => {
2424
if (new URL(request.url).pathname !== path) return null
2525

2626
return handler(request, remixContext)
2727
}
28-
}),
29-
]
28+
},
29+
)
3030

3131
export { routes, pathedRoutes }

app/routes/blog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ function BlogHome({ loaderData: data }: Route.ComponentProps) {
606606
selected={selected}
607607
onClick={() => toggleTag(tag)}
608608
disabled={
609-
Boolean(!visibleTags.has(tag)) ? !selected : false
609+
!visibleTags.has(tag) ? !selected : false
610610
}
611611
/>
612612
)

app/routes/calls/$season/$episode/$slug.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ export const meta: MetaFunction<
4949
typeof loader,
5050
{ root: RootLoaderType; 'routes/calls/_layout': typeof callsLoader }
5151
> = ({ matches, params }) => {
52-
const { requestInfo } = matches.find((m) => m.id === 'root')
53-
?.data as SerializeFrom<typeof rootLoader>
52+
const rootData = matches.find((m) => m.id === 'root')
53+
?.data as SerializeFrom<typeof rootLoader> | undefined
54+
if (!rootData) {
55+
return [{ title: 'Call not found' }]
56+
}
57+
58+
const { requestInfo } = rootData
5459
const callsData = matches.find((m) => m.id === 'routes/calls/_layout')
5560
?.data as SerializeFrom<typeof callsLoader> | undefined
5661
if (!callsData) {

app/routes/mcp/mcp.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ function createServer() {
349349
},
350350
{
351351
type: 'text',
352-
text:
353-
`Transcript:\n\n${episode.transcriptHTML}` ||
354-
`Transcript: No transcript found for ${episode.title} (Chats with Kent S${seasonNumber}E${episodeNumber})`,
352+
text: episode.transcriptHTML
353+
? `Transcript:\n\n${episode.transcriptHTML}`
354+
: `Transcript: No transcript found for ${episode.title} (Chats with Kent S${seasonNumber}E${episodeNumber})`,
355355
},
356356
],
357357
}

app/routes/talks/$slug.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ export const meta: MetaFunction<
1616
(matches.find((m) => m.id === 'routes/talks/_layout')?.data as
1717
| SerializeFrom<typeof talkLoader>
1818
| undefined) ?? {}
19-
const { requestInfo } = matches.find((m) => m.id === 'root')
20-
?.data as SerializeFrom<RootLoaderType>
19+
const rootData = matches.find((m) => m.id === 'root')
20+
?.data as SerializeFrom<RootLoaderType> | undefined
21+
if (!rootData) {
22+
return [{ title: '404: Talk not found' }]
23+
}
24+
const { requestInfo } = rootData
2125

2226
const talk = params.slug ? talks.find((t) => t.slug === params.slug) : null
2327
const title = talk ? talk.title : '404: Talk not found'

app/utils/__tests__/call-kent-transcript-format.server.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect, test } from 'vitest'
22
import { formatCallKentTranscriptWithWorkersAi } from '#app/utils/cloudflare-ai-call-kent-transcript-format.server.ts'
3+
import { setEnv } from '#tests/env-disposable.ts'
34

45
test('formatCallKentTranscriptWithWorkersAi rejects empty transcripts', async () => {
56
await expect(
@@ -8,6 +9,14 @@ test('formatCallKentTranscriptWithWorkersAi rejects empty transcripts', async ()
89
})
910

1011
test('formatCallKentTranscriptWithWorkersAi returns paragraphs and preserves separators', async () => {
12+
using _env = setEnv({
13+
CLOUDFLARE_API_TOKEN: 'MOCK_CLOUDFLARE_API_TOKEN',
14+
CLOUDFLARE_ACCOUNT_ID: 'mock-account',
15+
CLOUDFLARE_AI_GATEWAY_ID: 'mock-gateway',
16+
CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN: 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN',
17+
CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL: '@cf/meta/llama-3.1-8b-instruct',
18+
})
19+
1120
const transcript = `
1221
Announcer: You're listening to the Call Kent Podcast. Now let's hear the call.
1322
@@ -39,13 +48,29 @@ Announcer: This has been the Call Kent Podcast. Thanks for listening.
3948
})
4049

4150
test('formatCallKentTranscriptWithWorkersAi works without --- separators', async () => {
51+
using _env = setEnv({
52+
CLOUDFLARE_API_TOKEN: 'MOCK_CLOUDFLARE_API_TOKEN',
53+
CLOUDFLARE_ACCOUNT_ID: 'mock-account',
54+
CLOUDFLARE_AI_GATEWAY_ID: 'mock-gateway',
55+
CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN: 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN',
56+
CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL: '@cf/meta/llama-3.1-8b-instruct',
57+
})
58+
4259
const transcript = `Caller: Hi Kent. This is a single block transcript. It should still get paragraph breaks.`
4360
const formatted = await formatCallKentTranscriptWithWorkersAi({ transcript })
4461
expect(formatted).toContain('Caller:')
4562
expect(formatted).toMatch(/[.!?]\n\n/)
4663
})
4764

4865
test('formatCallKentTranscriptWithWorkersAi does not truncate long transcripts', async () => {
66+
using _env = setEnv({
67+
CLOUDFLARE_API_TOKEN: 'MOCK_CLOUDFLARE_API_TOKEN',
68+
CLOUDFLARE_ACCOUNT_ID: 'mock-account',
69+
CLOUDFLARE_AI_GATEWAY_ID: 'mock-gateway',
70+
CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN: 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN',
71+
CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL: '@cf/meta/llama-3.1-8b-instruct',
72+
})
73+
4974
const longBody = Array.from(
5075
{ length: 600 },
5176
(_, i) => `Sentence ${i + 1}.`,

app/utils/__tests__/cloudflare-ai-utils.server.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { setEnv } from '#tests/env-disposable.ts'
33
import { getWorkersAiRunUrl } from '../cloudflare-ai-utils.server.ts'
44

55
test('getWorkersAiRunUrl routes embeddinggemma requests through CLOUDFLARE_AI_EMBEDDING_GATEWAY_ID', () => {
6-
using ignoredEnv = setEnv({
6+
using _ignoredEnv = setEnv({
77
CLOUDFLARE_ACCOUNT_ID: 'cf-account',
88
CLOUDFLARE_AI_GATEWAY_ID: 'runtime-gateway',
99
CLOUDFLARE_AI_EMBEDDING_GATEWAY_ID: 'embedding-gateway',
@@ -15,7 +15,7 @@ test('getWorkersAiRunUrl routes embeddinggemma requests through CLOUDFLARE_AI_EM
1515
})
1616

1717
test('getWorkersAiRunUrl keeps non-embedding models on CLOUDFLARE_AI_GATEWAY_ID', () => {
18-
using ignoredEnv = setEnv({
18+
using _ignoredEnv = setEnv({
1919
CLOUDFLARE_ACCOUNT_ID: 'cf-account',
2020
CLOUDFLARE_AI_GATEWAY_ID: 'runtime-gateway',
2121
CLOUDFLARE_AI_EMBEDDING_GATEWAY_ID: 'embedding-gateway',
@@ -27,7 +27,7 @@ test('getWorkersAiRunUrl keeps non-embedding models on CLOUDFLARE_AI_GATEWAY_ID'
2727
})
2828

2929
test('getWorkersAiRunUrl prefers explicit gatewayId overrides', () => {
30-
using ignoredEnv = setEnv({
30+
using _ignoredEnv = setEnv({
3131
CLOUDFLARE_ACCOUNT_ID: 'cf-account',
3232
CLOUDFLARE_AI_GATEWAY_ID: 'runtime-gateway',
3333
CLOUDFLARE_AI_EMBEDDING_GATEWAY_ID: 'embedding-gateway',

app/utils/__tests__/semantic-search.server.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vi.mock('#app/utils/semantic-search-presentation.server.ts', () => ({
2222
import { semanticSearchKCD } from '../semantic-search.server.ts'
2323

2424
test('semanticSearchKCD routes user query embeddings through CLOUDFLARE_AI_EMBEDDING_GATEWAY_ID', async () => {
25-
using ignoredEnv = setEnv({
25+
using _ignoredEnv = setEnv({
2626
CLOUDFLARE_ACCOUNT_ID: 'cf-account',
2727
CLOUDFLARE_API_TOKEN: 'cf-token',
2828
CLOUDFLARE_AI_GATEWAY_ID: 'runtime-search-gateway',
@@ -78,7 +78,7 @@ test('semanticSearchKCD routes user query embeddings through CLOUDFLARE_AI_EMBED
7878
})
7979

8080
test('semanticSearchKCD canonicalizes YouTube results by video id from URL when slug is missing', async () => {
81-
using ignoredEnv = setEnv({
81+
using _ignoredEnv = setEnv({
8282
CLOUDFLARE_ACCOUNT_ID: 'mock-account',
8383
CLOUDFLARE_API_TOKEN: 'mock-token',
8484
CLOUDFLARE_AI_GATEWAY_ID: 'runtime-search-gateway',

0 commit comments

Comments
 (0)