Skip to content

Commit 3c27970

Browse files
committed
fix(cli): preserve template workspace metadata
Signed-off-by: Mrunal Patel <[email protected]>
1 parent e3c45dc commit 3c27970

4 files changed

Lines changed: 42 additions & 16 deletions

File tree

‎.agents/skills/tui-development/SKILL.md‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,20 @@ Proto types come from `openshell-core` which generates them from `OUT_DIR` via `
469469

470470
```rust
471471
use openshell_core::proto::openshell_client::OpenShellClient;
472-
use openshell_core::proto::{ListSandboxesRequest, GetSandboxLogsRequest, ...};
472+
use openshell_core::proto::{
473+
all_workspaces_selector, workspace_selector, GetSandboxLogsRequest,
474+
ListSandboxesRequest, ...
475+
};
473476
```
474477

475478
### Proto field gotchas
476479

477480
- `DeleteSandboxRequest` uses the `name` field (not `id`):
478481
```rust
479-
let req = openshell_core::proto::DeleteSandboxRequest { name: sandbox_name };
482+
let req = openshell_core::proto::DeleteSandboxRequest {
483+
name: sandbox_name,
484+
workspace_scope: Some(workspace_selector(workspace)),
485+
};
480486
```
481487
- `WatchSandboxRequest` has extra fields beyond what you might need — always use `..Default::default()`:
482488
```rust
@@ -490,12 +496,24 @@ use openshell_core::proto::{ListSandboxesRequest, GetSandboxLogsRequest, ...};
490496
};
491497
```
492498
- `SandboxLogLine` proto fields: `sandbox_id`, `timestamp_ms`, `level`, `target`, `message`, `source`, `fields` (HashMap<String, String>).
493-
- `GetSandboxLogsRequest` fields: `sandbox_id`, `lines` (u32), `since_ms` (i64), `sources` (Vec<String>), `min_level` (String), `workspace` (String).
494-
- `ListSandboxesRequest` fields: `limit` (i64), `offset` (i64), `label_selector` (String), `workspace` (String), `all_workspaces` (bool).
495-
- `ListProvidersRequest` fields: `limit` (i64), `offset` (i64), `workspace` (String), `all_workspaces` (bool).
496-
- `ListWorkspacesRequest` fields: `limit` (i64), `offset` (i64), `label_selector` (String).
497-
- `UpdateConfigRequest` fields: `name` (String, sandbox name or empty for global), `setting_key`, `setting_value`, `delete_setting` (bool), `global` (bool), `workspace`.
498-
- Most resource requests include a `workspace` field that scopes the operation to the current workspace.
499+
- Workspace-scoped request fields use `workspace_scope: Option<WorkspaceSelector>`.
500+
Select one workspace with `Some(workspace_selector(name))`. List requests that
501+
explicitly support cross-workspace access also accept
502+
`Some(all_workspaces_selector())`; do not use that marker on other requests.
503+
- `GetSandboxLogsRequest` fields: `sandbox_id`, `lines` (u32), `since_ms` (i64),
504+
`sources` (Vec<String>), `min_level` (String), `workspace_scope`.
505+
- `ListSandboxesRequest` fields: `limit` (u32), `offset` (u32),
506+
`label_selector` (String), `workspace_scope`.
507+
- `ListProvidersRequest` fields: `limit` (u32), `offset` (u32),
508+
`workspace_scope`.
509+
- `ListWorkspacesRequest` fields: `limit` (u32), `offset` (u32),
510+
`label_selector` (String).
511+
- `UpdateConfigRequest` fields include `name` (String, sandbox name or empty for
512+
global), `setting_key`, `setting_value`, `delete_setting` (bool), `global`
513+
(bool), and `workspace_scope`. Sandbox-scoped updates require a named selector;
514+
gateway-global updates must leave `workspace_scope` as `None`.
515+
- Most resource requests require an explicit named `workspace_scope`, including
516+
the `default` workspace. An omitted selector is not an implicit default.
499517

500518
### gRPC timeouts
501519

‎crates/openshell-cli/src/run.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,7 @@ pub async fn sandbox_template_create(
24542454
labels,
24552455
resource_version: 0,
24562456
annotations,
2457-
workspace: "default".to_string(),
2457+
workspace: workspace.to_string(),
24582458
deletion_timestamp_ms: 0,
24592459
}),
24602460
spec: Some(SandboxWorkloadTemplateSpec {

‎crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ async fn sandbox_create_with_template_sends_workload_template_name() {
17451745
}
17461746

17471747
#[tokio::test]
1748-
async fn sandbox_template_create_sends_workload_template_resource() {
1748+
async fn sandbox_template_create_sends_non_default_workspace_in_scope_and_metadata() {
17491749
let server = run_server().await;
17501750
let fake_ssh_dir = tempfile::tempdir().unwrap();
17511751
let xdg_dir = tempfile::tempdir().unwrap();
@@ -1766,7 +1766,7 @@ async fn sandbox_template_create_sends_workload_template_resource() {
17661766
HashMap::from([("owner".to_string(), "platform".to_string())]),
17671767
HashMap::from([("FEATURE_FLAG".to_string(), "on".to_string())]),
17681768
"table",
1769-
"default",
1769+
"team-a",
17701770
&tls,
17711771
)
17721772
.await
@@ -1776,13 +1776,11 @@ async fn sandbox_template_create_sends_workload_template_resource() {
17761776
let request = requests
17771777
.first()
17781778
.expect("template create request should be recorded");
1779-
assert_eq!(
1780-
selected_workspace(&request.workspace_scope),
1781-
Some("default")
1782-
);
1779+
assert_eq!(selected_workspace(&request.workspace_scope), Some("team-a"));
17831780
let template = request.template.as_ref().expect("template should be sent");
17841781
let metadata = template.metadata.as_ref().expect("metadata should be sent");
17851782
assert_eq!(metadata.name, "gpu-kata");
1783+
assert_eq!(metadata.workspace, "team-a");
17861784
assert_eq!(metadata.labels.get("team"), Some(&"runtime".to_string()));
17871785
assert_eq!(
17881786
metadata.annotations.get("owner"),

‎sdk/typescript/README.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,24 @@ Curated methods are added deliberately, so some gateway RPCs are not yet wrapped
212212
`client.raw` is a generated client for every gateway RPC, including surface the curated sub-clients do not wrap yet (gateway config, provider CRUD, policy status, watch, logs, and the full observed `Sandbox`). `client.transport` is the shared connection, so extra clients reuse one socket. Generated request and response types live at `@nvidia/openshell-sdk/raw`.
213213

214214
```ts
215+
import { create } from '@bufbuild/protobuf'
215216
import { OpenShellClient } from '@nvidia/openshell-sdk'
217+
import { WorkspaceSelectorSchema } from '@nvidia/openshell-sdk/raw'
216218
import type { GetGatewayConfigResponse } from '@nvidia/openshell-sdk/raw'
217219

218220
const client = await OpenShellClient.connect({ gateway, oidcToken })
219221

220222
// Reach RPCs the curated surface does not wrap yet:
221223
const cfg: GetGatewayConfigResponse = await client.raw.getGatewayConfig({})
222-
const status = await client.raw.getSandboxPolicyStatus({ name: 'my-sandbox', version: 0, global: false })
224+
const defaultWorkspace = create(WorkspaceSelectorSchema, {
225+
selection: { case: 'workspace', value: 'default' },
226+
})
227+
const status = await client.raw.getSandboxPolicyStatus({
228+
name: 'my-sandbox',
229+
version: 0,
230+
global: false,
231+
workspaceScope: defaultWorkspace,
232+
})
223233
```
224234

225235
The raw layer returns the generated wire messages verbatim, preserving proto distinctions (an omitted optional versus an explicitly empty map) that the curated types may smooth over. As curated sub-clients land, prefer them; `raw` stays as the always-available floor.

0 commit comments

Comments
 (0)