Skip to content

Commit 653846d

Browse files
refactor(frontend): Task 6 — Modularize utility functions by domain
New utility modules in utils/: - messageUtils.ts: createMessage() factory, formatContentForClipboard() - contentParsing.ts: parseTextContent(), resolveImageUrl(), buildGeneratedContent() - sseParser.ts: parseSSEStream() — eliminates duplicated SSE decode loop - generationStages.ts: getGenerationStage() — pure progress-stage mapper - briefFields.ts: BRIEF_FIELD_LABELS, BRIEF_DISPLAY_ORDER, BRIEF_FIELD_KEYS - stringUtils.ts: escapeRegex(), createNameSwapper(), matchesAnyKeyword() - apiUtils.ts: retryRequest (exponential backoff), RequestCache, throttle - index.ts: barrel export for all utils Deduplicated code: - msg() helper was identical in 2 hooks → createMessage() in messageUtils - SSE stream parser was identical in 2 API functions → parseSSEStream() - GeneratedContent parsing was near-identical in 3 hooks → buildGeneratedContent() - Brief field constants duplicated in 2 components → shared briefFields - Keyword matching pattern repeated 3x → matchesAnyKeyword() Internal helpers marked non-exported: - rewriteBlobUrl() in contentParsing.ts - defaultShouldRetry(), sleep() in apiUtils.ts - plainDownload() in downloadImage.ts (already was) Build: 0 TypeScript errors
1 parent 86d2279 commit 653846d

17 files changed

Lines changed: 741 additions & 332 deletions

.coverage

52 KB
Binary file not shown.

content-gen/src/app/frontend/package-lock.json

Lines changed: 119 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

content-gen/src/app/frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
"dependencies": {
1313
"@fluentui/react-components": "^9.54.0",
1414
"@fluentui/react-icons": "^2.0.245",
15+
"@reduxjs/toolkit": "^2.11.2",
1516
"react": "^18.3.1",
1617
"react-dom": "^18.3.1",
1718
"react-markdown": "^9.0.1",
19+
"react-redux": "^9.2.0",
1820
"uuid": "^10.0.0"
1921
},
2022
"devDependencies": {

0 commit comments

Comments
 (0)