[ENGG-5253]: Add support for examples in local workspaces#300
[ENGG-5253]: Add support for examples in local workspaces#300RuntimeTerror10 wants to merge 1 commit intomasterfrom
Conversation
WalkthroughThis pull request introduces comprehensive example request management capabilities to the local-sync module. New type definitions (ResponseObject, ExampleRecord, ExampleAPI) are added to the schema and type layers. The FsManager class gains three new public methods for creating, updating, and deleting examples associated with parent requests. A parsing utility function converts example content to the API format. The getAllRecords method is refactored to branch explicitly on resource type and process examples when parsing files. Three corresponding IPC methods are exposed in FsManagerRPCService to make these operations remotely invocable. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/renderer/actions/local-sync/fs-manager.ts`:
- Around line 1621-1673: The not-found branch in deleteExampleRequest currently
returns ErrorCode.UNKNOWN; change it to return ErrorCode.NotFound (or the
project's canonical NotFound enum value) so callers can distinguish a missing
example from other errors—update the error object in deleteExampleRequest
(referencing requestFileResource, content.examples check and the returned error)
to use ErrorCode.NotFound and make the same change in the analogous not-found
branches around the other example-handling function referenced (the block at the
1726-1784 region).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/renderer/actions/local-sync/fs-manager.rpc-service.tssrc/renderer/actions/local-sync/fs-manager.tssrc/renderer/actions/local-sync/fs-utils.tssrc/renderer/actions/local-sync/schemas.tssrc/renderer/actions/local-sync/types.ts
| @HandleError | ||
| async deleteExampleRequest( | ||
| parentRequestId: string, | ||
| exampleId: string | ||
| ): Promise<FileSystemResult<void>> { | ||
| const requestFileResource = this.createResource({ | ||
| id: parentRequestId, | ||
| type: "file", | ||
| }); | ||
|
|
||
| const fileResult = await parseFile({ | ||
| resource: requestFileResource, | ||
| fileType: new ApiRecordFileType(), | ||
| }); | ||
|
|
||
| if (fileResult.type === "error") { | ||
| return fileResult; | ||
| } | ||
|
|
||
| const { content } = fileResult; | ||
|
|
||
| if (!content.examples || !(exampleId in content.examples)) { | ||
| return { | ||
| type: "error", | ||
| error: { | ||
| code: ErrorCode.UNKNOWN, | ||
| message: `Example with id ${exampleId} not found in request ${parentRequestId}`, | ||
| path: requestFileResource.path, | ||
| fileType: FileTypeEnum.UNKNOWN, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| delete content.examples[exampleId]; | ||
|
|
||
| if (Object.keys(content.examples).length === 0) { | ||
| delete content.examples; | ||
| } | ||
|
|
||
| const writeResult = await writeContent( | ||
| requestFileResource, | ||
| content, | ||
| new ApiRecordFileType() | ||
| ); | ||
|
|
||
| if (writeResult.type === "error") { | ||
| return writeResult; | ||
| } | ||
|
|
||
| return { | ||
| type: "success", | ||
| }; | ||
| } |
There was a problem hiding this comment.
Use NotFound for missing examples.
Returning ErrorCode.UNKNOWN makes it harder for callers to distinguish “missing example” from unexpected failures. Prefer ErrorCode.NotFound for the not-found branches.
Suggested tweak
@@
- code: ErrorCode.UNKNOWN,
+ code: ErrorCode.NotFound,
@@
- code: ErrorCode.UNKNOWN,
+ code: ErrorCode.NotFound,Also applies to: 1726-1784
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/renderer/actions/local-sync/fs-manager.ts` around lines 1621 - 1673, The
not-found branch in deleteExampleRequest currently returns ErrorCode.UNKNOWN;
change it to return ErrorCode.NotFound (or the project's canonical NotFound enum
value) so callers can distinguish a missing example from other errors—update the
error object in deleteExampleRequest (referencing requestFileResource,
content.examples check and the returned error) to use ErrorCode.NotFound and
make the same change in the analogous not-found branches around the other
example-handling function referenced (the block at the 1726-1784 region).
Summary by CodeRabbit