Skip to content

🧹 Refactor realJulesPort into a class to improve maintainability - #89

Merged
parvezk merged 1 commit into
mainfrom
jules-2889863391769991109-89002a31
Aug 11, 2026
Merged

🧹 Refactor realJulesPort into a class to improve maintainability#89
parvezk merged 1 commit into
mainfrom
jules-2889863391769991109-89002a31

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

🎯 What:
Refactored the realJulesPort function in src/adapters/jules-port.ts. Created a new class RealJulesPortImpl that implements the JulesPort interface, and moved the lengthy method implementations (createSession, getSession, listActivities, sendMessage, listSources) into the methods of this new class. The realJulesPort function now acts as a simple factory that instantiates and returns new RealJulesPortImpl(apiKey).

💡 Why:
The original realJulesPort function was excessively long and complex because it returned an object containing the implementations of all the interface's methods inline. By abstracting these implementations into a dedicated class (RealJulesPortImpl), we significantly reduce the cognitive load of the factory function and align with typical object-oriented principles, thereby improving code maintainability and readability.

Verification:

  1. pnpm test successfully executed and passed all tests.
  2. pnpm run build completed successfully without any compilation errors.
  3. Formatted using npx prettier --write src/adapters/jules-port.ts.

Result:
The complexity of the realJulesPort function has been drastically reduced, making the module much easier to understand, test, and maintain moving forward. No functionality was altered.


PR created automatically by Jules for task 2889863391769991109 started by @parvezk

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polyagent Ready Ready Preview Aug 1, 2026 4:07am

}[];
};

const messages = (resp.activities ?? []).map((a) => ({

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@claude The conditional statement and ternary check seem to be too convoluted. Can we simply it for maintainability?

messages: { role: "agent" | "human"; content: string; timestamp: string }[];
}> {
const resp = (await julesRequest(this.apiKey, "GET", `/sessions/${sessionId}/activities`)) as {
activities?: {

@parvezk parvezk Aug 11, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@claude Can we declare shared type or unionize the type for message in line 182 and 185?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@claude Can we declare shared type or unionize the type for message in line 182 and 185?

id?: string;
state?: JulesState;
};
class RealJulesPortImpl implements JulesPort {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@claude A brief description above would be helpful

@parvezk
parvezk merged commit 4978435 into main Aug 11, 2026
2 checks passed

parvezk commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Internal change — no release note.

This PR refactors realJulesPort in src/adapters/jules-port.ts into a class (RealJulesPortImpl) for maintainability. No behavior or public API changed.


Generated by Claude Code

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.

1 participant