The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): drag a sidebar session onto a project row to move it
Hermes Agentc4d14871e17a
diff --git a/apps/desktop/src/app/chat/session-drag.ts b/apps/desktop/src/app/chat/session-drag.tsindex 0b83e60ffa1..7f62fd7b538 100644--- a/apps/desktop/src/app/chat/session-drag.ts+++ b/apps/desktop/src/app/chat/session-drag.ts@@ -10,7 +10,9 @@* that edge (the zone sheet morphs to the half);* - a chat zone's CENTER / the composer → link: insert an `@session` chip* into that surface's composer (ChatDropOverlay owns the visual);- * - anything else (sidebar, terminal, gutters) → deny.+ * - a sidebar PROJECT ROW → move: re-home the session under that project+ * (same call the row's own "Move to project" menu item makes);+ * - anything else (terminal, gutters) → deny.** Zones that don't host a chat surface are NOT targets — the overlay never* lights them, so a release there must not commit either (one truth).@@ -45,14 +47,37 @@ import {SESSION_TILE_DRAG} from '@/components/pane-shell/tree/store'import type { EngineZone, ZoneRect } from '@/components/pane-shell/tree/zones-engine'+import { translateNow } from '@/i18n'+import { notifyError } from '@/store/notifications'+import { moveSessionToProject, projectIdForCwd } from '@/store/projects'import { requestFreshSession } from '@/store/profile'-import { $selectedStoredSessionId } from '@/store/session'+import { $selectedStoredSessionId, $sessions, sessionMatchesStoredId } from '@/store/session'import { $sessionTiles, nextSessionTileForWorkspace, openSessionTile, type TileDock } from '@/store/session-states'import { requestComposerInsertRefs } from './composer/focus'import { type SessionDragPayload, sessionInlineRef, sessionLabel } from './composer/inline-refs'+import { NO_PROJECT_ID } from './sidebar/projects/workspace-groups'import { tileZoneHost } from './tile-zone-host'+const PROJECT_ROW_DROP_ATTR = 'data-session-drop-hover'++/** A sidebar project row's drop geometry — tagged by `ProjectOverviewRow` via+ * `data-sessions-project`. */+interface ProjectRowSnapshot {+ el: HTMLElement+ id: string+ rect: ZoneRect+}++function snapshotProjectRows(excludeId: null | string): ProjectRowSnapshot[] {+ return queryAllVisible<HTMLElement>('[data-sessions-project]')+ .map(el => ({ el, id: el.dataset.sessionsProject || '', rect: snapRect(el) }))+ // Home (no folder to move into) and the session's own current project+ // (nothing to move) aren't drop targets — same exclusion the row's+ // "Move to project" menu applies to its own list.+ .filter(row => row.id !== NO_PROJECT_ID && row.id !== excludeId)+}+/** A chat surface's drag-start geometry: the anchor pane id it advertises* (`data-session-anchor`) and the composer a link drop routes to* (`data-composer-target`). */@@ -102,11 +127,23 @@ export function startSessionDrag(let surfaces: SurfaceSnapshot[] = []let composers: ZoneRect[] = []let zoneHost = new Map<string, ReturnType<typeof tileZoneHost>>()+ let projectRows: ProjectRowSnapshot[] = []// Commit intent, updated per resolved move (the machinery flushes the final// move before commit, so these always match the released-at position).let split: { anchor: string; before?: null | string; pos: TileDock } | null = nulllet link: null | string = null+ let moveToProject: null | string = null+ // The project row currently painted as the drop target, so a move to a+ // different row (or off any row) clears the one it left — imperative like+ // the source's own opacity, not React state (a repaint here shouldn't+ // re-render the sidebar on every pixel of pointer travel).+ let hoveredProjectRow: HTMLElement | null = null++ const clearProjectHover = () => {+ hoveredProjectRow?.removeAttribute(PROJECT_ROW_DROP_ATTR)+ hoveredProjectRow = null+ }// The drag SOURCE (sidebar row or tile tab). Captured synchronously — React// clears `currentTarget` after the pointerdown handler returns, but this runs@@ -125,6 +162,11 @@ export function startSessionDrag(surfaces = snapshotSurfaces()composers = queryAllVisible('[data-slot="composer-root"]').map(snapRect)zoneHost = new Map(zones.map(zone => [zone.id, tileZoneHost(zone.id)]))+ // Resolved fresh per drag (not passed in as payload): a stale value would+ // survive the row's own reorder/rename churn while a drag is armed.+ const draggedSession = $sessions.get().find(s => sessionMatchesStoredId(s, payload.id))+ const cwd = draggedSession?.cwd?.trim() || ''+ projectRows = snapshotProjectRows(cwd ? projectIdForCwd(cwd) : null)source?.style.setProperty('opacity', '0.45')// The same sentinel the zone overlay + chat surfaces key off — the// whole drop language (sheets, pills, caret, link overlay) lights up.@@ -135,9 +177,34 @@ export function startSessionDrag(if (source) {source.style.opacity = restoreOpacity}++ clearProjectHover()},resolveMove(x, y): DropHint | null {+ // The sidebar hosts no MAIN tile, so it's outside every pane-shell+ // zone — a project row is the one thing in that dead space a session+ // drop still resolves against. Checked first: it's a flat, disjoint+ // hit-test, not a fallback off the zone lookup below.+ const projectRow = projectRows.find(p => rectContains(p.rect, x, y))++ if (projectRow) {+ split = null+ link = null+ moveToProject = projectRow.id++ if (hoveredProjectRow !== projectRow.el) {+ clearProjectHover()+ hoveredProjectRow = projectRow.el+ hoveredProjectRow.setAttribute(PROJECT_ROW_DROP_ATTR, 'true')+ }++ return null+ }++ moveToProject = null+ clearProjectHover()+const zone = zones.find(z => rectContains(z.rect, x, y))const host = zone ? zoneHost.get(zone.id) : null@@ -210,6 +277,12 @@ export function startSessionDrag(} else if (link) {// The "link to chat" drop: an @session chip in that surface's composer.requestComposerInsertRefs([sessionInlineRef(payload)], { target: link })+ } else if (moveToProject) {+ // Same RPC the row's own "Move to project" menu item calls — the drop+ // is a shortcut onto that existing path, not a parallel one.+ void moveSessionToProject(payload.id, moveToProject, payload.profile).catch(err =>+ notifyError(err, translateNow('sidebar.projects.moveFailed'))+ )}}})diff --git a/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx b/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsxindex f5ac4c5d377..3afed314027 100644--- a/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx+++ b/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx@@ -278,7 +278,18 @@ export function ProjectOverviewRow({// project in the overview — the parallel to the entered-project wrapper's// `data-sessions-project` (index.tsx), which only fires once you've drilled// in. Here it's present on every row of the list.- <div className={cn(dragging && 'relative z-10')} data-sessions-project={project.id} ref={ref} style={style}>+ <div+ className={cn(+ dragging && 'relative z-10',+ // Painted imperatively by session-drag.ts while a dragged session+ // hovers this row — a live "drop here to move" cue, not React state+ // (it must not repaint the sidebar on every pixel of pointer travel).+ 'rounded-[6px] data-[drop-hover=true]:outline-2 data-[drop-hover=true]:-outline-offset-2 data-[drop-hover=true]:outline-sidebar-ring'+ )}+ data-sessions-project={project.id}+ ref={ref}+ style={style}+ >{/* Home has no per-project actions, so it gets no right-click menu. */}{project.isNoProject ? (shell