mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-24 18:52:29 -07:00
feat(workspaces): fix sync path bug and implement dynamic project_id handling
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user