Skip to content

feat: improved processes#50

Merged
rupertsworld merged 4 commits intomainfrom
feat/improved-processes
Aug 8, 2025
Merged

feat: improved processes#50
rupertsworld merged 4 commits intomainfrom
feat/improved-processes

Conversation

@rupertsworld
Copy link
Copy Markdown
Contributor

  • fix serializing issue
  • clearer process snapshot handling & tests
  • fix errors with async

Copilot AI review requested due to automatic review settings August 8, 2025 11:31
@rupertsworld rupertsworld merged commit 3186c9f into main Aug 8, 2025
1 check passed
@rupertsworld rupertsworld deleted the feat/improved-processes branch August 8, 2025 11:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves process management with better serialization, clearer process snapshot handling, and async functionality fixes. The changes restructure the process system to separate concerns between the process runtime and individual process containers.

  • Restructured process architecture into separate modules for better organization
  • Fixed serialization issues by improving type definitions and snapshot handling
  • Enhanced async process support with new promise-based process creation

Reviewed Changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types.ts Added undefined to JSONValue type definition
src/tools.ts Updated imports and return types for better flexibility
src/runtime.ts Refactored runtime to use constructor-based process spawning
src/resources.ts Extended ResourceIcon interface with JSONValue support
src/promise-process.ts Converted to factory function for creating promise-based processes
src/processes/ Split monolithic processes.ts into modular structure
src/messages.ts Updated import path for ProcessContainer
src/kernel.ts Updated event handlers and process spawning logic
src/index.ts Reordered exports for better organization
docs/introduction.md Updated example to return constructor instead of instance
cli/src/tools/ Added async test tool and updated deep research implementation
cli/src/components/MessageBlock.tsx Added console.log for debugging
cli/package.json Removed watch flag from dev script
README.md Added build step to installation instructions
test/ Removed existing test files and added new runtime tests

parameters: z.object({ query: z.string() }),
execute: ({ query }) => {
return new PromiseProcess('deep_research', () => deepResearch(query));
createPromiseProcess('deep_research', () => deepResearch(query));
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The createPromiseProcess function is called but its return value is not returned from the execute function. This will cause the tool to return undefined instead of the expected process constructor.

Suggested change
createPromiseProcess('deep_research', () => deepResearch(query));
return createPromiseProcess('deep_research', () => deepResearch(query));

Copilot uses AI. Check for mistakes.
}

if (msg.type === 'tool-results') {
console.log(msg);
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed from production code. Consider using a proper logging library or removing this debugging statement.

Suggested change
console.log(msg);

Copilot uses AI. Check for mistakes.
Comment thread src/runtime.ts
Comment on lines +93 to +103
// TODO: Logic to decide whether/when to suspend
container.handleSuspend();
};

const ctor = this.constructors.get(snapshot.type)!;
const process = new ctor(snapshot.state);
process.name = snapshot.name;
process.icons = snapshot.icons;
container.resume = () => {
// TODO: Logic to decide whether/when to resume
container.handleResume();
};

const container = this.registerProcess(process, snapshot.id);
this.emit('process.restored', { pid: container.id, process: container });
container.exit = () => {
// TODO: Logic to decide whether/when to exit
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suspend, resume, and exit methods are being overridden with inline functions that contain TODO comments. This creates unclear responsibilities and incomplete functionality that could lead to runtime issues.

Copilot uses AI. Check for mistakes.
this.emit('exit');
}

serialize(): ProcessSnapshot {
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serialize method may return an incomplete ProcessSnapshot when type is undefined, as it's marked optional in the interface but ProcessSnapshot expects it to be present for proper deserialization.

Suggested change
serialize(): ProcessSnapshot {
serialize(): ProcessSnapshot {
if (this.type === undefined) {
throw new Error('Cannot serialize ProcessSnapshot: type is undefined.');
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants