Skip to content

fix(vscode): allow /yolo and /auto before the first message - #31

Merged
elkaix merged 2 commits into
mainfrom
fix/vscode-permission-command-before-session
Aug 6, 2026
Merged

fix(vscode): allow /yolo and /auto before the first message#31
elkaix merged 2 commits into
mainfrom
fix/vscode-permission-command-before-session

Conversation

@elkaix

@elkaix elkaix commented Aug 6, 2026

Copy link
Copy Markdown
Member

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.

/yolo and /auto take 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:

  • PythinkerRuntime holds a pending permission mode per webview and hands it to the session on open/attach, consuming it once.
  • The setPermissionMode handler falls back to that pending target when the view has no session, seeded from the pythinker.yoloMode setting so a toggle reports the right resulting mode and message.
  • applyPermissionCommand now 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

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Summary by CodeRabbit

  • New Features
    • VS Code /yolo and /auto permission commands now work before the first message and apply to the next session.
  • Style
    • Improved dark-theme inline-code readability with a brighter periwinkle accent.
  • Bug Fixes
    • Permission settings are preserved when a session has not yet been opened and applied automatically when it starts.

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.
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 799edccc-96d6-4699-91a7-56874997e538

📥 Commits

Reviewing files that changed from the base of the PR and between c3dbed6 and 2f28751.

📒 Files selected for processing (2)
  • apps/vscode/src/runtime/pythinker-runtime.ts
  • apps/vscode/test/pythinker-runtime.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/vscode/test/pythinker-runtime.test.ts
  • apps/vscode/src/runtime/pythinker-runtime.ts

📝 Walkthrough

Walkthrough

The 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.

Changes

Pre-session permission commands

Layer / File(s) Summary
Permission target contract and command entry
apps/vscode/src/runtime/permission-mode.ts, apps/vscode/src/handlers/slash-command.ts, apps/vscode/src/handlers/chat.handler.ts
PermissionModeTarget supports live and pending targets. Permission commands now create a pending target when no session exists.
Pending mode application and validation
apps/vscode/src/runtime/pythinker-runtime.ts, apps/vscode/test/pythinker-runtime.test.ts
Pending modes are stored per webview, applied when sessions open or resume, consumed after application, and preserved when application fails.

Dark-theme accent update

Layer / File(s) Summary
Accent color and release metadata
apps/vscode/webview-ui/src/styles/index.css, .changeset/vscode-inline-code-color.md, .changeset/vscode-permission-command-before-first-message.md
The dark-theme --brand color changes to #b3b9f4. Patch changesets document the accent and permission-command updates.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the fix(vscode) prefix, imperative mood, and clearly describes the main change within 72 characters.
Description check ✅ Passed The description includes all required sections, explains the problem and solution, and confirms tests, changesets, and documentation checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@pythoughts/pythinker-code@2f28751
npx https://pkg.pr.new/@pythoughts/pythinker-code@2f28751

commit: 2f28751

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 463b176 and c3dbed6.

📒 Files selected for processing (8)
  • .changeset/vscode-inline-code-color.md
  • .changeset/vscode-permission-command-before-first-message.md
  • apps/vscode/src/handlers/chat.handler.ts
  • apps/vscode/src/handlers/slash-command.ts
  • apps/vscode/src/runtime/permission-mode.ts
  • apps/vscode/src/runtime/pythinker-runtime.ts
  • apps/vscode/test/pythinker-runtime.test.ts
  • apps/vscode/webview-ui/src/styles/index.css

Comment thread apps/vscode/src/runtime/pythinker-runtime.ts
@elkaix
elkaix merged commit e5e9de4 into main Aug 6, 2026
12 checks passed
@elkaix
elkaix deleted the fix/vscode-permission-command-before-session branch August 6, 2026 03:19
elkaix added a commit that referenced this pull request Aug 7, 2026
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>
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