Skip to content

Fixing main#68

Merged
webdevcody merged 6 commits intomainfrom
fixing-main
Dec 14, 2025
Merged

Fixing main#68
webdevcody merged 6 commits intomainfrom
fixing-main

Conversation

@webdevcody
Copy link
Collaborator

No description provided.

- Enhanced the executeQuery method to better handle conversation history and user messages, ensuring compliance with SDK requirements.
- Introduced a default tools array for allowedTools, simplifying the options setup.
- Updated the getAvailableModels method to use type assertions for model tiers and ensured proper return type with TypeScript's satisfies operator.
- Added error handling during query execution to log and propagate errors effectively.
… handling

- Added a postinstall script in package.json to set permissions for spawn-helper on macOS.
- Refactored the terminal WebSocket connection handling in index.ts for improved readability and consistency.
- Enhanced error logging and connection management in the terminal service.
- Cleaned up formatting and indentation across multiple files for better code clarity.
- Refactored init.sh to introduce a reusable function for killing processes on specified ports, improving code clarity and maintainability.
- Added a cleanup function to ensure proper resource management on exit.
- Updated server startup logic in index.ts to handle port conflicts gracefully, providing clear error messages and suggestions for resolution.
- Improved logging for server status and health checks during initialization.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @webdevcody, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the stability and user experience of the server and development environment. Key changes include more robust server startup procedures with better port conflict resolution, refined handling of conversation history within the Claude AI provider for improved multi-turn interactions, and a crucial fix for node-pty permissions on macOS. The init.sh script has also been streamlined for more efficient development workflows.

Highlights

  • Robust Server Startup & Port Conflict Handling: The server now includes enhanced error handling for port conflicts (EADDRINUSE), providing clear instructions to the user if the default port is already in use. The init.sh script has also been updated to proactively kill processes on ports 3007 and 3008 and wait for them to free up before starting the server.
  • Improved Claude AI Conversation History Handling: The Claude AI provider has been updated to correctly process conversation history, specifically filtering for user messages when assistant messages are present, to ensure compatibility with the Claude SDK's async generator requirements. This prevents potential errors during multi-turn conversations.
  • Refactored init.sh Script: The init.sh script has been significantly refactored to only start the backend server when the web application mode is selected. It also includes a new kill_port function for cleaner process termination and a cleanup trap for graceful shutdown.
  • macOS node-pty Permissions Fix: A postinstall script has been added to package.json to automatically set executable permissions for node-pty's spawn-helper binaries on macOS, resolving a common issue that could prevent terminal functionality.
  • Code Formatting and Readability: Numerous minor formatting adjustments, such as import statements, console logs, and function signatures, have been applied across several files to improve overall code readability and consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a number of improvements, primarily focused on code formatting, developer experience, and robustness. Key changes include:

  • Improved startup error handling in apps/server/src/index.ts, especially for port conflicts (EADDRINUSE), which is a great addition for developers.
  • Refactoring of the init.sh script to be more robust, with better process cleanup and conditional server startup.
  • Several fixes and modernizations in apps/server/src/providers/claude-provider.ts, such as adding try-catch blocks, fixing a bug with multipart prompts, and using modern TypeScript features like satisfies.

However, I've identified a critical issue in claude-provider.ts where changes to handle conversation history inadvertently drop assistant messages, leading to a loss of conversation context for the model. My review includes a suggestion to fix this while also improving the code's structure.

Comment on lines +75 to +128
// Convert history to SDK message format
// Note: When using async generator, SDK only accepts SDKUserMessage (type: 'user')
// So we filter to only include user messages to avoid SDK errors
const historyMessages = convertHistoryToMessages(conversationHistory);
const hasAssistantMessages = historyMessages.some(
(msg) => msg.type === "assistant"
);

if (hasAssistantMessages) {
// If we have assistant messages, use async generator but filter to only user messages
// This maintains conversation flow while respecting SDK type constraints
promptPayload = (async function* () {
// Filter to only user messages - SDK async generator only accepts SDKUserMessage
const userHistoryMessages = historyMessages.filter(
(msg) => msg.type === "user"
);
for (const msg of userHistoryMessages) {
yield msg;
}

// Yield current prompt
const normalizedPrompt = normalizeContentBlocks(prompt);
const currentPrompt = {
type: "user" as const,
session_id: "",
message: {
role: "user" as const,
content: normalizedPrompt,
},
parent_tool_use_id: null,
};
yield currentPrompt;
})();
} else {
// Only user messages in history - can use async generator normally
promptPayload = (async function* () {
for (const msg of historyMessages) {
yield msg;
}

// Yield current prompt
const normalizedPrompt = normalizeContentBlocks(prompt);
const currentPrompt = {
type: "user" as const,
session_id: "",
message: {
role: "user" as const,
content: normalizedPrompt,
},
parent_tool_use_id: null,
};
yield currentPrompt;
})();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change introduces a critical issue. By filtering out assistant messages from the conversation history (lines 88-90), you are sending an incomplete history to the model. This will lead to incorrect responses as the model will lack the full context of the conversation. The comment on line 85, // This maintains conversation flow..., is incorrect as this change breaks the conversation flow.

While the SDK's async generator for the prompt may only accept SDKUserMessage (with type: 'user'), a better approach is to switch to a different payload format when assistant messages are present. Given that you've updated promptPayload's type to include Array<any>, you can pass the entire history as an array. This avoids using the async generator in that case and preserves the full conversation context.

The suggested change below fixes this critical bug and also reduces code duplication by defining currentPrompt once.

      // Convert history to SDK message format
      const historyMessages = convertHistoryToMessages(conversationHistory);
      const hasAssistantMessages = historyMessages.some(
        (msg) => msg.type === "assistant"
      );

      const normalizedPrompt = normalizeContentBlocks(prompt);
      const currentPrompt = {
        type: "user" as const,
        session_id: "",
        message: {
          role: "user" as const,
          content: normalizedPrompt,
        },
        parent_tool_use_id: null,
      };

      if (hasAssistantMessages) {
        // Note: When using an async generator, the SDK may only accept user messages.
        // To pass a full conversation with assistant replies, we must pass the history as an array.
        // This preserves the full conversation context.
        promptPayload = [...historyMessages, currentPrompt];
      } else {
        // Only user messages in history, so we can use the async generator.
        promptPayload = (async function* () {
          for (const msg of historyMessages) {
            yield msg;
          }
          yield currentPrompt;
        })();
      }

- Added a hasInstallScript property to package-lock.json.
- Refactored the app-store.ts file for improved readability by formatting function parameters and object properties.
- Updated the default terminal shortcut from "Cmd+`" to "T" and implemented migration logic for state persistence.
- Incremented version number in the terminal state management to reflect breaking changes.
… service

- Added a default categories.json file to the project initialization structure.
- Improved code formatting and readability in the auto-mode-service.ts file by restructuring console log statements and method calls.
- Updated feature status checks to include "backlog" in addition to "pending" and "ready".
- Updated the stopAutoLoop method to emit the "auto_mode_stopped" event immediately when the loop is explicitly stopped, enhancing event handling.
- Improved code readability by restructuring feature retrieval calls in integration tests for better clarity.
@webdevcody webdevcody merged commit 406ba14 into main Dec 14, 2025
2 checks passed
@trueheads trueheads deleted the fixing-main branch December 14, 2025 16:22
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