fix(vscode): allow /yolo and /auto before the first message - #31
Conversation
The permission commands take a control path to the extension host, which resolved the view's session and bailed when there was none. A session is created lazily by the first message, so the command failed with "Could not change the permission mode." every time it was used to set the mode up front. The request is now parked on the view and applied to the session that view opens next. Also brightens the dark-theme periwinkle accent used for inline code in chat.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR enables VS Code permission commands before a session exists by storing per-webview pending modes and applying them when a session opens or resumes. It also updates the dark-theme accent color and adds patch changesets. ChangesPre-session permission commands
Dark-theme accent update
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ChatHandler
participant PythinkerRuntime
participant WebviewSession
User->>ChatHandler: Run /yolo or /auto
ChatHandler->>PythinkerRuntime: Create pending permission target
PythinkerRuntime-->>ChatHandler: Store requested mode
WebviewSession->>PythinkerRuntime: Open or resume session
PythinkerRuntime->>WebviewSession: Apply pending mode
PythinkerRuntime->>PythinkerRuntime: Consume pending mode
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/vscode/src/runtime/pythinker-runtime.ts`:
- Around line 240-243: Update the pending-permission handling around
pendingPermissionByView and runtime.setPermissionMode so the map entry is
removed only after setPermissionMode succeeds. After the await, delete
conditionally only when the stored value still equals the applied pending value,
preserving any newer command received during the await; retain the entry when
application rejects.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 86bc5997-4a93-4b1e-a833-14cb47354895
📒 Files selected for processing (8)
.changeset/vscode-inline-code-color.md.changeset/vscode-permission-command-before-first-message.mdapps/vscode/src/handlers/chat.handler.tsapps/vscode/src/handlers/slash-command.tsapps/vscode/src/runtime/permission-mode.tsapps/vscode/src/runtime/pythinker-runtime.tsapps/vscode/test/pythinker-runtime.test.tsapps/vscode/webview-ui/src/styles/index.css
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @pythoughts/pythinker-code@0.10.0 ### Minor Changes - [#30](#30) [`463b176`](463b176) - Let a Dynamic Workflow run its subagents on a different model than the agent orchestrating them. `DynamicWorkflow` accepts `model` and `effort` for every subagent in the call, and `/workflow model <alias>` sets that model for the session so an expensive orchestrator can hand mechanical work to a cheaper or faster one. ### Patch Changes - [#28](#28) [`cf5b6b1`](cf5b6b1) - Keep a subagent on the model and effort its profile assigns when the subagent is resumed or retried, instead of reverting it to the main agent's model. - [#31](#31) [`e5e9de4`](e5e9de4) - Brighten the periwinkle accent in the VS Code extension's dark theme so inline code in chat is easier to read. - [#31](#31) [`e5e9de4`](e5e9de4) - Let `/yolo` and `/auto` be used in the VS Code extension before the first message is sent — the request now applies to the session that chat opens next instead of failing with "Could not change the permission mode." Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: M Elkholy <melkholy@techmatrix.com>
Related Issue
No issue filed — the problem is described below.
Problem
In the VS Code extension, typing
/yolo(or/auto) before sending anything to the agent shows a "Could not change the permission mode." toast and does nothing. The same command works once a message has been sent./yoloand/autotake a control path to the extension host instead of the chat queue, so they still work mid-turn. That handler resolves the view's session and returns{ ok: false }when there is none — and a session is only created lazily, by the first message. Setting the mode up front, which is exactly when a user reaches for/yolo, was therefore the one case that always failed.What changed
The request is parked on the view and applied to the session that view opens next, so the command is never dropped:
PythinkerRuntimeholds a pending permission mode per webview and hands it to the session on open/attach, consuming it once.setPermissionModehandler falls back to that pending target when the view has no session, seeded from thepythinker.yoloModesetting so a toggle reports the right resulting mode and message.applyPermissionCommandnow takes a small target interface that both a live session and the pending target satisfy, so the toggle semantics and toast wording are identical in either path.Also brightens the dark-theme periwinkle accent (
--brand) used for inline code in chat, which was hard to read against the message background.Covered by a new case in the runtime tests: a mode requested with no session is applied to the next session opened by that view, and is not reapplied afterwards. Verified the test fails when the apply step is removed.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.Summary by CodeRabbit
/yoloand/autopermission commands now work before the first message and apply to the next session.