MCPcopy
hub / github.com/coder/mux / getSendOptionsFromStorage

Function getSendOptionsFromStorage

src/browser/utils/messages/sendOptions.ts:41–91  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

39 * Used by compaction, resume, idle-compaction, and plan execution outside React context.
40 */
41export function getSendOptionsFromStorage(workspaceId: string): SendMessageOptions {
42 const defaultModel = getDefaultModel();
43 const rawModel = readPersistedState<string>(getModelKey(workspaceId), defaultModel);
44 const baseModel = normalizeModelPreference(rawModel, defaultModel);
45
46 // Read thinking level (workspace-scoped).
47 // Migration: if the workspace-scoped value is missing, fall back to legacy per-model storage
48 // once, then persist into the workspace-scoped key.
49 const scopedKey = getThinkingLevelKey(workspaceId);
50 const existingScoped = readPersistedState<ThinkingLevel | undefined>(scopedKey, undefined);
51 const thinkingLevel =
52 existingScoped ??
53 readPersistedState<ThinkingLevel>(
54 getThinkingLevelByModelKey(baseModel),
55 WORKSPACE_DEFAULTS.thinkingLevel
56 );
57 if (existingScoped === undefined) {
58 // Best-effort: avoid losing a user's existing per-model preference.
59 updatePersistedState<ThinkingLevel>(scopedKey, thinkingLevel);
60 }
61
62 const agentId = readPersistedState<string>(
63 getAgentIdKey(workspaceId),
64 WORKSPACE_DEFAULTS.agentId
65 );
66
67 const providerOptions = getProviderOptions();
68
69 const disableWorkspaceAgents = readPersistedState<boolean>(
70 getDisableWorkspaceAgentsKey(workspaceId),
71 false
72 );
73
74 return buildSendMessageOptions({
75 model: baseModel,
76 agentId,
77 thinkingLevel,
78 providerOptions,
79 disableWorkspaceAgents,
80 experiments: {
81 programmaticToolCalling: isExperimentEnabled(EXPERIMENT_IDS.PROGRAMMATIC_TOOL_CALLING),
82 programmaticToolCallingExclusive: isExperimentEnabled(
83 EXPERIMENT_IDS.PROGRAMMATIC_TOOL_CALLING_EXCLUSIVE
84 ),
85 advisorTool: isExperimentEnabled(EXPERIMENT_IDS.ADVISOR_TOOL),
86 execSubagentHardRestart: isExperimentEnabled(EXPERIMENT_IDS.EXEC_SUBAGENT_HARD_RESTART),
87 dynamicWorkflows: isExperimentEnabled(EXPERIMENT_IDS.DYNAMIC_WORKFLOWS),
88 memory: isExperimentEnabled(EXPERIMENT_IDS.MEMORY),
89 },
90 });
91}

Callers 10

handleManualRetryFunction · 0.90
useCreationWorkspaceFunction · 0.90
handleSubmitFunction · 0.90
handleImplementFunction · 0.90
handleContinueInAutoFunction · 0.90
resumeFunction · 0.90
useCompactAndRetryFunction · 0.90
onSendFunction · 0.90

Calls 12

getDefaultModelFunction · 0.90
readPersistedStateFunction · 0.90
getModelKeyFunction · 0.90
normalizeModelPreferenceFunction · 0.90
getThinkingLevelKeyFunction · 0.90
updatePersistedStateFunction · 0.90
getAgentIdKeyFunction · 0.90
buildSendMessageOptionsFunction · 0.90
isExperimentEnabledFunction · 0.90
getProviderOptionsFunction · 0.85

Tested by

no test coverage detected