mirror of
https://github.com/stablyai/orca.git
synced 2026-10-03 00:02:19 +00:00
* feat(native-chat): one shell-environment setting for every structured chat Structured Codex chats started from the login-shell environment, while structured Claude chats started from Orca's own process environment, so a variable exported in .zshrc reached one and not the other. Both now start from the same base, chosen by a new setting: - on (default): the whole login-shell environment, as a terminal gets - off: Orca's environment plus PATH, locale, SSH_AUTH_SOCK, and the variable names the user lists The setting is re-read each time a chat starts or resumes. It is shown only when Chat UI, the Chat UI default view, and structured native chat are all on. Terminal-backed chat is unchanged. * fix(native-chat): normalize the shell-environment settings when a profile loads A hand-edited settings file could store the variable list as something other than an array, and the structured runtime called `.filter` on it per launch, so a malformed value failed every structured chat create and resume, and the settings pane render. Normalize both keys where the profile loads, the same way the other array settings are, through one shared normalizer the runtime policy also uses. Also pin that an uncommitted name draft survives an unrelated settings re-render. * fix(native-chat): keep the pinned account as the only source of a structured chat's Claude home The session record owns which Claude home a structured chat uses, and the acquisition pin (claudeConfigDirEnvPatch) is the only emitter of CLAUDE_CONFIG_DIR, compared against what the child would otherwise inherit. With the login-shell snapshot as the inherited base, a CLAUDE_CONFIG_DIR exported only in a shell rc flipped that comparison and produced an explicit pin to the CLI default home, which moves the CLI off its default Keychain item. Drop the inherited CLAUDE_CONFIG_DIR in the Claude launch resolver before the pin runs, as Codex already does for an inherited CODEX_HOME. A configured per-agent overlay still passes through, since the record already honors it. * fix(native-chat): drop Orca's own CLAUDE_CONFIG_DIR from a structured Claude child too The process spawner merges Orca's process env under the launch env, so a CLAUDE_CONFIG_DIR exported to Orca itself reached the child around the launch resolver's drop and unseen by the account pin. One helper now strips it from both inherited bases. Also declare the two shell-environment settings on the runtime store contract and add the six new strings to every locale catalog. * feat(native-chat): add shell variables one at a time with a removable list * fix(native-chat): return focus to the name input after removing a shell variable * fix(native-chat): use a neutral placeholder for the shell variable input The empty input showed a grey HTTPS_PROXY as its placeholder, which reads as a saved value, especially right after that exact entry is removed from the list. Use "Variable name" instead, in every locale catalog.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { GlobalSettings } from './global-settings-types'
|
|
|
|
/** Which login-shell variables a structured native chat child inherits. */
|
|
export type NativeChatShellEnvironmentPolicy = {
|
|
inheritAll: boolean
|
|
names: readonly string[]
|
|
}
|
|
|
|
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/
|
|
|
|
/** One whole variable name, as a shell would accept it; the only rule the list control and the normalizer share. */
|
|
export function isNativeChatShellEnvironmentName(value: string): boolean {
|
|
return ENV_NAME.test(value)
|
|
}
|
|
|
|
/** The persisted list as a valid, deduplicated name list; anything malformed (hand-edited file) is empty. */
|
|
export function normalizeNativeChatShellEnvironmentVariables(value: unknown): string[] {
|
|
if (!Array.isArray(value)) {
|
|
return []
|
|
}
|
|
const names: string[] = []
|
|
for (const entry of value) {
|
|
// Validate each saved entry whole; re-splitting would turn "not valid" into two names.
|
|
if (
|
|
typeof entry === 'string' &&
|
|
isNativeChatShellEnvironmentName(entry) &&
|
|
!names.includes(entry)
|
|
) {
|
|
names.push(entry)
|
|
}
|
|
}
|
|
return names
|
|
}
|
|
|
|
export function nativeChatShellEnvironmentPolicy(
|
|
settings: Pick<
|
|
GlobalSettings,
|
|
'nativeChatInheritShellEnvironment' | 'nativeChatShellEnvironmentVariables'
|
|
> | null
|
|
): NativeChatShellEnvironmentPolicy {
|
|
return {
|
|
inheritAll: settings?.nativeChatInheritShellEnvironment !== false,
|
|
names: normalizeNativeChatShellEnvironmentVariables(
|
|
settings?.nativeChatShellEnvironmentVariables
|
|
)
|
|
}
|
|
}
|