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
20 changes: 20 additions & 0 deletions src/features/host-provider/HostProvider.render.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,26 @@ describe("HostProvider render integration", () => {

act(() => actions.setSessionPinned("session-1", true));
expect(state.sessionMeta["session-1"]?.pinnedAt).toEqual(expect.any(String));
await act(() => actions.moveSessionToProject("session-1", "/other/"));
expect(state.sessionMeta["session-1"]).toEqual(
expect.objectContaining({
sidebarSection: "projects",
displayProjectDir: "/other",
sidebarMovedAt: expect.any(Number),
}),
);
expect(JSON.parse(persisted.values.get(STORAGE_KEYS.SESSION_META) ?? "{}")).toEqual(
expect.objectContaining({
"session-1": expect.objectContaining({
sidebarSection: "projects",
displayProjectDir: "/other",
}),
}),
);
await act(() => actions.removeSessionFromProject("session-1"));
expect(state.sessionMeta["session-1"]).toEqual(
expect.objectContaining({ sidebarSection: "chats", displayProjectDir: null }),
);
await act(() => actions.deleteSession("session-1"));
expect(host.deleteSession).toHaveBeenCalledWith("session-1");

Expand Down
29 changes: 26 additions & 3 deletions src/features/host-provider/HostProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ import { getShellWorkspacePolicy } from "@/runtime/shell-policy";
import { normalizeProjectPath } from "@/lib/path";
import { defaultEnabledSkillNames, sessionSkillsKey } from "@/lib/session-skills";
import { findModel } from "@/lib/utils";
import { makeProjectKey, shouldAutoNameSession } from "@/hooks/agent-session-utils";
import {
createSessionProjectDetachMeta,
createSessionProjectMoveMeta,
makeProjectKey,
shouldAutoNameSession,
} from "@/hooks/agent-session-utils";
import { STORAGE_KEYS } from "@/lib/constants";
import { storageGet, storageSet } from "@/lib/persistence/storage";
import { connectionsToModelProviders } from "@/lib/models-dev";
Expand Down Expand Up @@ -1121,8 +1126,26 @@ function HostProviderBody({
return next;
});
},
moveSessionToProject: async () => {},
removeSessionFromProject: async () => {},
moveSessionToProject: async (sessionId, directory) => {
const session = sessions.find((item) => item.id === sessionId);
setSessionMeta((current) => {
const meta = createSessionProjectMoveMeta(session, current[sessionId], directory);
if (!meta) return current;
const next = { ...current, [sessionId]: { ...current[sessionId], ...meta } };
persistSessionMetaMap(next);
return next;
});
},
removeSessionFromProject: async (sessionId) => {
const session = sessions.find((item) => item.id === sessionId);
setSessionMeta((current) => {
const meta = createSessionProjectDetachMeta(session, current[sessionId]);
if (!meta) return current;
const next = { ...current, [sessionId]: { ...current[sessionId], ...meta } };
persistSessionMetaMap(next);
return next;
});
},
setProjectPinned: (directory, pinned) => {
const projectKey = makeProjectKey(activeWorkspaceId, directory);
setProjectMeta((current) => {
Expand Down