Skip to content

Feature - Add ghostty to aider desk#613

Open
jutaz wants to merge 7 commits intohotovo:mainfrom
jutaz:feature/ghostty
Open

Feature - Add ghostty to aider desk#613
jutaz wants to merge 7 commits intohotovo:mainfrom
jutaz:feature/ghostty

Conversation

@jutaz
Copy link
Contributor

@jutaz jutaz commented Jan 14, 2026

Adds ghostty via ghostty-web instead of xterm. This should increase reliability and usability of the inbuilt terminal.

@github-actions github-actions bot requested a review from wladimiiir January 14, 2026 15:07
@gemini-code-assist
Copy link

Summary of Changes

Hello @jutaz, 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 introduces a significant upgrade to the application's integrated terminal by replacing the existing xterm.js implementation with ghostty-web. This migration is intended to enhance the terminal's overall reliability and user experience. The changes span across dependency updates, adjustments to security policies, and a comprehensive refactoring of the terminal's frontend component to seamlessly integrate the new ghostty-web library.

Highlights

  • Terminal Library Switch: The core terminal functionality has been migrated from xterm.js to ghostty-web, aiming for improved reliability and usability of the inbuilt terminal.
  • Dependency Management: xterm.js and its associated addons (@xterm/addon-fit, @xterm/addon-web-links) have been removed from package.json, and ghostty-web has been added as a new dependency.
  • Content Security Policy Update: The index.html file's Content Security Policy (CSP) was adjusted to include 'unsafe-eval' for script-src and data: for connect-src, which are likely requirements for ghostty-web.
  • Terminal Component Refactor: The Terminal.tsx component has been significantly refactored to integrate ghostty-web, including changes to imports, state management, lifecycle effects, and exposed imperative methods.
  • Automatic Resizing & Cursor Handling: ghostty-web now handles terminal resizing automatically, removing the need for a FitAddon. Custom CSS was added to hide native cursors, as ghostty likely renders its own.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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

@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 replaces xterm.js with ghostty-web for the terminal component, which is a significant and welcome improvement for reliability and usability. The refactoring also includes performance enhancements for terminal tab switching. While the changes are generally positive, I've identified a critical bug that causes an infinite render loop, a high-severity security issue with the Content Security Policy, and a couple of medium-severity issues related to error handling and potential performance optimizations. Please review the comments for details.

@wladimiiir
Copy link
Contributor

There are some issues I have found out during testing:

  1. missing padding
image
  1. cursor is disappearing when over it
    mouse-disappearing

  2. missing scrollbar

image
  1. terminal not focused automatically when opened

Copy link
Contributor

@wladimiiir wladimiiir left a comment

Choose a reason for hiding this comment

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

See my comment.

@jutaz
Copy link
Contributor Author

jutaz commented Jan 15, 2026

See my comment.

Good points, addressed 👍

@jutaz jutaz requested a review from wladimiiir January 15, 2026 16:44
Copy link
Contributor

@wladimiiir wladimiiir left a comment

Choose a reason for hiding this comment

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

Looks better, my previous findings seem to have been fixed, but I am experiencing another issue when minimizing/closing the Terminal view when there are messages present. It seems that it does close the component area properly:

Image

@wladimiiir
Copy link
Contributor

@jutaz
Thanks for the update, almost there 🙂
There seems to be an issue, that when you open new terminal, it's not possible to write input into the previously created terminals anymore. Can you please have a look at it as well as the failing checks? Thank you.

@jutaz
Copy link
Contributor Author

jutaz commented Jan 28, 2026

Taking a look in an hour or so - sorry about that! Focused on layout too much 😂

@wladimiiir
Copy link
Contributor

@jutaz
Do you think you will have time to finish this one up in the next few days?

ghostty.onResize(({ cols, rows }) => {
void api.resizeTerminal(terminalId, cols, rows);
});
}, [terminalId, api, ghosttyTerminal]);
Copy link

Choose a reason for hiding this comment

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

CRITICAL: Memory leak - event handlers not cleaned up

The onData and onResize event handlers registered on the ghostty terminal are never removed. This will cause memory leaks when the component unmounts or when dependencies change.

The effect should return a cleanup function that removes these handlers. Most terminal libraries provide an unsubscribe mechanism or disposable pattern for event handlers.


