fix(core): ensure TERM env var is passed to editors and shells#20440
fix(core): ensure TERM env var is passed to editors and shells#20440rmedranollamas wants to merge 2 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello @rmedranollamas, 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 addresses issues where terminal-based editors and interactive shell commands might fail due to missing or redacted Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly identifies the need to pass TERM and COLORTERM environment variables to child processes to ensure proper functionality of terminal-based editors and shells. The changes to whitelist these variables in environmentSanitization.ts and to pass them when spawning editors in editorUtils.ts are well-implemented. However, the fix is incomplete in shellExecutionService.ts, where a fallback for COLORTERM is missing for shell commands, potentially leading to inconsistent color support. I've added comments with suggestions to address this for a more robust solution.
| env: { | ||
| ...process.env, | ||
| TERM: process.env['TERM'] || 'xterm-256color', | ||
| COLORTERM: process.env['COLORTERM'] || 'truecolor', |
There was a problem hiding this comment.
pretending the terminal is truecolor when it isn't seems dangerous. Can we just pass exactly what was in the process rather than lying about it.
jacob314
left a comment
There was a problem hiding this comment.
Should we be really claiming the terminal is truecolor when it is not? I would suggest we omit this or use the existing detection logic we already have for whether the terminal appears to be true color (used for warnings we show when the terminal is not true color).
Summary
Ensure the
TERMandCOLORTERMenvironment variables are correctly passed to editors (like Emacs) and interactive shell commands, preventing failures when these variables are missing or redacted.Details
TERMandCOLORTERMto the whitelist of always allowed environment variables inpackages/core/src/services/environmentSanitization.ts.ShellExecutionServiceto use the host'sTERMvariable with a fallback toxterm-256color, instead of hardcoding the fallback value.openFileInEditorto explicitly passTERMandCOLORTERMto spawned editor processes, ensuring terminal-based editors have the necessary context to initialize.Related Issues
Fixes #20444
How to Validate
EDITORorVISUALtoemacs(terminal mode).run_shell_command top) and verify it correctly identifies the terminal type.Pre-Merge Checklist