Skip to content

fix(config): honor workspace shell opt-in#2529

Draft
cyq1017 wants to merge 2 commits into
Hmbown:mainfrom
cyq1017:codex/2523-workspace-shell-config
Draft

fix(config): honor workspace shell opt-in#2529
cyq1017 wants to merge 2 commits into
Hmbown:mainfrom
cyq1017:codex/2523-workspace-shell-config

Conversation

@cyq1017
Copy link
Copy Markdown
Contributor

@cyq1017 cyq1017 commented Jun 1, 2026

Problem

Change

  • Merge matching user config [workspace.'...'] / legacy [projects."..."] entries for allow_shell during TUI and engine-backed exec startup.
  • Preserve env and managed-config precedence.
  • Document the workspace-scoped shell opt-in and correct the allow_shell default.

Verification

  • cargo test -p codewhale-tui user_workspace_overlay --locked
  • cargo test -p codewhale-tui project_config_tests --locked
  • cargo fmt --all -- --check
  • git diff --check

Fixes #2523

Greptile Summary

This PR fixes the user-reported issue where a workspace-scoped allow_shell = true entry in the user's global config file was ignored at launch because the TUI only merged top-level config values and project-local overlays.

  • Adds merge_user_workspace_config (called from both the TUI interactive path and the exec path) that re-reads the user config file as raw TOML and applies the allow_shell value from any matching [workspace.'...'] or legacy [projects.'...'] entry, with guards for managed-config, requirements-path, and the DEEPSEEK_ALLOW_SHELL environment variable.
  • Widens resolve_load_config_path visibility to pub(crate) so the new helper can call it, and adds five unit tests covering path matching, env-var precedence, and managed-config bypass.
  • Updates docs to document the new opt-in syntax and corrects the allow_shell default from true to false.

Confidence Score: 5/5

The change is safe to merge — it adds a new opt-in code path guarded by managed-config and env-var precedence checks with no effect unless the user's global config explicitly contains a matching workspace entry.

The new merge function is narrow in scope (only touches allow_shell), all existing precedence invariants are preserved, and the five new tests cover the main branches. The open gap — no test for the legacy [projects] table — is low-risk given that table follows the same iteration logic.

No files require special attention; the logic in crates/tui/src/main.rs is straightforward and well-tested for the primary [workspace] path.

Important Files Changed

Filename Overview
crates/tui/src/config.rs Visibility of resolve_load_config_path widened to pub(crate) so the new merge helper in main.rs can call it — a minimal, low-risk change.
docs/CONFIGURATION.md Adds a 'User workspace entries' section documenting the new opt-in and corrects the allow_shell default to false. The section does not note that a project-level config.toml (applied after) can still override the user workspace setting, which could surprise users who rely on this opt-in.
crates/tui/src/main.rs Adds merge_user_workspace_config (called from both TUI interactive and exec paths) with appropriate guards for managed-config, env-var precedence, and Windows path normalisation. Five new unit tests added; the legacy [projects] table branch is not covered by tests.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[launch / exec] --> B[load_config_from_cli\nuser file + env vars]
    B --> C{managed_config_path\nor requirements_path?}
    C -- yes --> G[skip workspace overlay]
    C -- no --> D[merge_user_workspace_config\nre-read raw TOML\nfind matching workspace entry\napply allow_shell]
    D --> E{DEEPSEEK_ALLOW_SHELL\nenv var set?}
    E -- yes --> F[restore pre-merge\nallow_shell value\nenv wins]
    E -- no --> H[keep merged value]
    F --> I{interactive mode?}
    H --> I
    G --> I
    I -- yes --> J[merge_project_config\n.codewhale/config.toml\napplied last — can override]
    I -- no / exec --> K[proceed with config]
    J --> K
Loading

Fix All in Codex Fix All in Claude Code Fix All in Cursor

Reviews (2): Last reviewed commit: "fix(config): normalize windows workspace..." | Re-trigger Greptile

Copy link
Copy Markdown
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 user workspace configuration overlays, allowing users to define workspace-specific settings (such as allow_shell) within their global configuration file. It adds logic to merge these configurations, implements OS-specific path comparison, and updates the documentation and tests accordingly. Feedback was provided to improve the robustness of the Windows path comparison logic by handling mismatched path separators and UNC prefixes.

Comment thread crates/tui/src/main.rs
Comment on lines +5007 to +5011
#[cfg(windows)]
fn paths_equal_for_config(left: &Path, right: &Path) -> bool {
left.to_string_lossy()
.eq_ignore_ascii_case(&right.to_string_lossy())
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

On Windows, path comparison using to_string_lossy() directly can fail due to mismatched path separators (forward vs backward slashes) or the presence of the UNC prefix (\\?\) on canonicalized paths. Normalizing the slashes and stripping the UNC prefix ensures robust path matching.

#[cfg(windows)]
fn paths_equal_for_config(left: &Path, right: &Path) -> bool {
    let left_str = left.to_string_lossy().replace('/', "\\");
    let right_str = right.to_string_lossy().replace('/', "\\");
    let left_clean = left_str.strip_prefix("\\\\\\\\?\\\\").unwrap_or(left_str.as_str());
    let right_clean = right_str.strip_prefix("\\\\\\\\?\\\\").unwrap_or(right_str.as_str());
    left_clean.eq_ignore_ascii_case(right_clean)
}

Comment thread crates/tui/src/main.rs
Comment thread crates/tui/src/main.rs
@buko
Copy link
Copy Markdown

buko commented Jun 1, 2026

You should see my comment here #2523 (comment)

There are many issues around shell configuration that need to be fixed.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented Jun 1, 2026

Harvested into #2504 for the v0.8.50 release slice.

What landed:

  • 7dfec0ed4 / 1d8cbbd40 preserve your workspace shell opt-in fix and Windows path normalization.
  • 3d5edfee8 adds the follow-up legacy [projects] table coverage and documents that project-local config can still override the user workspace entry.

Local verification on the harvest branch:

  • cargo test -p codewhale-tui --all-features --locked user_workspace_overlay -- --nocapture
  • cargo clippy -p codewhale-tui --all-targets --all-features --locked -- -D warnings
  • ./scripts/release/check-versions.sh

Live #2504 CI is green across Ubuntu, macOS, Windows, lint, version drift, CodeQL, mobile smoke, npm smoke, and GitGuardian. Thanks @cyq1017 for the focused fix; I kept your authorship on the harvested commits.

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.

exec_shell tool remains unavailable despite allow_shell = true + trusted = true

3 participants