-
Notifications
You must be signed in to change notification settings - Fork 28
🤖 Add command palette control for thinking effort #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import NewWorkspaceModal from "./components/NewWorkspaceModal"; | |
| import { AIView } from "./components/AIView"; | ||
| import { ErrorBoundary } from "./components/ErrorBoundary"; | ||
| import { TipsCarousel } from "./components/TipsCarousel"; | ||
| import { usePersistedState } from "./hooks/usePersistedState"; | ||
| import { usePersistedState, updatePersistedState } from "./hooks/usePersistedState"; | ||
| import { matchesKeybind, KEYBINDS } from "./utils/ui/keybinds"; | ||
| import { useProjectManagement } from "./hooks/useProjectManagement"; | ||
| import { useWorkspaceManagement } from "./hooks/useWorkspaceManagement"; | ||
|
|
@@ -21,6 +21,12 @@ import { CommandPalette } from "./components/CommandPalette"; | |
| import { buildCoreSources, type BuildSourcesParams } from "./utils/commands/sources"; | ||
| import { useGitStatus } from "./hooks/useGitStatus"; | ||
|
|
||
| import type { ThinkingLevel } from "./types/thinking"; | ||
| import { CUSTOM_EVENTS } from "./constants/events"; | ||
| import { getThinkingLevelKey } from "./constants/storage"; | ||
|
|
||
| const THINKING_LEVELS: ThinkingLevel[] = ["off", "low", "medium", "high"]; | ||
|
|
||
| // Global Styles with nice fonts | ||
| const globalStyles = css` | ||
| * { | ||
|
|
@@ -277,6 +283,51 @@ function AppInner() { | |
| close: closeCommandPalette, | ||
| } = useCommandRegistry(); | ||
|
|
||
| const getThinkingLevelForWorkspace = useCallback((workspaceId: string): ThinkingLevel => { | ||
| if (!workspaceId) { | ||
| return "off"; | ||
| } | ||
|
|
||
| if (typeof window === "undefined" || !window.localStorage) { | ||
| return "off"; | ||
| } | ||
|
|
||
| try { | ||
| const key = getThinkingLevelKey(workspaceId); | ||
| const stored = window.localStorage.getItem(key); | ||
| if (!stored || stored === "undefined") { | ||
| return "off"; | ||
| } | ||
| const parsed = JSON.parse(stored) as ThinkingLevel; | ||
| return THINKING_LEVELS.includes(parsed) ? parsed : "off"; | ||
| } catch (error) { | ||
| console.warn("Failed to read thinking level", error); | ||
| return "off"; | ||
| } | ||
| }, []); | ||
|
|
||
| const setThinkingLevelFromPalette = useCallback((workspaceId: string, level: ThinkingLevel) => { | ||
| if (!workspaceId) { | ||
| return; | ||
| } | ||
|
|
||
| const normalized = THINKING_LEVELS.includes(level) ? level : "off"; | ||
| const key = getThinkingLevelKey(workspaceId); | ||
|
|
||
| // Use the utility function which handles localStorage and event dispatch | ||
| // ThinkingProvider will pick this up via its listener | ||
| updatePersistedState(key, normalized); | ||
|
|
||
| // Dispatch toast notification event for UI feedback | ||
| if (typeof window !== "undefined") { | ||
| window.dispatchEvent( | ||
| new CustomEvent(CUSTOM_EVENTS.THINKING_LEVEL_TOAST, { | ||
| detail: { workspaceId, level: normalized }, | ||
| }) | ||
| ); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here re coupling |
||
| }, []); | ||
|
|
||
| const registerParamsRef = useRef<BuildSourcesParams | null>(null); | ||
|
|
||
| const openNewWorkspaceFromPalette = useCallback( | ||
|
|
@@ -343,6 +394,8 @@ function AppInner() { | |
| workspaceMetadata, | ||
| selectedWorkspace, | ||
| streamingModels, | ||
| getThinkingLevel: getThinkingLevelForWorkspace, | ||
| onSetThinkingLevel: setThinkingLevelFromPalette, | ||
| onOpenNewWorkspaceModal: openNewWorkspaceFromPalette, | ||
| onCreateWorkspace: createWorkspaceFromPalette, | ||
| onSelectWorkspace: selectWorkspaceFromPalette, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /** | ||
| * Custom Event Constants | ||
| * These are window-level custom events used for cross-component communication | ||
| */ | ||
|
|
||
| export const CUSTOM_EVENTS = { | ||
| /** | ||
| * Event to show a toast notification when thinking level changes | ||
| * Detail: { workspaceId: string, level: ThinkingLevel } | ||
| */ | ||
| THINKING_LEVEL_TOAST: "cmux:thinkingLevelToast", | ||
|
|
||
| /** | ||
| * Event to insert text into the chat input | ||
| * Detail: { text: string } | ||
| */ | ||
| INSERT_TO_CHAT_INPUT: "cmux:insertToChatInput", | ||
|
|
||
| /** | ||
| * Event to open the model selector | ||
| * No detail | ||
| */ | ||
| OPEN_MODEL_SELECTOR: "cmux:openModelSelector", | ||
| } as const; | ||
|
|
||
| /** | ||
| * Helper to create a storage change event name for a specific key | ||
| * Used by usePersistedState for same-tab synchronization | ||
| */ | ||
| export const getStorageChangeEvent = (key: string): string => `storage-change:${key}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /** | ||
| * LocalStorage Key Constants and Helpers | ||
| * These keys are used for persisting state in localStorage | ||
| */ | ||
|
|
||
| /** | ||
| * Helper to create a thinking level storage key for a workspace | ||
| * Format: "thinkingLevel:{workspaceId}" | ||
| */ | ||
| export const getThinkingLevelKey = (workspaceId: string): string => `thinkingLevel:${workspaceId}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sidenote: App.tsx is becoming a monster but that can be handled elsewhere