Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions packages/boxel-cli/src/commands/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,29 @@ async function addProfile(manager: ProfileManager): Promise<void> {
console.log(`Which environment?`);
console.log(` ${FG_CYAN}1${RESET}) Staging (realms-staging.stack.cards)`);
console.log(` ${FG_MAGENTA}2${RESET}) Production (app.boxel.ai)`);
console.log(` ${FG_GREEN}3${RESET}) Local (localhost:4201)`);

const envChoice = await prompt('\nChoice [1/2]: ');
const envChoice = await prompt('\nChoice [1/2/3]: ');
const isProduction = envChoice === '2';

const domain = isProduction ? 'boxel.ai' : 'stack.cards';
const defaultMatrixUrl = isProduction
? 'https://matrix.boxel.ai'
: 'https://matrix-staging.stack.cards';
const defaultRealmUrl = isProduction
? 'https://app.boxel.ai/'
: 'https://realms-staging.stack.cards/';
const isLocal = envChoice === '3';

let domain: string;
let defaultMatrixUrl: string;
let defaultRealmUrl: string;

if (isLocal) {
domain = 'localhost';
defaultMatrixUrl = 'http://localhost:8008';
defaultRealmUrl = 'http://localhost:4201/';
} else if (isProduction) {
domain = 'boxel.ai';
defaultMatrixUrl = 'https://matrix.boxel.ai';
defaultRealmUrl = 'https://app.boxel.ai/';
} else {
domain = 'stack.cards';
defaultMatrixUrl = 'https://matrix-staging.stack.cards';
defaultRealmUrl = 'https://realms-staging.stack.cards/';
}

console.log(`\nEnter your Boxel username (without @ or domain)`);
console.log(`${DIM}Example: ctse, aallen90${RESET}`);
Expand Down
5 changes: 4 additions & 1 deletion packages/boxel-cli/src/lib/profile-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface ProfilesConfig {
activeProfile: string | null;
}

export type Environment = 'staging' | 'production' | 'unknown';
export type Environment = 'staging' | 'production' | 'local' | 'unknown';

/**
* Extract environment from Matrix user ID
Expand All @@ -37,6 +37,7 @@ export type Environment = 'staging' | 'production' | 'unknown';
export function getEnvironmentFromMatrixId(matrixId: string): Environment {
if (matrixId.endsWith(':stack.cards')) return 'staging';
if (matrixId.endsWith(':boxel.ai')) return 'production';
if (matrixId.endsWith(':localhost')) return 'local';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit URL handling for localhost profiles

Returning 'local' for :localhost makes ProfileManager.addProfile() treat @user:localhost as a known environment, so the non-interactive path (boxel profile add -u ... -p ...) no longer requires explicit URLs and silently falls back to the staging defaults (https://matrix-staging.stack.cards and https://realms-staging.stack.cards/). In practice, local profiles created this way point to staging endpoints and break local auth/workflows; addProfile needs a local default branch (or localhost should remain unknown until that branch exists).

Useful? React with 👍 / 👎.

return 'unknown';
}

Expand Down Expand Up @@ -67,6 +68,8 @@ export function getEnvironmentLabel(env: Environment): string {
return 'stack.cards';
case 'production':
return 'boxel.ai';
case 'local':
return 'localhost';
default:
return 'unknown';
}
Expand Down