You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 30c4f0c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(webview): validate mode slugs and unify the mode-change paths
Review of every mode-change entry point surfaced three inconsistencies:
- handleModeSwitch accepted any slug (the webview "mode" message sends
message.text as Mode with no server-side validation), so unvalidated
callers could persist invalid modes into task history and the view's
durable pin. Validate the slug against built-in + custom modes and
no-op (with a log) on unknown slugs, mirroring
selectTaskFollowupSuggestion.
- Task.submitUserMessage wrote the mode through setValues (raw global
ContextProxy write, no history entry, no TaskModeSwitched/ModeChanged,
no view pin) while every other switch goes through handleModeSwitch.
Route it through handleModeSwitch(mode, this) so an API-initiated
switch is recorded like any other.
- delegateParentAndOpenChild passed the child's mode as as any; drop the
cast now that handleModeSwitch validates.
Test updates:
- sticky-mode: the "invalid mode" test now asserts the ignore behavior;
the module-level getModeBySlug mock's undefined override (leaked past
vi.clearAllMocks, which does not clear implementations) is restored in
the top-level beforeEach so later tests validate through the default;
the slow-init ordering test settles the restore's early durable write
before issuing the mid-init switch, matching the production order in
which a user's switch is issued after the restore starts.
- Task.spec: the submitUserMessage mode test now expects
handleModeSwitch("code", task); the mock provider gains the method.
check-types clean; 336/336 across the six affected spec files; eslint
--prune-suppressions clean (ClineProvider.ts no-explicit-any 12 -> 11).
0 commit comments