Skip to content

Add Window Projects panel for archiving and restoring terminal windows#620

Draft
YSaxon wants to merge 4 commits into
gnachman:masterfrom
YSaxon:claude/archives-per-window-projects-xtfmL
Draft

Add Window Projects panel for archiving and restoring terminal windows#620
YSaxon wants to merge 4 commits into
gnachman:masterfrom
YSaxon:claude/archives-per-window-projects-xtfmL

Conversation

@YSaxon
Copy link
Copy Markdown

@YSaxon YSaxon commented Mar 17, 2026

Summary

Introduces a new "Window Projects" panel UI that allows users to organize, archive, and restore iTerm2 terminal windows into named project hierarchies. This feature enables saving window arrangements for later restoration while keeping projects organized in a tree structure.

Key Changes

  • New Panel UI (iTermProjectsPanelController.swift):

    • Floating panel window with split-view layout
    • Left side: hierarchical project tree (NSOutlineView) with project management controls
    • Right side: list of currently open windows (NSTableView) with archive options
    • Hover previews for both archived windows and open windows
  • Data Model (iTermWindowProjectsModel.swift):

    • iTermWindowProject: Hierarchical project nodes supporting nested sub-projects
    • iTermArchivedWindow: Stores window metadata and binary-encoded arrangement data
    • Singleton model with JSON persistence to Application Support directory
    • Full CRUD operations for projects and window archiving/restoration
  • Project Management Features:

    • Create root projects and nested sub-projects
    • Rename projects via context menu
    • Delete projects with confirmation dialog
    • Display total archived window count per project
  • Window Archiving:

    • Archive open windows to selected project (with option to keep open or close)
    • Remove archived windows from projects
    • Restore individual archived windows or all windows in a project
    • Preserve window arrangements using iTerm's existing arrangement serialization
  • UI Polish:

    • Context menus for projects and archived windows
    • Hover preview popovers (0.5s delay) showing window thumbnails
    • Status label showing open window count
    • Responsive button states based on selection
    • Section headers and visual separators
  • Integration:

    • Added "Window Projects…" menu item to Window menu in iTermApplicationDelegate.m
    • Notification-based model change propagation
    • Proper memory management with weak references in closures

Implementation Details

  • Window arrangements are serialized as binary plists and base64-encoded for JSON storage
  • Preview images for open windows use CGWindowListCreateImage for live thumbnails
  • Archived window previews use iTerm's ArrangementPreviewView component
  • Split view maintains 42% width preference for projects panel with configurable min/max constraints
  • All UI built with Auto Layout for responsive resizing

https://claude.ai/code/session_011nQdWSvNudhnXQN7vu16YW

claude added 2 commits March 17, 2026 20:52
Introduces a side-by-side panel (Window > Window Projects…) that lets
users organise iTerm2 windows into arbitrarily-nested projects:

• iTermWindowProjectsModel – data layer (projects, sub-projects, archived
  windows). Persisted as JSON in ~/Library/Application Support/iTerm2/
  WindowProjects.json.

• iTermProjectsPanelController – floating panel with an NSSplitView:
  - Left: NSOutlineView showing the project tree. Each project can hold
    sub-projects and archived (closed) windows. Hover preview shows an
    ArrangementPreviewView for any archived window.
  - Right: NSTableView listing every currently-open window. Hover preview
    captures a live screenshot via CGWindowListCreateImage.

  Actions: create/rename/delete projects & sub-projects; archive a
  selected open window to a selected project (optionally closing it);
  restore individual archived windows or all windows in a project.
  Right-click context menus on both panes.

• Window > Window Projects… menu item wired to iTermApplicationDelegate.

https://claude.ai/code/session_011nQdWSvNudhnXQN7vu16YW
- Add Window > Window Projects… menu item (awakeFromNib, programmatic)
- Add -showWindowProjectsPanel: IBAction to iTermApplicationDelegate
- Register both new Swift files in iTerm2SharedARC target

https://claude.ai/code/session_011nQdWSvNudhnXQN7vu16YW
@YSaxon YSaxon marked this pull request as draft March 17, 2026 21:03
claude added 2 commits March 18, 2026 14:55
- iTermWindowProject gains a lastUsed: Date field (backward-compatible;
  defaults to distantPast on decode so older JSON sorts to the bottom)
- archiveWindow and restoreWindow/restoreAllWindows update lastUsed
- Projects pane header now has a two-segment control ("Name" / "Recent")
  that re-sorts root and sub-project lists in the outline view on the fly;
  "Recent" is the default

https://claude.ai/code/session_011nQdWSvNudhnXQN7vu16YW
Model (iTermWindowProjectsModel):
- Add runtime liveAssociations ([windowNumber → projectID])
- associateWindow/disassociateWindow: mark open windows as belonging
  to a project without closing them
- Auto-archive on close: NSWindow.willCloseNotification observer saves
  the window arrangement to its associated project when the window closes
- closeProject: archive + close all live windows for a project
- archivedWindow(id:) and project(id:) lookup helpers

Panel UI (iTermProjectsPanelController):
Left pane: now shows both live (bold, terminal.fill icon) and archived
  (grey, terminal icon) windows as leaves under each project. Double-click
  an open window → bring to front; double-click archived → restore.
  New "Close All" button + context menu item closes the selected project.

Right pane: converted from NSTableView to NSOutlineView grouped by
  project. Each project that has open windows appears as an expandable
  group header. Unassociated open windows appear in an "Unassociated"
  section at the bottom. Bottom bar "Associate with Project" button
  (replaces old "Archive to Project") records the live association
  without closing the window.

Drag-and-drop (all 6 semantic paths):
  right window  → left project       archive + close
  right window  → right group        reassign association (keep open)
  right window  → Unassociated/root  disassociate (keep open)
  right group   → left pane          close-all for that project
  left archived → right pane         restore, remove archive entry
  left project  → right pane         restore all windows in project

https://claude.ai/code/session_011nQdWSvNudhnXQN7vu16YW
@gnachman
Copy link
Copy Markdown
Owner

This seems like a useful idea - basically a way of organizing arrangements. I think it would be better to start with a spec; the code as written is pretty far from being mergable. Do you have a vision for where this could go? It feels like a bigger idea is trapped inside waiting to get out.

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.

3 participants