mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: npub1d6t84ajeg9skp2609l2k6axgcme8x7g7u7luj352r03hcwreg7lqnxcsex <6e967af659416160ab4f2fd56d74c8c6f273791ee7bfc9468a1be37c387947be@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1s654z6utm59mkg4tjdqw69tlen05y2hrrwajlck4n2ar0jyx7hfsmp60kf <86a9516b8bdd0bbb22ab9340ed157fccdf422ae31bbb2fe2d59aba37c886f5d3@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1d6t84ajeg9skp2609l2k6axgcme8x7g7u7luj352r03hcwreg7lqnxcsex <6e967af659416160ab4f2fd56d74c8c6f273791ee7bfc9468a1be37c387947be@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1s654z6utm59mkg4tjdqw69tlen05y2hrrwajlck4n2ar0jyx7hfsmp60kf <86a9516b8bdd0bbb22ab9340ed157fccdf422ae31bbb2fe2d59aba37c886f5d3@sprout-oss.stage.blox.sqprod.co>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import * as React from "react";
|
|
|
|
import { useBakedBuildEnvQuery } from "../hooks";
|
|
import { useGlobalAgentConfig } from "../useGlobalAgentConfig";
|
|
import { BUZZ_AGENT_THINKING_EFFORT } from "./buzzAgentConfig";
|
|
import { getInheritedAgentDefaults } from "./bakedEnvHelpers";
|
|
|
|
export function useAgentDialogDefaults({
|
|
inheritedEnvVars = {},
|
|
open,
|
|
}: {
|
|
inheritedEnvVars?: Record<string, string>;
|
|
open: boolean;
|
|
}) {
|
|
const { globalConfig } = useGlobalAgentConfig();
|
|
const { data: bakedEnv } = useBakedBuildEnvQuery({ enabled: open });
|
|
const inheritedDefaults = getInheritedAgentDefaults(globalConfig, bakedEnv);
|
|
const effectiveInheritedEnvVars = React.useMemo(
|
|
() => ({
|
|
...globalConfig.env_vars,
|
|
...inheritedEnvVars,
|
|
...(inheritedDefaults.effort.value
|
|
? { [BUZZ_AGENT_THINKING_EFFORT]: inheritedDefaults.effort.value }
|
|
: {}),
|
|
}),
|
|
[globalConfig.env_vars, inheritedDefaults.effort.value, inheritedEnvVars],
|
|
);
|
|
return {
|
|
globalConfig,
|
|
inheritedDefaults,
|
|
inheritedEnvVars: effectiveInheritedEnvVars,
|
|
};
|
|
}
|