Sprint 1: refactor App workflows and add regression tests#33
Open
Coldaine wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors src/App.js by extracting import/runtime/search/export workflows into dedicated services and hooks, and adds a Jest-based regression test suite to validate the new boundaries.
Changes:
- Extracted file import parsing/metadata/merge logic into
fileImportService+useFileManager, and moved global search indexing timing intouseGlobalSearchIndex. - Added ZIP import + remote sync service (
zipConversationService) and export orchestration service (exportOrchestrator), plus runtime adapter helpers for extension/web payload flows. - Introduced Jest + Babel test setup with fixtures and regression coverage for import parsing, branch grouping, ZIP import, search indexing, and export orchestration.
Reviewed changes
Copilot reviewed 23 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/zipConversationService.test.js | Regression test for ZIP import parsing + renames/export context + generated File payloads. |
| tests/styleMock.js | Jest moduleNameMapper stub for stylesheet imports. |
| tests/helpers/fileFactories.js | Test helpers to emulate File-like objects for text/binary inputs. |
| tests/globalSearchManager.test.js | Regression test ensuring imported content is indexed and searchable with rename mapping applied. |
| tests/fixtures/claude-conversation.json | Claude conversation fixture used across tests. |
| tests/fixtures/chatgpt-conversation.json | ChatGPT branch fixture used to validate provider parsing/branch behavior. |
| tests/fileMock.js | Jest moduleNameMapper stub for static assets. |
| tests/fileImportService.test.js | Regression test for provider parsing into processed data + metadata. |
| tests/exportOrchestrator.test.js | Regression tests for Markdown/PDF export orchestration with mocked exporters. |
| tests/branchGroupingService.test.js | Regression test for grouping main + branch JSONL files together. |
| src/utils/globalSearchManager.js | Refactor to reuse shared import pipeline (processImportFile) and adjust cache clearing. |
| src/services/zip/zipConversationService.js | New ZIP import parsing + card generation + remote sync batching logic. |
| src/services/runtime/runtimeAdapterService.js | New runtime helpers for lang/theme application, payload-to-File conversion, and session persistence. |
| src/services/import/fileImportService.js | New shared import pipeline (parse/process/metadata/batch extraction/merge helpers). |
| src/services/import/conversationGroupingService.js | New grouping logic for JSONL branch reconstruction prior to merged import. |
| src/services/export/exportOrchestrator.js | New orchestration for Markdown/PDF exports + extension config resolution + pending export handling. |
| src/hooks/useGlobalSearchIndex.js | New hook centralizing “build global index when ready” timing and error handling. |
| src/hooks/useFileManager.js | New hook owning file loading, metadata extraction, merged JSONL handling, and file switching. |
| src/App.js | Integrates the extracted hooks/services; removes inlined workflow implementations. |
| README.md | Adds test commands and Sprint 1 architecture reference; minor formatting change. |
| package.json | Adds Jest/Babel dev deps, Jest config, and test, test:watch, test:ci scripts. |
| docs/sprint-1-architecture.md | New architecture note documenting Sprint 1 module boundaries. |
| babel.config.js | Babel config for Jest transforms (targets current Node). |
| .gitignore | Adds node_modules/, build/, and coverage/ ignores. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+6
to
+27
| const groups = new Map(); | ||
| const fileNameToIntegrity = new Map(); | ||
| const integrityToGroup = new Map(); | ||
| const chatIdHashToGroup = new Map(); | ||
| const mainChatToGroup = new Map(); | ||
|
|
||
| filesData.forEach((fileData) => { | ||
| const metadata = fileData.data[0]?.chat_metadata; | ||
| const integrity = metadata?.integrity; | ||
| const mainChat = metadata?.main_chat; | ||
| const chatIdHash = metadata?.chat_id_hash; | ||
|
|
||
| if (mainChat) return; | ||
|
|
||
| const baseName = normalizeFileBaseName(fileData.fileName); | ||
| const groupKey = integrity || chatIdHash?.toString() || fileData.fileName; | ||
|
|
||
| if (integrity) { | ||
| fileNameToIntegrity.set(baseName, integrity); | ||
| fileNameToIntegrity.set(fileData.fileName, integrity); | ||
| integrityToGroup.set(integrity, groupKey); | ||
| } |
Comment on lines
8
to
13
| constructor() { | ||
| this.messageIndex = new Map(); | ||
| this.fileData = new Map(); | ||
| this.fileCache = new Map(); // 文件内容的缓存 { fileName: { lastModified: timestamp, data: parsedData } } | ||
| this.searchCache = new Map(); | ||
| } |
|
|
||
| - `npm test` runs the Jest suite locally. | ||
| - `npm run test:ci` runs the CI-ready, non-watch test command with coverage. | ||
| - [`docs/sprint-1-architecture.md`](C:/Users/pmacl/.codex/worktrees/6c61/loominary/docs/sprint-1-architecture.md) summarizes the Sprint 1 module boundaries. |
| @@ -0,0 +1,13 @@ | |||
| # Sprint 1 Architecture Note | |||
|
|
|||
| Sprint 1 narrows [`/src/App.js`](C:/Users/pmacl/.codex/worktrees/6c61/loominary/src/App.js) back to app composition by moving critical workflows into dedicated seams: | |||
| ## Contributing | ||
|
|
||
| A contributing guide and development roadmap are on the way. In the meantime, if you have any idea, please [open an discussion](https://github.com/Laumss/Loominary/discussions). No newline at end of file | ||
| A contributing guide and development roadmap are on the way. In the meantime, if you have any idea, please [open an discussion](https://github.com/Laumss/Loominary/discussions). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification