feat(workspaces): fix sync path bug and implement dynamic project_id handling

This commit is contained in:
mkorwel
2026-03-19 09:25:38 -07:00
parent a0db453abe
commit 26ce07d89b
8 changed files with 15 additions and 9 deletions
@@ -92,9 +92,7 @@ export async function connectToWorkspace(args: ArgumentsCamelCase<ConnectArgs>):
}
}
const { instance_name: instanceName, zone } = readyWs;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const project = process.env['GOOGLE_CLOUD_PROJECT'] || 'dev-project';
const { instance_name: instanceName, zone, project_id: projectId } = readyWs;
const ssh = new SSHService();
// 1. Sync settings if enabled
@@ -106,7 +104,7 @@ export async function connectToWorkspace(args: ArgumentsCamelCase<ConnectArgs>):
await sync.pushSettings({
instanceName,
zone,
project,
project: projectId,
});
// eslint-disable-next-line no-console
console.log(chalk.green(`✓ Settings synced.`));
@@ -122,7 +120,7 @@ export async function connectToWorkspace(args: ArgumentsCamelCase<ConnectArgs>):
// eslint-disable-next-line no-console
console.log(chalk.yellow('Injecting GitHub credentials...'));
try {
await ssh.pushSecret({ instanceName, zone, project }, '.gh_token', pat);
await ssh.pushSecret({ instanceName, zone, project: projectId }, '.gh_token', pat);
// eslint-disable-next-line no-console
console.log(chalk.green('✓ Credentials injected.'));
} catch (err) {
@@ -141,7 +139,7 @@ export async function connectToWorkspace(args: ArgumentsCamelCase<ConnectArgs>):
await ssh.connect({
instanceName,
zone,
project,
project: projectId,
command: remoteCommand,
forwardAgent: args.forwardAgent,
});
@@ -50,7 +50,7 @@ describe('SyncService', () => {
'scp',
'--recurse',
'/mock/local/dir/settings.json',
'test-inst:',
'test-inst:.gemini/',
'--zone=us-west1-a',
'--project=test-project',
'--tunnel-through-iap',
+2 -2
View File
@@ -23,8 +23,8 @@ export class SyncService {
const { instanceName, zone, project } = options;
const localDir = Storage.getGlobalGeminiDir();
// Fix: Using the home directory as destination to avoid nested .gemini/.gemini
const remotePath = `${instanceName}:`;
// Fix: Ensure files are placed in the .gemini directory on the remote
const remotePath = `${instanceName}:.gemini/`;
// Performance/Robustness: Exclude large and local-only folders.
// Since gcloud scp doesn't support --exclude, we could either:
@@ -14,6 +14,7 @@ export interface WorkspaceHubInfo {
status: string;
machine_type: string;
zone: string;
project_id: string;
created_at: string;
owner_id: string;
}
@@ -53,6 +53,7 @@ router.post('/', async (req, res) => {
status: 'PROVISIONING',
machine_type: machineType,
zone,
project_id: computeService.getProjectId(),
created_at: new Date().toISOString(),
};
@@ -23,6 +23,10 @@ export class ComputeService {
this.projectId = process.env['GOOGLE_CLOUD_PROJECT'] || 'dev-project';
}
getProjectId(): string {
return this.projectId;
}
/**
* Provision a new GCE VM with the Workspace Container
*/
@@ -55,6 +55,7 @@ describe('WorkspaceService', () => {
status: 'READY',
machine_type: 'e2',
zone: 'us1',
project_id: 'p1',
created_at: 'now',
};
await service.createWorkspace('id1', data);
@@ -13,6 +13,7 @@ export interface WorkspaceData {
status: string;
machine_type: string;
zone: string;
project_id: string;
created_at: string;
}