void createTerminal();
}, [baseDir, terminalId, visible, api, taskId]);
}, [baseDir, terminalId, visible, api, taskId, ghosttyTerminal]);
Copy link

Choose a reason for hiding this comment

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

WARNING: Missing dependency in useEffect

The fitAddon is used inside the effect (line 294) but is not included in the dependency array. This could cause the effect to use a stale reference to fitAddon.

Add fitAddon to the dependency array: [baseDir, terminalId, visible, api, taskId, ghosttyTerminal, fitAddon]

}

.xterm-viewport {
@apply scrollbar-thin scrollbar-track-bg-primary scrollbar-thumb-bg-secondary-light hover:scrollbar-thumb-bg-tertiary;
Copy link

Choose a reason for hiding this comment

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

WARNING: Stale CSS selector after library migration

The .xterm-viewport class was specific to the xterm.js library which has been replaced with ghostty-web. This selector will no longer match any elements and should be updated to target ghostty-web's viewport class or removed if no longer needed.

Check ghostty-web documentation for the correct class names.


.xterm-screen {
@apply px-3;
@apply pl-3 pr-0;
Copy link

Choose a reason for hiding this comment

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

WARNING: Stale CSS selector after library migration

The .xterm-screen class was specific to the xterm.js library which has been replaced with ghostty-web. This selector will no longer match any elements and should be updated to target ghostty-web's screen class or removed if no longer needed.

Check ghostty-web documentation for the correct class names.

@kilo-code-bot
Copy link

kilo-code-bot bot commented Mar 12, 2026

Code Review Summary

Status: 2 New Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 1
New Issue Details (click to expand)

CRITICAL

File Line Issue
src/renderer/src/components/terminal/Terminal.tsx 272 Circular dependency in useLayoutEffect causing infinite re-renders

WARNING

File Line Issue
src/renderer/src/components/terminal/Terminal.tsx 318 Missing fitAddon dependency in useLayoutEffect
Previously Reported Issues (8 active)
File Line Issue
src/renderer/src/components/terminal/Terminal.tsx 345 CRITICAL: Memory leak - event handlers not cleaned up
src/renderer/src/components/terminal/Terminal.tsx 318 WARNING: Missing dependency in useEffect
src/renderer/src/components/terminal/Terminal.scss N/A WARNING: Stale CSS selector after library migration
src/renderer/index.html N/A Security issue
Files Reviewed (4 files)
  • package.json - Dependency changes (xterm → ghostty-web)
  • package-lock.json - Lock file updates
  • src/renderer/src/components/terminal/Terminal.tsx - 2 new issues
  • src/renderer/src/components/terminal/TerminalView.tsx - No new issues
  • src/main/terminal/terminal-manager.ts - No issues

Fix these issues in Kilo Cloud

}
};
}, [terminalId, api]);
}, [taskId, visible, fitAddon]);
Copy link

Choose a reason for hiding this comment

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

CRITICAL: Circular dependency causing infinite re-renders

The useLayoutEffect at line 124 includes fitAddon in its dependency array (line 272), but this same effect creates and sets fitAddon via setFitAddon(fitAddonInstance) at line 219. This creates a circular dependency:

  1. Effect runs → creates new fitAddon → calls setFitAddon
  2. fitAddon state changes → triggers effect again
  3. Loop repeats infinitely

Impact: Infinite re-renders, memory leaks from repeatedly creating/disposing terminal instances, poor performance.

Solution: Remove fitAddon from the dependency array. The effect should only run when taskId or visible changes, not when fitAddon changes (since the effect itself creates it).

Suggested change
}, [taskId, visible, fitAddon]);
}, [taskId, visible]);


void createTerminal();
}, [baseDir, terminalId, visible, api, taskId]);
}, [baseDir, terminalId, visible, api, taskId, ghosttyTerminal]);
Copy link

Choose a reason for hiding this comment

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

WARNING: Missing fitAddon dependency in useLayoutEffect

The effect uses fitAddon at line 293-295 but doesn't include it in the dependency array. This violates the React hooks exhaustive-deps rule and could cause the effect to use a stale fitAddon reference.

Solution: Add fitAddon to the dependency array:

Suggested change
}, [baseDir, terminalId, visible, api, taskId, ghosttyTerminal]);
}, [baseDir, terminalId, visible, api, taskId, ghosttyTerminal, fitAddon]);

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