Skip to content

Commit 09edb58

Browse files
committed
refactor(ui-desktop): prefer GOOSE_PATH_ROOT for path resolution
Signed-off-by: Vadim Polulyakh <bavadim@gmail.com> (cherry picked from commit 7f789c8)
1 parent b046416 commit 09edb58

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

ui/desktop/src/bin/jbang

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting jbang setup script."
2222

23-
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
24-
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
25-
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
23+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
2624
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
25+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
26+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
2728
else
2829
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
2930
fi

ui/desktop/src/bin/node-setup-common.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2323

2424
log "Starting node setup (common)."
2525

26-
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
27-
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
28-
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
26+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
2927
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
28+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
29+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
30+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
3031
else
3132
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
3233
fi

ui/desktop/src/bin/uvx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ trap 'log "An error occurred. Exiting with status $?."' ERR
2020

2121
log "Starting uvx setup script."
2222

23-
if [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
24-
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
25-
elif [ -n "${GOOSE_PATH_ROOT:-}" ]; then
23+
if [ -n "${GOOSE_PATH_ROOT:-}" ]; then
2624
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_PATH_ROOT}/config"
25+
elif [ -n "${GOOSE_CONFIG_DIR:-}" ]; then
26+
log "GOOSE_CONFIG_DIR is deprecated for desktop shims; prefer GOOSE_PATH_ROOT."
27+
RESOLVED_GOOSE_CONFIG_DIR="${GOOSE_CONFIG_DIR}"
2728
else
2829
RESOLVED_GOOSE_CONFIG_DIR="${HOME}/.config/goose"
2930
fi

ui/desktop/src/main.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -439,18 +439,12 @@ const getBundledConfig = (): BundledConfig => {
439439
const { defaultProvider, defaultModel, predefinedModels, baseUrlShare, version } =
440440
getBundledConfig();
441441

442-
const resolveGooseConfigDir = (): string => {
443-
const explicitConfigDir = process.env.GOOSE_CONFIG_DIR?.trim();
444-
if (explicitConfigDir) {
445-
return expandTilde(explicitConfigDir);
446-
}
447-
442+
const resolveGoosePathRoot = (): string | undefined => {
448443
const pathRoot = process.env.GOOSE_PATH_ROOT?.trim();
449444
if (pathRoot) {
450-
return path.join(expandTilde(pathRoot), 'config');
445+
return expandTilde(pathRoot);
451446
}
452-
453-
return '~/.config/goose';
447+
return undefined;
454448
};
455449

456450
const GENERATED_SECRET = crypto.randomBytes(32).toString('hex');
@@ -470,8 +464,7 @@ let appConfig = {
470464
GOOSE_DEFAULT_MODEL: defaultModel,
471465
GOOSE_PREDEFINED_MODELS: predefinedModels,
472466
GOOSE_API_HOST: 'http://127.0.0.1',
473-
GOOSE_CONFIG_DIR: resolveGooseConfigDir(),
474-
GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT,
467+
GOOSE_PATH_ROOT: resolveGoosePathRoot(),
475468
GOOSE_WORKING_DIR: '',
476469
// If GOOSE_ALLOWLIST_WARNING env var is not set, defaults to false (strict blocking mode)
477470
GOOSE_ALLOWLIST_WARNING: process.env.GOOSE_ALLOWLIST_WARNING === 'true',
@@ -503,8 +496,7 @@ const createChat = async (
503496
serverSecret,
504497
dir: dir || os.homedir(),
505498
env: {
506-
GOOSE_PATH_ROOT: process.env.GOOSE_PATH_ROOT,
507-
GOOSE_CONFIG_DIR: appConfig.GOOSE_CONFIG_DIR,
499+
GOOSE_PATH_ROOT: appConfig.GOOSE_PATH_ROOT as string | undefined,
508500
},
509501
externalGoosed: settings.externalGoosed,
510502
isPackaged: app.isPackaged,

ui/desktop/src/recipe/recipe_management.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ export const convertToLocaleDateString = (lastModified: string): string => {
4242

4343
export const getStorageDirectory = (isGlobal: boolean): string => {
4444
if (isGlobal) {
45-
const configDir = window.appConfig.get('GOOSE_CONFIG_DIR') as string | undefined;
46-
if (configDir) {
47-
return `${configDir}/recipes`;
48-
}
4945
const pathRoot = window.appConfig.get('GOOSE_PATH_ROOT') as string | undefined;
5046
if (pathRoot) {
5147
return `${pathRoot}/config/recipes`;
5248
}
49+
const configDir = window.appConfig.get('GOOSE_CONFIG_DIR') as string | undefined;
50+
if (configDir) {
51+
return `${configDir}/recipes`;
52+
}
5353
return '~/.config/goose/recipes';
5454
} else {
5555
// For directory recipes, build absolute path using working directory

0 commit comments

Comments
 (0)