fix: propagate telemetry opt-out to Python engine sidecar#224
fix: propagate telemetry opt-out to Python engine sidecar#224suryaiyer95 wants to merge 2 commits intomainfrom
Conversation
When altimate-code has telemetry disabled (env var or config file), the Python engine (altimate_core) must also not send telemetry. Two changes: - \`Telemetry.isEnabled()\`: new export that returns \`true\` only after \`init()\` has completed and telemetry is active - \`Bridge.start()\`: awaits \`Telemetry.init()\` before spawning the Python process, then injects \`ALTIMATE_TELEMETRY_DISABLED=true\` into the child's environment when telemetry is disabled The child process inherits the parent env already, so env-var-based opt-outs propagate automatically. This change closes the gap for config-file-based opt-outs (\`telemetry.disabled: true\` in \`altimate-code.json\`), where no env var is set in the shell. Companion change in altimate-core: \`init()\` now reads \`ALTIMATE_TELEMETRY_DISABLED\` and forces \`telemetry=False\`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code ReviewThis repository is configured for manual code reviews. Comment |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
There was a problem hiding this comment.
Pull request overview
Adds first-class support for connecting to an Altimate platform “backend” as an OpenAI-compatible provider, including a dedicated TUI login flow and improved credential-file permissions, plus propagates telemetry opt-out into the Python bridge.
Changes:
- Added an
altimate-backendprovider loader + model registration and wired it into the provider picker. - Introduced a new TUI dialog to collect/validate Altimate credentials and persist them to
~/.altimate/altimate.json. - Improved telemetry/bridge integration (new
Telemetry.isEnabled(); passALTIMATE_TELEMETRY_DISABLEDto the Python engine) and tightened filesystem permission handling viachmod.
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 |
|---|---|
| packages/opencode/src/util/filesystem.ts | Ensures file modes are applied even when overwriting by calling chmod after writes. |
| packages/opencode/src/provider/provider.ts | Adds altimate-backend provider loader and registers a default OpenAI-compatible model. |
| packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx | Adds altimate-backend into provider selection and routes selection to a dedicated login dialog. |
| packages/opencode/src/cli/cmd/tui/component/dialog-altimate-login.tsx | New dialog to enter and validate Altimate instance/key/url and write credentials. |
| packages/opencode/src/altimate/telemetry/index.ts | Adds Telemetry.isEnabled() to query post-init enabled state. |
| packages/opencode/src/altimate/bridge/client.ts | Initializes telemetry before spawning Python engine and propagates opt-out env var. |
| docs/docs/getting-started.md | Documents /connect and manual ~/.altimate/altimate.json setup for Altimate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| evt.preventDefault() | ||
| } | ||
| if (evt.name === "return") { | ||
| if (validating()) return |
| const res = await fetch(`${url}/auth_health`, { | ||
| method: "GET", | ||
| headers: { | ||
| Authorization: `Bearer ${key}`, | ||
| "x-tenant": instance, | ||
| }, | ||
| }) |
| title: provider.name, | ||
| value: provider.id, | ||
| description: { | ||
| "altimate-backend": "(API key)", | ||
| opencode: "(Recommended)", | ||
| anthropic: "(API key)", | ||
| openai: "(ChatGPT Plus/Pro or API key)", | ||
| "opencode-go": "Low cost subscription for everyone", | ||
| }[provider.id], |
| // Register altimate-backend as an OpenAI-compatible provider | ||
| if (!database["altimate-backend"]) { | ||
| const backendModels: Record<string, Model> = { | ||
| "altimate-default": { | ||
| id: ModelID.make("altimate-default"), | ||
| providerID: ProviderID.make("altimate-backend"), | ||
| name: "Altimate AI", | ||
| family: "openai", | ||
| api: { id: "altimate-default", url: "", npm: "@ai-sdk/openai-compatible" }, | ||
| status: "active", | ||
| headers: {}, | ||
| options: {}, | ||
| cost: { input: 0, output: 0, cache: { read: 0, write: 0 } }, | ||
| limit: { context: 200000, output: 128000 }, | ||
| capabilities: { | ||
| temperature: true, | ||
| reasoning: false, | ||
| attachment: false, | ||
| toolcall: true, | ||
| input: { text: true, audio: false, image: true, video: false, pdf: false }, | ||
| output: { text: true, audio: false, image: false, video: false, pdf: false }, | ||
| interleaved: false, | ||
| }, | ||
| release_date: "2025-01-01", | ||
| variants: {}, | ||
| }, | ||
| } | ||
| database["altimate-backend"] = { | ||
| id: ProviderID.make("altimate-backend"), | ||
| name: "Altimate", | ||
| source: "custom", | ||
| env: [], | ||
| options: {}, | ||
| models: backendModels, | ||
| } | ||
| } | ||
|
|
Summary
Telemetry.isEnabled()export — returnstrueonly afterinit()has completed and telemetry is activeBridge.start(): awaitsTelemetry.init()before spawning the Python process, then injectsALTIMATE_TELEMETRY_DISABLED=trueinto the child's environment when telemetry is disabledWhy
When the user disables telemetry via config file (
telemetry.disabled: trueinaltimate-code.json), no env var is set in the shell. The Python engine inheritsprocess.envimplicitly, so it wouldn't see any opt-out signal. This change explicitly injectsALTIMATE_TELEMETRY_DISABLED=trueinto the child env based on the actual telemetry state after init, closing that gap.The env-var case (
ALTIMATE_TELEMETRY_DISABLED=truein the shell) already worked via inheritance — this only adds coverage for the config-file case.Companion PR in
altimate-core:init()now readsALTIMATE_TELEMETRY_DISABLEDand forcestelemetry=False.Test plan
telemetry.disabled: truein~/.config/altimate-code/altimate-code.json— verifyALTIMATE_TELEMETRY_DISABLED=trueis in the Python engine's environmentALTIMATE_TELEMETRY_DISABLED=truein shell — verify it continues to work via inheritance🤖 Generated with Claude Code