refactor: extract explorer open gesture and standardize icon sizes
This commit is contained in:
@@ -168,6 +168,34 @@ describe("daemon client E2E", () => {
|
||||
rmSync(cwd, { recursive: true, force: true });
|
||||
}, 30000);
|
||||
|
||||
test("archives agents and excludes them from default listings", async () => {
|
||||
const cwd = tmpCwd();
|
||||
try {
|
||||
const created = await ctx.client.createAgent({
|
||||
config: {
|
||||
...getFullAccessConfig("codex"),
|
||||
cwd,
|
||||
},
|
||||
});
|
||||
|
||||
await ctx.client.archiveAgent(created.id);
|
||||
|
||||
const active = await ctx.client.fetchAgents();
|
||||
expect(active.entries.some((entry) => entry.agent.id === created.id)).toBe(false);
|
||||
|
||||
const withArchived = await ctx.client.fetchAgents({
|
||||
filter: { includeArchived: true },
|
||||
});
|
||||
expect(withArchived.entries.some((entry) => entry.agent.id === created.id)).toBe(true);
|
||||
} finally {
|
||||
rmSync(cwd, { recursive: true, force: true });
|
||||
}
|
||||
}, 30000);
|
||||
|
||||
test("returns rpc error when archiving an unknown agent id", async () => {
|
||||
await expect(ctx.client.archiveAgent(randomUUID())).rejects.toThrow();
|
||||
}, 10000);
|
||||
|
||||
test("returns home-scoped directory suggestions", async () => {
|
||||
const insideHomeDir = mkdtempSync(path.join(homedir(), "paseo-dir-suggestion-"));
|
||||
const outsideHomeDir = mkdtempSync(path.join(tmpdir(), "paseo-dir-suggestion-outside-"));
|
||||
|
||||
@@ -1675,22 +1675,32 @@ export class Session {
|
||||
this.sessionLogger.info({ agentId }, `Archiving agent ${agentId}`)
|
||||
|
||||
const archivedAt = new Date().toISOString()
|
||||
let archivedRecord: StoredAgentRecord | null = null
|
||||
|
||||
try {
|
||||
const existing = await this.agentStorage.get(agentId)
|
||||
if (existing) {
|
||||
archivedRecord = {
|
||||
...existing,
|
||||
archivedAt,
|
||||
}
|
||||
await this.agentStorage.upsert(archivedRecord)
|
||||
const existing = await this.agentStorage.get(agentId)
|
||||
let archivedRecord: StoredAgentRecord | null = existing
|
||||
if (!archivedRecord) {
|
||||
const liveAgent = this.agentManager.getAgent(agentId)
|
||||
if (!liveAgent) {
|
||||
throw new Error(`Agent not found: ${agentId}`)
|
||||
}
|
||||
|
||||
await this.agentStorage.applySnapshot(liveAgent, {
|
||||
title: liveAgent.config.title ?? null,
|
||||
internal: liveAgent.internal,
|
||||
})
|
||||
archivedRecord = await this.agentStorage.get(agentId)
|
||||
if (!archivedRecord) {
|
||||
throw new Error(`Agent not found in storage after snapshot: ${agentId}`)
|
||||
}
|
||||
this.agentManager.notifyAgentState(agentId)
|
||||
} catch (error: any) {
|
||||
this.sessionLogger.error({ err: error, agentId }, `Failed to archive agent ${agentId}`)
|
||||
}
|
||||
|
||||
archivedRecord = {
|
||||
...archivedRecord,
|
||||
archivedAt,
|
||||
}
|
||||
await this.agentStorage.upsert(archivedRecord)
|
||||
this.agentManager.notifyAgentState(agentId)
|
||||
|
||||
this.emit({
|
||||
type: 'agent_archived',
|
||||
payload: {
|
||||
@@ -1700,13 +1710,11 @@ export class Session {
|
||||
},
|
||||
})
|
||||
|
||||
if (archivedRecord) {
|
||||
await this.maybeArchiveWorktreeAfterLastAgentArchived({
|
||||
archivedAgentId: agentId,
|
||||
archivedAgentCwd: archivedRecord.cwd,
|
||||
requestId,
|
||||
})
|
||||
}
|
||||
await this.maybeArchiveWorktreeAfterLastAgentArchived({
|
||||
archivedAgentId: agentId,
|
||||
archivedAgentCwd: archivedRecord.cwd,
|
||||
requestId,
|
||||
})
|
||||
}
|
||||
|
||||
private async handleUpdateAgentRequest(
|
||||
|
||||
@@ -118,6 +118,16 @@ describe("createWorktree", () => {
|
||||
expect(ownership.repoRoot).toBe(repoDir);
|
||||
});
|
||||
|
||||
it("treats non-git directories as non-worktrees without throwing", async () => {
|
||||
const nonGitDir = join(tempDir, "not-a-repo");
|
||||
execSync(`mkdir -p ${nonGitDir}`);
|
||||
|
||||
const ownership = await isPaseoOwnedWorktreeCwd(nonGitDir, { paseoHome });
|
||||
|
||||
expect(ownership.allowed).toBe(false);
|
||||
expect(ownership.worktreePath).toBe(realpathSync(nonGitDir));
|
||||
});
|
||||
|
||||
it("creates a worktree with a new branch", async () => {
|
||||
const projectHash = await deriveWorktreeProjectHash(repoDir);
|
||||
const result = await createWorktree({
|
||||
|
||||
@@ -692,7 +692,15 @@ export async function isPaseoOwnedWorktreeCwd(
|
||||
cwd: string,
|
||||
options?: { paseoHome?: string }
|
||||
): Promise<PaseoWorktreeOwnership> {
|
||||
const gitCommonDir = await getGitCommonDir(cwd);
|
||||
let gitCommonDir: string;
|
||||
try {
|
||||
gitCommonDir = await getGitCommonDir(cwd);
|
||||
} catch {
|
||||
return {
|
||||
allowed: false,
|
||||
worktreePath: normalizePathForOwnership(cwd),
|
||||
};
|
||||
}
|
||||
const repoRoot = resolveRepoRootFromGitCommonDir(gitCommonDir);
|
||||
const worktreesRoot = await getPaseoWorktreesRoot(cwd, options?.paseoHome);
|
||||
const resolvedRoot = normalizePathForOwnership(worktreesRoot) + sep;
|
||||
|
||||
Reference in New Issue
Block a user