Port core runtime paths and shell execution to support native Windows builds#1
Conversation
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
Agent-Logs-Url: https://github.com/giveen/late/sessions/37f198b0-316d-4095-967b-b1545d7b069b Co-authored-by: giveen <1180939+giveen@users.noreply.github.com>
d2882cd
into
copilot/examine-codebase-compilation-issues
There was a problem hiding this comment.
Pull request overview
Ports OS-sensitive runtime behavior toward native Windows support by introducing platform-aware shell execution and centralizing config/session path resolution.
Changes:
- Added build-tagged shell command construction (
cmd.exe /Con Windows;bashwithshfallback on non-Windows). - Centralized app config/session/MCP config path building in
internal/common/path_utils.go. - Refactored config/session/MCP loaders to use the shared path helpers.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/tool/shell_command_windows.go | Adds Windows-specific shell command builder using cmd.exe /C. |
| internal/tool/shell_command_unix.go | Adds non-Windows shell command builder with cached bash→sh fallback. |
| internal/tool/implementations.go | Switches BashTool execution to the platform-specific shell wrapper. |
| internal/common/path_utils.go | Introduces centralized helpers for config, session, and MCP config paths. |
| internal/config/config.go | Loads config via common.LateConfigDir() instead of manual path building. |
| internal/session/models.go | Resolves session storage via common.LateSessionDir(). |
| internal/mcp/config.go | Uses shared helpers for project/user MCP config discovery and defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Use UserConfigDir on Windows to keep all app state under AppData. | ||
| configDir, err := LateConfigDir() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(configDir, "sessions"), nil |
There was a problem hiding this comment.
In the Windows branch, the local variable is named configDir but LateConfigDir() already appends the late subdirectory, so it’s actually the app-specific config dir. Renaming it (e.g., lateConfigDir) or adjusting the comment would avoid confusion when extending these helpers.
| // Use UserConfigDir on Windows to keep all app state under AppData. | |
| configDir, err := LateConfigDir() | |
| if err != nil { | |
| return "", err | |
| } | |
| return filepath.Join(configDir, "sessions"), nil | |
| // Use the app-specific config dir on Windows to keep all app state under AppData. | |
| lateConfigDir, err := LateConfigDir() | |
| if err != nil { | |
| return "", err | |
| } | |
| return filepath.Join(lateConfigDir, "sessions"), nil |
| // Execute command using a platform-specific shell wrapper. | ||
| cmd := newShellCommand(ctx, params.Command) | ||
| cmd.Dir = params.Cwd |
There was a problem hiding this comment.
BashTool now executes via newShellCommand (which uses cmd.exe on Windows or sh fallback on Unix), but the tool’s user-facing naming/messaging still assumes “bash” (e.g., tool description and some error text). This can be confusing on Windows and when sh is selected; consider making the description/errors shell-agnostic (or explicitly mention the platform-specific shell).
| // Execute command using a platform-specific shell wrapper. | ||
| cmd := newShellCommand(ctx, params.Command) | ||
| cmd.Dir = params.Cwd |
There was a problem hiding this comment.
This change introduces a new OS-specific execution path (newShellCommand) but there’s no direct unit test asserting the constructed command/args per platform (Windows: cmd.exe /C, Unix: <shell> -c). Adding a small test that inspects the returned *exec.Cmd would help prevent regressions without needing to actually run a shell.
| func LateConfigDir() (string, error) { | ||
| configDir, err := os.UserConfigDir() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(configDir, "late"), nil | ||
| } | ||
|
|
||
| func LateSessionDir() (string, error) { | ||
| if runtime.GOOS == "windows" { | ||
| // Use UserConfigDir on Windows to keep all app state under AppData. | ||
| configDir, err := LateConfigDir() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(configDir, "sessions"), nil | ||
| } | ||
|
|
||
| homeDir, err := os.UserHomeDir() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(homeDir, ".local", "share", "late", "sessions"), nil | ||
| } |
There was a problem hiding this comment.
LateConfigDir/LateSessionDir introduce new cross-platform path semantics (notably the Windows branch). Given internal/common already has unit tests, it would be valuable to add tests for these helpers (e.g., validate directory suffixes and behavior under t.Setenv for config/home vars where supported) to lock in the intended conventions.
This PR ports the project’s core OS-sensitive runtime behavior toward native Windows support by removing hardcoded Unix shell assumptions and centralizing platform-aware path resolution. It introduces build-tagged execution paths and aligns config/session storage behavior with OS conventions.
Execution abstraction (no hardcoded Unix shell)
bash -cinvocation inBashToolwith a platform-specific command builder.internal/tool/shell_command_windows.go→cmd.exe /Cinternal/tool/shell_command_unix.go→bashwith cached fallback toshCentralized path handling
internal/common/path_utils.goto define cross-platform path conventions in one place.LateConfigDir)LateSessionDir)Adoption in runtime config/session loaders
internal/config/config.gointernal/session/models.gointernal/mcp/config.goBuild-constraint structure for future OS-specific behavior
*_windows.go/*_unix.gosplit where behavior cannot be cleanly unified, starting with command execution.Example of the shell abstraction now used by command execution: