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
25 changes: 18 additions & 7 deletions src/commands/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { resolveWorkspace } from '../lib/workspace-resolver.js';
import { CheckpointManager, type CheckpointChange } from '../lib/checkpoint-manager.js';
import { createHash } from 'crypto';
import { getEditingFiles } from '../lib/edit-lock.js';
import { getProfileManager, formatProfileBadge } from '../lib/profile-manager.js';
Comment thread
christse marked this conversation as resolved.

interface WatchOptions {
interval?: number;
Expand Down Expand Up @@ -38,16 +39,22 @@ export async function watchCommand(
const intervalMs = (options.interval || 30) * 1000;
const debounceMs = (options.debounce ?? 5) * 1000;

// Initialize Matrix client (shared across all realms)
const matrixUrl = process.env.MATRIX_URL;
const username = process.env.MATRIX_USERNAME;
const password = process.env.MATRIX_PASSWORD;
// Get credentials from profile manager (falls back to env vars)
const profileManager = getProfileManager();
const credentials = await profileManager.getActiveCredentials();

if (!matrixUrl || !username || !password) {
console.error('Missing required environment variables: MATRIX_URL, MATRIX_USERNAME, MATRIX_PASSWORD');
if (!credentials) {
console.error('No credentials found. Run "boxel profile add" or set environment variables.');
process.exit(1);
}

const { matrixUrl, username, password, profileId } = credentials;

// Show active profile if using one
if (profileId) {
console.log(`${formatProfileBadge(profileId)}\n`);
}
Comment thread
christse marked this conversation as resolved.

const matrixClient = new MatrixClient({
matrixURL: new URL(matrixUrl),
username,
Expand Down Expand Up @@ -170,7 +177,11 @@ export async function watchCommand(
const fileResponse = await fetch(fileUrl, {
headers: {
'Authorization': realm.jwt,
'Accept': file.endsWith('.json') ? 'application/vnd.card+json' : '*/*',
'Accept': file.endsWith('.json')
? 'application/vnd.card+json'
: file.endsWith('.gts')
? 'application/vnd.card+source'
: '*/*',
},
});

Expand Down
Loading