Skip to content

Remove sessions from projects - #75

Merged
akemmanuel merged 2 commits into
masterfrom
remove-session-from-project
Jun 12, 2026
Merged

akemmanuel merged 2 commits into
masterfrom
remove-session-from-project

Conversation

@touch2be

Copy link
Copy Markdown
Collaborator

Summary

  • add a session menu action to remove a session from its current project
  • move removed project sessions into the Chats section using persisted session metadata
  • clear the removed-from-project state when moving a session back to a project

Validation

  • vp check src/hooks/agent-state-persistence.ts src/hooks/use-agent-impl-core.tsx src/hooks/agent-contexts.ts src/components/sidebar/use-sidebar-model.ts src/components/SessionContextMenu.tsx src/components/SidebarItemMenus.tsx src/components/sidebar/SessionRow.tsx src/components/sidebar/ProjectEntry.tsx src/components/sidebar/SidebarContentSections.tsx src/components/AppSidebar.tsx src/i18n/locales/en.json src/i18n/locales/de.json src/i18n/locales/es.json

Note: full vp check on a clean origin/master worktree is currently blocked by pre-existing formatting issues in unrelated files.

@github-actions

Copy link
Copy Markdown

Confidence Score: 4/5

// src/hooks/use-agent-impl-core.tsx:2558-2596
// The `removeSessionFromProject` action doesn't validate that the session
// is actually assigned to a project before proceeding. If called
// programmatically (not through the menu) on a non-project session, it
// would redundantly mark it as detached. Consider adding a guard:

const meta = stateRef.current.sessionMeta[sessionId];
if (!meta?.assignedProjectDir) return;  // already not in a project
// src/hooks/use-sidebar-model.ts:176-183
// The `chatSessions` filter includes sessions where
// `detachedFromProject === true`. This is correct, but the filter
// double-checks `isDefaultChatDirectory` for non-detached sessions.
// If a session has `detachedFromProject: true` but also a non-matching
// `_projectDir`, it still lands in chatSessions. Consider adding a
// comment here to clarify the inclusion logic for maintainability.

Issues detected:

  • removeSessionFromProject lacks a defensive check (use-agent-impl-core.tsx). Unlike moveSessionToProject which validates sourceDirectory, the remove action has no early return when the session has no assignedProjectDir. The UI guards this (menu items only appear when currentProjectDir is set), but a programmatic call could mark a chat-only session as detachedFromProject: true — a no-op but still state pollution.

  • No test coverage for the state transitions: detach → appears in Chats, reattach → clears detachedFromProject, detach → hidden from project list. This is high-risk state logic with no verification.

  • sortSessionsForSidebar sorting priority is implicit (use-sidebar-model.ts:65-87). The order of fallbacks (detached → assigned → updated → created → id) is fragile and not documented. A future change adding another timestamp field could silently break the sort.

New%20session%20-%202026-06-10T03%3A11%3A17.882Z
opencode session  |  github run

@akemmanuel
akemmanuel merged commit 06c0b9f into master Jun 12, 2026
1 check failed
@akemmanuel
akemmanuel deleted the remove-session-from-project branch June 12, 2026 19:43
@github-actions

Copy link
Copy Markdown

fatal: couldn't find remote ref remove-session-from-project

opencode session  |  github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants