Skip to content

Commit 01229ca

Browse files
authored
🤖 Make 1M context setting global instead of per-workspace (#120)
## Summary Make the 1M context checkbox setting global instead of per-workspace. ## Changes - Updated `use1MContext` hook to use global localStorage key - Removed `workspaceId` parameter from hook signature - Updated all call sites: Context1MCheckbox, CostsTab, ChatInput - Removed `workspaceId` from ChatContext (no longer needed) - **Bonus:** Added closed PR detection to `wait_pr_checks.sh` script ## Rationale Users typically want 1M context either on or off everywhere. Per-workspace state caused confusion when switching between workspaces. ## Testing - ✅ make typecheck - ✅ make test (273 tests passing) _Generated with `cmux`_
1 parent 049f640 commit 01229ca

File tree

8 files changed

+19
-27
lines changed

8 files changed

+19
-27
lines changed

scripts/wait_pr_checks.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ while true; do
3030
exit 0
3131
fi
3232

33+
# Check if PR is closed without merging
34+
if [ "$PR_STATE" = "CLOSED" ]; then
35+
echo "❌ PR #$PR_NUMBER is closed (not merged)!"
36+
exit 1
37+
fi
38+
3339
MERGEABLE=$(echo "$STATUS" | jq -r '.mergeable')
3440
MERGE_STATE=$(echo "$STATUS" | jq -r '.mergeStateStatus')
3541

src/components/AIView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,7 @@ const AIViewInner: React.FC<AIViewProps> = ({
320320
}
321321

322322
return (
323-
<ChatProvider
324-
messages={messages}
325-
cmuxMessages={cmuxMessages}
326-
model={currentModel}
327-
workspaceId={workspaceId}
328-
>
323+
<ChatProvider messages={messages} cmuxMessages={cmuxMessages} model={currentModel}>
329324
<ViewContainer className={className}>
330325
<ChatArea>
331326
<ViewHeader>

src/components/ChatInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
306306
const modelSelectorRef = useRef<ModelSelectorRef>(null);
307307
const [thinkingLevel] = useThinkingLevel();
308308
const [mode, setMode] = useMode();
309-
const [use1M] = use1MContext(workspaceId);
309+
const [use1M] = use1MContext();
310310
const { recentModels } = useModelLRU();
311311

312312
const focusMessageInput = useCallback(() => {
@@ -763,7 +763,7 @@ export const ChatInput: React.FC<ChatInputProps> = ({
763763
</EditingIndicator>
764764
)}
765765
<ModeTogglesRow>
766-
<ChatToggles workspaceId={workspaceId} modelString={preferredModel}>
766+
<ChatToggles modelString={preferredModel}>
767767
<ModelDisplayWrapper>
768768
<ModelSelector
769769
ref={modelSelectorRef}

src/components/ChatMetaSidebar/CostsTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ const VIEW_MODE_OPTIONS: Array<ToggleOption<ViewMode>> = [
280280
];
281281

282282
export const CostsTab: React.FC = () => {
283-
const { stats, isCalculating, workspaceId } = useChatContext();
283+
const { stats, isCalculating } = useChatContext();
284284
const [viewMode, setViewMode] = usePersistedState<ViewMode>("costsTab:viewMode", "last-request");
285-
const [use1M] = use1MContext(workspaceId);
285+
const [use1M] = use1MContext();
286286

287287
// Only show loading if we don't have any stats yet
288288
if (isCalculating && !stats) {

src/components/ChatToggles.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ export const TogglesContainer = styled.div`
1010
`;
1111

1212
interface ChatTogglesProps {
13-
workspaceId: string;
1413
modelString: string;
1514
children: React.ReactNode;
1615
}
1716

18-
export const ChatToggles: React.FC<ChatTogglesProps> = ({ workspaceId, modelString, children }) => {
17+
export const ChatToggles: React.FC<ChatTogglesProps> = ({ modelString, children }) => {
1918
return (
2019
<TogglesContainer>
2120
{children}
2221
<ThinkingSliderComponent />
23-
<Context1MCheckbox workspaceId={workspaceId} modelString={modelString} />
22+
<Context1MCheckbox modelString={modelString} />
2423
</TogglesContainer>
2524
);
2625
};

src/components/Context1MCheckbox.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ const Checkbox = styled.input`
5959
`;
6060

6161
interface Context1MCheckboxProps {
62-
workspaceId: string;
6362
modelString: string;
6463
}
6564

66-
export const Context1MCheckbox: React.FC<Context1MCheckboxProps> = ({
67-
workspaceId,
68-
modelString,
69-
}) => {
70-
const [use1M, setUse1M] = use1MContext(workspaceId);
65+
export const Context1MCheckbox: React.FC<Context1MCheckboxProps> = ({ modelString }) => {
66+
const [use1M, setUse1M] = use1MContext();
7167
const isSupported = supports1MContext(modelString);
7268

7369
if (!isSupported) {

src/contexts/ChatContext.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ interface ChatContextType {
88
messages: DisplayedMessage[];
99
stats: ChatStats | null;
1010
isCalculating: boolean;
11-
workspaceId: string;
1211
}
1312

1413
const ChatContext = createContext<ChatContextType | undefined>(undefined);
@@ -18,15 +17,13 @@ interface ChatProviderProps {
1817
messages: DisplayedMessage[];
1918
cmuxMessages: CmuxMessage[];
2019
model: string;
21-
workspaceId: string;
2220
}
2321

2422
export const ChatProvider: React.FC<ChatProviderProps> = ({
2523
children,
2624
messages,
2725
cmuxMessages,
2826
model,
29-
workspaceId,
3027
}) => {
3128
const [stats, setStats] = useState<ChatStats | null>(null);
3229
const [isCalculating, setIsCalculating] = useState(false);
@@ -91,7 +88,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
9188
}, [cmuxMessages, model]);
9289

9390
return (
94-
<ChatContext.Provider value={{ messages, stats, isCalculating, workspaceId }}>
91+
<ChatContext.Provider value={{ messages, stats, isCalculating }}>
9592
{children}
9693
</ChatContext.Provider>
9794
);

src/hooks/use1MContext.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { usePersistedState } from "@/hooks/usePersistedState";
22

33
/**
44
* Custom hook for 1M context state.
5-
* Persists state per workspace in localStorage.
5+
* Persists state globally in localStorage (applies to all workspaces).
66
*
7-
* @param workspaceId - Unique identifier for the workspace
87
* @returns [use1MContext, setUse1MContext] tuple
98
*/
10-
export function use1MContext(workspaceId: string): [boolean, (value: boolean) => void] {
11-
return usePersistedState<boolean>(`use1MContext:${workspaceId}`, false);
9+
export function use1MContext(): [boolean, (value: boolean) => void] {
10+
return usePersistedState<boolean>("use1MContext", false);
1211
}

0 commit comments

Comments
 (0)