Skip to content

Conversation

@gilmishal
Copy link
Contributor

No description provided.

@gilmishal gilmishal requested a review from garbas November 20, 2025 20:34
@github-actions github-actions bot added the team-developer-support Issues to be picked up by @flox/team-developer-support label Nov 20, 2025
@gilmishal gilmishal marked this pull request as draft November 20, 2025 20:37
@garbas garbas requested a review from Copilot November 20, 2025 21:18
Copy link

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 pull request refactors the Flox environment activation management by moving process lifecycle management from the extension.ts file into the Env class in env.ts. The main goal is to improve encapsulation and maintainability by centralizing the activation process management within the Env class.

Key changes:

  • Moved floxActivateProcess from a module-level variable to an instance property of the Env class
  • Created spawnActivateProcess() and killActivateProcess() methods to encapsulate process management logic
  • Modified exec() method to automatically wrap commands in flox activate when an activation process is running
  • Updated environment active detection to check for the existence of floxActivateProcess instead of parsing environment variables

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/extension.ts Removed process management code and updated to use new Env methods for spawning and killing the activation process
src/env.ts Added floxActivateProcess property, implemented spawnActivateProcess() and killActivateProcess() methods, and enhanced exec() to wrap commands when activation is active

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

src/extension.ts Outdated
});

let didActivate = await env.spawnActivateProcess();
if(didActivate) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

[nitpick] Missing space after if keyword. Add a space between if and the opening parenthesis for consistency with TypeScript style guidelines: if (didActivate).

Suggested change
if(didActivate) {
if (didActivate) {

Copilot uses AI. Check for mistakes.
src/env.ts Outdated
Comment on lines 303 to 310
if (this.floxActivateProcess) {
return await promisify(execFile)('flox',
['activate', "--dir", this.workspaceUri?.fsPath || "", '--']
.concat([command])
.concat(options.argv),
execOptions);
}
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Potential issue with recursive flox activate calls. When this.floxActivateProcess is running and exec("flox", { argv: ["activate", ...] }) is called (e.g., from line 63 in the constructor), it will wrap it as flox activate --dir ... -- flox activate ..., creating a nested activation. Consider adding a check to skip the wrapping when the command is already "flox" with "activate" as the first argument, or handle this case explicitly.

Copilot uses AI. Check for mistakes.
Comment on lines 344 to 378
this.floxActivateProcess.on('exit', (code, signal) => {
console.log(`Flox activate process exited with code ${code} and signal ${signal}`);
this.floxActivateProcess = undefined;
this.context.workspaceState.update('flox.activatePid', undefined);
vscode.commands.executeCommand('setContext', 'flox.envActive', false);
});

// Handle errors
this.floxActivateProcess.on('error', (error) => {
console.error('Flox activate process error:', error);
this.displayError(`Failed to start flox activate: ${error.message}`);
this.floxActivateProcess = undefined;
this.context.workspaceState.update('flox.activatePid', undefined);
vscode.commands.executeCommand('setContext', 'flox.envActive', false);
});
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The async operations this.context.workspaceState.update() and vscode.commands.executeCommand() in the event handlers are not awaited. While this might be intentional to avoid blocking the event handler, it could lead to race conditions or unhandled promise rejections. Consider either awaiting these calls or explicitly handling any potential errors, e.g.:

this.context.workspaceState.update('flox.activatePid', undefined).catch(err => 
  console.error('Failed to update workspace state:', err)
);

Copilot uses AI. Check for mistakes.
src/extension.ts Outdated
console.error('Failed to kill flox activate process:', error);
await env.displayError(`Failed to deactivate Flox environment: ${error}`);
}
env.killActivateProcess();
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The killActivateProcess() method is async but not awaited here. This could lead to issues where the command completes before the process is properly cleaned up and state updates are finished. Add await before the call.

Suggested change
env.killActivateProcess();
await env.killActivateProcess();

Copilot uses AI. Check for mistakes.
src/env.ts Outdated
}
}

async spawnActivateProcess(): Promise<Boolean> {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Using the primitive wrapper type Boolean instead of the primitive type boolean. TypeScript best practice is to use lowercase boolean for return types. Change Promise<Boolean> to Promise<boolean>.

Suggested change
async spawnActivateProcess(): Promise<Boolean> {
async spawnActivateProcess(): Promise<boolean> {

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@garbas garbas left a comment

Choose a reason for hiding this comment

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

👍🏼 generally good, just one comment that we can fix in the following PRs.

@gilmishal gilmishal force-pushed the feat/support-remote-workspaces branch 2 times, most recently from 255d5c9 to 033ce64 Compare November 23, 2025 13:38
@gilmishal gilmishal force-pushed the 142-make-sure-that-the-other-visual-stuff-works-as-before branch 2 times, most recently from 066af3d to a6e774f Compare November 23, 2025 15:36
@gilmishal gilmishal force-pushed the 142-make-sure-that-the-other-visual-stuff-works-as-before branch from a6e774f to 6246f93 Compare November 25, 2025 13:59
@gilmishal gilmishal force-pushed the 142-make-sure-that-the-other-visual-stuff-works-as-before branch from 6246f93 to 07888d0 Compare November 25, 2025 16:30
@gilmishal gilmishal marked this pull request as ready for review December 3, 2025 16:59
@gilmishal gilmishal closed this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-developer-support Issues to be picked up by @flox/team-developer-support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants