fix: accept external Workdirs in Browser subscriptions

This commit is contained in:
2026-09-30 01:14:24 +09:00
parent 5f19dcc93f
commit 677c7cfed9
4 changed files with 42 additions and 6 deletions
+8 -1
View File
@@ -214,6 +214,8 @@ fn rust_serialized_subscription_frame_fixtures() -> Vec<SubscriptionFrame> {
SubscriptionId::new("fixture-subscription").expect("fixture subscription id must be valid");
let worker_id =
SubscriptionWorkerId::new("fixture-worker").expect("fixture worker id must be valid");
let external_workdir_id = SubscriptionWorkdirId::new("fixture-external-workdir")
.expect("fixture external Workdir id must be valid");
let worker = SubscriptionWorker {
worker_id: worker_id.clone(),
runtime_id: Some("fixture-runtime".to_string()),
@@ -226,7 +228,12 @@ fn rust_serialized_subscription_frame_fixtures() -> Vec<SubscriptionFrame> {
workspace_id: Some("fixture-workspace".to_string()),
display_name: None,
profile: None,
workdir_attachments: Vec::new(),
workdir_attachments: vec![SubscriptionWorkerWorkdirAttachment {
alias: "external".to_string(),
repository_id: None,
repository_key: None,
working_directory_id: external_workdir_id,
}],
};
let subscribed = SubscriptionFrame::new(SubscriptionFramePayload::Response(
SubscriptionResponse::Subscribed {
@@ -391,8 +391,7 @@ function validateWorker(worker: SubscriptionWorker): boolean {
if (
!validateIdentifier(attachment.alias, MAX_RESOURCE_ID_BYTES) ||
!validateIdentifier(attachment.working_directory_id, MAX_RESOURCE_ID_BYTES) ||
attachment.repository_key == null ||
!validateRepositoryKey(attachment.repository_key) ||
(attachment.repository_key != null && !validateRepositoryKey(attachment.repository_key)) ||
aliases.has(attachment.alias) ||
workdirIds.has(attachment.working_directory_id)
) {
File diff suppressed because one or more lines are too long
@@ -42,6 +42,37 @@ Deno.test('generated subscription validator accepts a current exact frame', () =
assert(result.value.frame === 'response', 'expected response frame');
});
Deno.test('generated subscription validator accepts an external Workdir Worker', () => {
const result = decode(subscribedFrame({
snapshot: {
topic: 'workers',
data: {
workers: [
{
worker_id: 'worker-1',
runtime_id: 'runtime-1',
resource_key: 'worker-resource-1',
availability: 'observed',
subject_revision: 1,
state: 'idle',
has_running_internal_workers: false,
workspace_id: 'workspace-1',
display_name: 'Companion',
profile: 'companion',
workdir_attachments: [
{
alias: 'workspace',
working_directory_id: 'external-workdir-1',
},
],
},
],
},
},
}));
assert(result.ok, `external Workdir Worker was rejected: ${JSON.stringify(result)}`);
});
Deno.test('Rust-serialized compatibility fixtures satisfy the generated Browser contract', () => {
for (const fixture of RUST_SERIALIZED_SUBSCRIPTION_FRAME_FIXTURES) {
const result = decode(fixture);