Skip to content

fix(devtools): toggle stuck ON — persist enabled state bidirectionally - #489

Merged
jeonghun-jj-lee merged 5 commits into
mainfrom
fix/devtools-toggle-stuck-on
Aug 21, 2026
Merged

fix(devtools): toggle stuck ON — persist enabled state bidirectionally#489
jeonghun-jj-lee merged 5 commits into
mainfrom
fix/devtools-toggle-stuck-on

Conversation

@jeonghun-jj-lee

@jeonghun-jj-lee jeonghun-jj-lee commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Problem

The developer tools release ↔ dev toggle in Settings was non-functional. Clicking it did nothing visible — the switch stayed ON permanently.

Root Cause

A controlled-component + state-persistence mismatch:

  1. defaultSettings.developer.enabled was true — the toggle always showed ON
  2. The OFF path deliberately did NOT persist false to the SolidJS store (stale comment: "marketplace build doesn't render this section")
  3. Kobalte's controlled <Switch checked={enabled()}/> always reflected the stale true
  4. Every user click fired onChange(false) but since the signal never updated, the visual snapped back to ON
  5. The ON path (setEnabled(true), which autofills paths and triggers rebuild) was unreachable from the UI

Fix

  • Default developer.enabled to false (fresh installs show OFF, toggle can be turned ON)
  • Persist both true and false via settings.developer.setEnabled(value) unconditionally — the controlled component now reflects reality

The toggle is now bidirectional: ON triggers a full rebuild, OFF restores the marketplace dist and reloads.

Companion PR

The same fix applied to the opencode local/amicode branch (where the app source lives for the running dev build).

Summary by CodeRabbit

  • New Features
    • Developer Tools are now disabled by default.
    • Disabling Developer Tools reliably restores the marketplace extension and reloads the application.
  • Bug Fixes
    • Developer Tools settings now persist correctly when disabled.
    • Onboarding no longer appears immediately after restoring the marketplace extension.
  • Tests
    • Added coverage for one-time restoration handling and onboarding behavior.

The developer tools toggle was stuck in the ON position because:
1. The default for developer.enabled was true (always showed ON)
2. Toggling OFF never persisted false to the store
3. Kobalte's controlled Switch always reflected the stale true value
4. Every click triggered onChange(false) but the visual never changed

Fix: default to false, and persist both true/false so the controlled
component reflects reality. The toggle now works bidirectionally:
ON triggers rebuild, OFF restores marketplace and reloads.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f8dd2fe5-cd22-4801-8ce4-5375c3e0e1a6

📥 Commits

Reviewing files that changed from the base of the PR and between 324a5ec and 9cd188a.

📒 Files selected for processing (7)
  • packages/app-bundle/overlay/packages/app/src/components/settings-v2/developer-tools-controller.ts
  • packages/app-bundle/overlay/packages/app/src/context/settings.tsx
  • packages/extension/.gitignore
  • packages/extension/src/chat_bridge.ts
  • packages/extension/src/opencode_config.ts
  • packages/extension/src/substrate/vault_store.ts
  • packages/extension/test/onboarding_routing.test.ts

📝 Walkthrough

Walkthrough

Developer Tools now persists disabled state, restores the marketplace extension through uninstall and install commands, and records a one-time restore marker. Extension activation consumes the marker to bypass onboarding. Developer mode is disabled by default.

Changes

Developer Tools restore flow

