Skip to content

Conversation

opencode-agent[bot]
Copy link
Contributor

Perfect! I've successfully implemented the requested changes to add a sharing config option that can be set to "auto" or "disabled" while maintaining backward compatibility with the deprecated autoshare field.

Summary of Changes

  1. Updated config schema (src/config/config.ts):

    • Added new sharing field with enum values "auto" | "disabled"
    • Marked autoshare field as deprecated with @deprecated comment
    • Added isSharingEnabled() helper function that respects both new and old config fields
  2. Updated sharing logic in multiple files:

    • Session creation (src/session/index.ts): Now uses Config.isSharingEnabled() instead of directly checking cfg.autoshare
    • CLI run command (src/cli/cmd/run.ts): Updated to use the new helper function and added error message when sharing is disabled but --share flag is used
  3. Backward compatibility:

    • The autoshare field is still respected for existing configurations
    • If sharing is explicitly set, it takes precedence over autoshare
    • If sharing is not set, falls back to autoshare behavior

Usage Examples

New configuration (recommended):

{
  "sharing": "disabled"
}

Legacy configuration (still works):

{
  "autoshare": false
}

Mixed configuration (sharing takes precedence):

{
  "sharing": "disabled",
  "autoshare": true
}

This implementation allows enterprise users to disable sharing entirely by setting "sharing": "disabled" in their configuration files, addressing the security concerns raised in the GitHub issue while maintaining full backward compatibility with existing configurations.

Closes #938

view session | view log

Co-authored-by: thdxr <thdxr@users.noreply.github.com>
@thdxr
Copy link
Contributor

thdxr commented Jul 13, 2025

hey opencode i don't want that stupid isSharingEnabled function. when loading the config just check to see if autoshare is set and then set the value of the config to share: "auto" also change the field name to share not sharing

Copy link
Contributor Author

opencode-agent bot commented Jul 13, 2025

Perfect! I've successfully implemented all the requested changes:

  1. Removed the isSharingEnabled function from config.ts
  2. Changed the field name from sharing to share in the config schema
  3. Updated config loading logic to automatically set share: "auto" when autoshare is true during config parsing
  4. Updated all usage sites to directly check cfg.share === "auto" instead of calling the helper function

The changes maintain backward compatibility by migrating autoshare: true to share: "auto" during config loading, making the logic much simpler and more direct as requested.

view session | view log

Co-authored-by: thdxr <thdxr@users.noreply.github.com>
@thdxr
Copy link
Contributor

thdxr commented Jul 13, 2025

hey opencode move the disabled check into the share function - don't check it anywhere else

Copy link
Contributor Author

opencode-agent bot commented Jul 13, 2025

Perfect! I've successfully moved the disabled check into the share function and removed it from other locations. Here's what I changed:

  1. Modified the share function in src/session/index.ts to check if sharing is disabled at the beginning and throw an error if it is
  2. Updated the run command in src/cli/cmd/run.ts to remove the explicit disabled check and instead catch the error from the share function
  3. Updated session creation in src/session/index.ts to silently handle sharing errors during automatic session creation

Now the disabled check is centralized in the share function, making the code cleaner and ensuring that all sharing attempts go through the same validation logic.

view session | view log

Co-authored-by: thdxr <thdxr@users.noreply.github.com>
@thdxr thdxr merged commit 736396f into dev Jul 13, 2025
ryanjdillon pushed a commit to fornybar/opencode that referenced this pull request Jul 17, 2025
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: thdxr <thdxr@users.noreply.github.com>
achembarpu pushed a commit to achembarpu/opencode that referenced this pull request Aug 4, 2025
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: thdxr <thdxr@users.noreply.github.com>
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.

Disable sharing in config
1 participant