mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
fix(plugins): keep agent.create.before's workspace and metadata after the rebase
Rebased onto main after #8744 added metadata to agent.create.before. A result that omits workspaceId or metadata keeps the request's; a changed workspaceId is still rejected. The session's command lifecycle moves to a getter so its constructor stays under the complexity limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6d5fcf87e5
commit
416d706144
@@ -403,11 +403,19 @@ test("terminal and command hooks can change only what Paseo runs", async () => {
|
|||||||
test("agent creation hooks keep the workspace, including from plugins that omit it", async () => {
|
test("agent creation hooks keep the workspace, including from plugins that omit it", async () => {
|
||||||
const request = {
|
const request = {
|
||||||
config: { provider: "claude", cwd: "/work/a" },
|
config: { provider: "claude", cwd: "/work/a" },
|
||||||
|
metadata: { "issues.id": "ENG-1" },
|
||||||
workspaceId: "wks_a",
|
workspaceId: "wks_a",
|
||||||
};
|
};
|
||||||
|
// A result built before either field existed keeps both.
|
||||||
await expect(
|
await expect(
|
||||||
validateBeforeResult("agent.create.before", request, { config: request.config }),
|
validateBeforeResult("agent.create.before", request, { config: request.config }),
|
||||||
).resolves.toEqual(request);
|
).resolves.toEqual(request);
|
||||||
|
await expect(
|
||||||
|
validateBeforeResult("agent.create.before", request, {
|
||||||
|
config: request.config,
|
||||||
|
metadata: { "issues.id": "ENG-2" },
|
||||||
|
}),
|
||||||
|
).resolves.toEqual({ ...request, metadata: { "issues.id": "ENG-2" } });
|
||||||
await expect(
|
await expect(
|
||||||
validateBeforeResult("agent.create.before", request, { ...request, workspaceId: "wks_b" }),
|
validateBeforeResult("agent.create.before", request, { ...request, workspaceId: "wks_b" }),
|
||||||
).rejects.toThrow("agent.create.before hooks cannot change the workspace");
|
).rejects.toThrow("agent.create.before hooks cannot change the workspace");
|
||||||
|
|||||||
@@ -814,6 +814,10 @@ export class Session {
|
|||||||
private readonly daemonConfigStore: DaemonConfigStore;
|
private readonly daemonConfigStore: DaemonConfigStore;
|
||||||
private readonly pushNotifications: PushNotifications;
|
private readonly pushNotifications: PushNotifications;
|
||||||
private readonly pluginRuntime: SessionOptions["pluginRuntime"];
|
private readonly pluginRuntime: SessionOptions["pluginRuntime"];
|
||||||
|
// What worktree setup and teardown commands run through: the plugins' hooks, or none.
|
||||||
|
private get commandLifecycle(): NonNullable<SessionOptions["pluginRuntime"]> | null {
|
||||||
|
return this.pluginRuntime ?? null;
|
||||||
|
}
|
||||||
private readonly orchestrationSkills: SessionOptions["orchestrationSkills"];
|
private readonly orchestrationSkills: SessionOptions["orchestrationSkills"];
|
||||||
private unsubscribeAgentEvents: (() => void) | null = null;
|
private unsubscribeAgentEvents: (() => void) | null = null;
|
||||||
private unsubscribeProjectMutations: (() => void) | null = null;
|
private unsubscribeProjectMutations: (() => void) | null = null;
|
||||||
@@ -1249,7 +1253,7 @@ export class Session {
|
|||||||
logger: this.sessionLogger,
|
logger: this.sessionLogger,
|
||||||
});
|
});
|
||||||
this.createAgentLifecycleDispatch = new CreateAgentLifecycleDispatch({
|
this.createAgentLifecycleDispatch = new CreateAgentLifecycleDispatch({
|
||||||
lifecycle: this.pluginRuntime ?? null,
|
lifecycle: this.commandLifecycle,
|
||||||
paseoHome: this.paseoHome,
|
paseoHome: this.paseoHome,
|
||||||
worktreesRoot: this.worktreesRoot,
|
worktreesRoot: this.worktreesRoot,
|
||||||
agentManager: this.agentManager,
|
agentManager: this.agentManager,
|
||||||
@@ -5709,7 +5713,7 @@ export class Session {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return handleWorktreeArchiveRequest(
|
return handleWorktreeArchiveRequest(
|
||||||
{
|
{
|
||||||
lifecycle: this.pluginRuntime ?? null,
|
lifecycle: this.commandLifecycle,
|
||||||
paseoHome: this.paseoHome,
|
paseoHome: this.paseoHome,
|
||||||
paseoWorktreesBaseRoot: this.worktreesRoot,
|
paseoWorktreesBaseRoot: this.worktreesRoot,
|
||||||
github: this.github,
|
github: this.github,
|
||||||
@@ -7964,7 +7968,7 @@ export class Session {
|
|||||||
): Promise<CreatePaseoWorktreeWorkflowResult> {
|
): Promise<CreatePaseoWorktreeWorkflowResult> {
|
||||||
return createWorktreeWorkflow(
|
return createWorktreeWorkflow(
|
||||||
{
|
{
|
||||||
lifecycle: this.pluginRuntime ?? null,
|
lifecycle: this.commandLifecycle,
|
||||||
paseoHome: this.paseoHome,
|
paseoHome: this.paseoHome,
|
||||||
worktreesRoot: this.worktreesRoot,
|
worktreesRoot: this.worktreesRoot,
|
||||||
createPaseoWorktree: (workflowInput, serviceOptions) =>
|
createPaseoWorktree: (workflowInput, serviceOptions) =>
|
||||||
@@ -8018,7 +8022,7 @@ export class Session {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return handleWorkspaceSetupRunRequestMessage(
|
return handleWorkspaceSetupRunRequestMessage(
|
||||||
{
|
{
|
||||||
lifecycle: this.pluginRuntime ?? null,
|
lifecycle: this.commandLifecycle,
|
||||||
getWorkspace: (workspaceId) => this.workspaceRegistry.get(workspaceId),
|
getWorkspace: (workspaceId) => this.workspaceRegistry.get(workspaceId),
|
||||||
clearAutomationBlock: (workspaceId) =>
|
clearAutomationBlock: (workspaceId) =>
|
||||||
clearWorkspaceAutomationBlock(this.workspaceRegistry, workspaceId),
|
clearWorkspaceAutomationBlock(this.workspaceRegistry, workspaceId),
|
||||||
@@ -8060,7 +8064,7 @@ export class Session {
|
|||||||
}
|
}
|
||||||
return archiveByScope(
|
return archiveByScope(
|
||||||
{
|
{
|
||||||
lifecycle: this.pluginRuntime ?? null,
|
lifecycle: this.commandLifecycle,
|
||||||
paseoHome: this.paseoHome,
|
paseoHome: this.paseoHome,
|
||||||
paseoWorktreesBaseRoot: this.worktreesRoot,
|
paseoWorktreesBaseRoot: this.worktreesRoot,
|
||||||
github: this.github,
|
github: this.github,
|
||||||
|
|||||||
Reference in New Issue
Block a user