Layer / File(s) Summary
Persist toggle state and restore marketplace
packages/app-bundle/overlay/packages/app/src/components/settings-v2/developer-tools-controller.ts, packages/app-bundle/overlay/packages/app/src/context/settings.tsx, packages/extension/src/chat_bridge.ts, packages/extension/.gitignore
The controller persists both toggle states. Developer mode defaults to disabled. The extension disable flow writes a restore marker, reinstalls the marketplace extension, and reloads the window.
Consume restore marker during onboarding
packages/extension/src/substrate/vault_store.ts, packages/extension/src/opencode_config.ts, packages/extension/test/onboarding_routing.test.ts
The vault store supports one-time marker consumption. Onboarding skips its flow when the marker is consumed. Tests cover missing markers, deletion, and onboarding state preservation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeveloperToolsController
  participant settings_developer
  participant chat_bridge
  participant VaultStore
  participant VSCodeCLI
  participant Window
  DeveloperToolsController->>settings_developer: persist disabled value
  DeveloperToolsController->>chat_bridge: send disabled update
  chat_bridge->>VaultStore: write restore marker
  chat_bridge->>VSCodeCLI: uninstall and install marketplace extension
  VSCodeCLI-->>chat_bridge: complete reinstall callback
  chat_bridge->>Window: reload window
Loading
sequenceDiagram
  participant ExtensionActivation
  participant VaultStore
  participant OnboardingRouting
  ExtensionActivation->>VaultStore: consume restore marker
  VaultStore-->>ExtensionActivation: return marker presence
  ExtensionActivation->>OnboardingRouting: evaluate onboarding eligibility
  OnboardingRouting-->>ExtensionActivation: skip onboarding when marker exists
Loading

Suggested reviewers: aarontrowbridge

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/devtools-toggle-stuck-on

Comment @coderabbitai help to get the list of available commands.

…l on toggle OFF

The old backup mechanism captured dist/ once and never refreshed it.
When the extension was republished at the same version (e.g. 0.2.4
rebuilt with new features), the backup stayed stale and toggling OFF
restored an ancient build missing webviews and the Developer Tools
section entirely.

Replace with uninstall+install from the marketplace on toggle OFF.
This always gives a clean dist matching whatever the user is entitled
to on the marketplace — never older, never stale. Onboarding state
survives (stored at ~/.amico/, not in VS Code extension state).
…stall

The uninstall+install cycle clears VS Code globalState, but the
onboarding routing predicate checks a filesystem event at
~/.amico/amicode/onboarding/events.jsonl. Before uninstalling,
ensureOnboardingCompleted() idempotently writes the completion
marker so onboarding never re-triggers on a devtools mode switch.

A manual uninstall+install by the user (outside the toggle) does NOT
write this marker, so onboarding correctly re-triggers for fresh
installs.

Includes tests for the new ensureOnboardingCompleted function.
The previous approach wrote an onboarding_completed event to the
permanent event stream. This polluted the onboarding state: a manual
uninstall+reinstall would never re-trigger onboarding because the
filesystem marker survived.

Replace with a temporary .devtools-restore marker file:
- Toggle OFF writes it before uninstalling
- On next activation, consumeDevtoolsRestoreMarker() reads + deletes it
- If present: skip onboarding (this was a devtools mode switch)
- If absent: onboarding triggers normally (genuine fresh install)

Manual uninstall by the user does not write this marker, so
onboarding correctly re-triggers.
@jeonghun-jj-lee
jeonghun-jj-lee marked this pull request as ready for review August 21, 2026 22:01
@jeonghun-jj-lee
jeonghun-jj-lee merged commit b79f957 into main Aug 21, 2026
6 of 7 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the fix/devtools-toggle-stuck-on branch August 21, 2026 22:01
jeonghun-jj-lee added a commit to harmoniqs/opencode that referenced this pull request Aug 21, 2026
…nally (#223)

The developer tools toggle was stuck in the ON position because:
1. The default for developer.enabled was true (always showed ON)
2. Toggling OFF never persisted false to the store
3. Kobalte's controlled Switch always reflected the stale true value
4. Every click triggered onChange(false) but the visual never changed

Fix: default to false, and persist both true/false so the controlled
component reflects reality. The toggle now works bidirectionally:
ON triggers rebuild, OFF restores marketplace and reloads.

Companion: harmoniqs/amicode#489
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.

1 participant