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
7 changes: 0 additions & 7 deletions app/api/chat/_lib/session-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,6 @@ export async function resolveChatSessionContext(
);
}

if (body.sandboxId && body.sandboxId !== conversation.sandbox_id) {
throw new ChatSessionContextError(
"The conversation sandbox is no longer available.",
404
);
}

let sandbox: ChatSandboxContextRecord | null = null;
if (conversation.sandbox_id) {
try {
Expand Down
74 changes: 37 additions & 37 deletions tests/unit/chat-session-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,46 +147,46 @@ test("native chat rejects a missing conversation and a mismatched sandbox", asyn
);
});

test("native chat rejects a sandbox saved to another same-repository workspace conversation", async () => {
test("native chat ignores a stale browser sandbox hint and uses the saved conversation sandbox", async () => {
let loadedSandboxId: string | null = null;

await assert.rejects(
resolveChatSessionContext(
new Request("https://app.mogplex.com/api/chat"),
"user-1",
{
messages: [],
conversationId: "conversation-workspace-a",
sandboxId: "sandbox-workspace-b",
},
{
loadConversation: async () => ({
id: "conversation-workspace-a",
user_id: "user-1",
const resolved = await resolveChatSessionContext(
new Request("https://app.mogplex.com/api/chat"),
"user-1",
{
messages: [],
conversationId: "conversation-workspace-a",
sandboxId: "sandbox-workspace-b",
},
{
loadConversation: async () => ({
id: "conversation-workspace-a",
user_id: "user-1",
repo_id: "repo-1",
workspace_session_id: "workspace-a",
sandbox_id: "sandbox-workspace-a",
model: "openai/gpt-5.6-sol",
}),
loadRepo: async () => ({
id: "repo-1",
full_name: "Mogplex/mogplex",
owner: "Mogplex",
name: "mogplex",
default_branch: "main",
}),
loadSandbox: async ({ sandboxId }) => {
loadedSandboxId = sandboxId;
return {
id: sandboxId,
repo_id: "repo-1",
workspace_session_id: "workspace-a",
sandbox_id: "sandbox-workspace-a",
model: "openai/gpt-5.6-sol",
}),
loadRepo: async () => ({
id: "repo-1",
full_name: "Mogplex/mogplex",
owner: "Mogplex",
name: "mogplex",
default_branch: "main",
}),
loadSandbox: async ({ sandboxId }) => {
loadedSandboxId = sandboxId;
return {
id: sandboxId,
repo_id: "repo-1",
working_branch: "fix/workspace-a",
};
},
}
),
(error) => error instanceof ChatSessionContextError && error.status === 404
working_branch: "fix/workspace-a",
};
},
}
);

assert.equal(loadedSandboxId, null);
assert.equal(loadedSandboxId, "sandbox-workspace-a");
assert.equal(resolved.sandboxId, "sandbox-workspace-a");
assert.equal(resolved.workspaceSessionId, "workspace-a");
assert.equal(resolved.repoBranch, "fix/workspace-a");
});
Loading