Skip to content

Add persistent session project assignments and tags - #265

Merged
nicosuave merged 1 commit into
mainfrom
session-project-assignments-and-tags
Oct 28, 2026
Merged

nicosuave merged 1 commit into
mainfrom
session-project-assignments-and-tags

Conversation

@nicosuave

Copy link
Copy Markdown
Owner

Requested by Nico · project thread

Closes #263

Users can now move a session into a project and add free-form tags. Both work in session and project listings, search, MCP, the TUI, and the web UI, and both survive reindex and rebuild.

memex session set-project SESSION_ID ProjectA
memex session clear-project SESSION_ID
memex session tag add SESSION_ID tooling
memex session tag rm SESSION_ID tooling
memex session tag ls
memex session inspect SESSION_ID
memex sessions --tag tooling        # also: projects --tag, search --tag

Storage and resolution

  • Assignments are stored in state/session-metadata.sqlite (new src/session_meta.rs), apart from the rebuildable analytics.sqlite. reset_reindex_artifacts, analytics backfills, and the schema bump don't touch the new file. Transcripts and provider metadata are never written.
  • Rows are keyed by (machine, source, session_id), not by transcript path.
  • The analytics connection attaches the store. Project resolution now happens in one place, project_sql() in analytics.rs, which replaces COALESCE(NULLIF(repo_project,''),'Unfiled'). The order is: the session's own assignment, then its parent's assignment, then the derived repo_project, then Unfiled. Flat grouping uses the same order, falling back to project.
  • parent_session_id is now recorded in the analytics sessions table. SCHEMA_VERSION goes from 7 to 8 so one backfill fills it in.
  • Read-only handles with no store file yet get empty TEMP tables, so the file is never created by a read.

Design defaults (maintainer decisions from the issue)

  • Inheritance: sub-agent and forked sessions inherit their parent's project unless they have their own. They also carry their parent's tags. Claude sub-agents share their parent's session ID, so they match directly. Codex forks link through parent_session_id.
  • Continuations: files that share a session ID share its assignment. A moved transcript keeps its assignment.
  • Providers: the same session ID from two providers counts as two sessions. When it's ambiguous, the command errors and asks for --source. Legacy codex-session and codex-history labels map to codex.
  • Only indexed sessions can be assigned, so a typo errors out instead of leaving an orphaned row.
  • Tags are case-insensitive, trimmed, have any leading # stripped, and can't contain commas. Repeating --tag means every tag must match.
  • Derived facts are kept. inspect and sessions output show assigned_project and tags next to the unchanged repo_project, cwd, and git_root.
  • Machines: each machine stores assignments for the sessions it indexes, so its own filters apply them. --machine ID sends writes and inspects to that machine through a new SessionAssignment RPC. The machine column is always local for now. It's in the key so assignments can't collide if stores are ever merged.
  • Flat-name search: this keeps using the index field until any project assignment exists. After that, project filters resolve through the catalog. Repository grouping always used the catalog.
  • TUI: typing #tag in the project filter applies a tag filter, and the project lists include #tag entries. Web UI: there's a tag picker next to the project picker, a Tag field in the filter panel, /api/tags, and #tag shown on result rows.

Not covered

  • The activity and token charts (TUI home and web) ignore tag filters, though they still respect assigned projects through the shared SQL.
  • Older remote peers: the new tag fields are optional on RPC payloads. Federated session lists drop an older peer's rows when filtering by tag. In search, an older peer ignores the tag filter.

PR #237's chat organization is a macOS-app-local organization.json for pins and sections, so it's not reused here and nothing depends on it.

Testing

  • New tests: tests/session_assignments_cli.rs follows the issue's acceptance examples end to end, including a simulated rebuild, inheritance, an explicit child override, and ambiguity and missing-session errors. There are also analytics unit tests (override, inheritance, survival across rebuild_from_records, read-only open without a store), a search scope test (tags and assigned projects in flat search), and a Playwright test for the web tag filter.
  • cargo fmt --check and cargo clippy --all-targets -- -D warnings are clean.
  • Frontend: typecheck passes, all 56 Playwright tests pass, and web/dist was rebuilt (I checked that the build is byte-reproducible on main first).
  • Full cargo test in the sandbox: every failure is a blocked Hugging Face model download (the lib suite has 162 failures, the same count as on main, plus 3 embedding tests in daemon_cli). Everything else passes.

Generated by Claude Code

Users can move a session to a project and add free-form tags. Both live in
state/session-metadata.sqlite, apart from the rebuildable analytics cache, so
reindex, rebuild, and analytics backfills keep them. Rows are keyed by
machine, provider, and session ID.

Project resolution now happens in one place in analytics: the session's own
assignment, then its parent's, then the derived repository grouping.
Sub-agent and forked sessions inherit their parent's project and tags unless
they have their own. The analytics cache records parent_session_id (schema 8
backfills it).

New commands: memex session set-project, clear-project, tag add/rm/ls, and
inspect, with --machine routed over RPC to the machine that indexes the
session. --tag filters sessions, projects, search, and MCP; the TUI accepts
#tag in the project filter; the web UI gets a tag picker and shows tags.

Closes #263

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0112tRxuWBggF3Q77E2YbDaN
@nicosuave nicosuave self-assigned this Oct 28, 2026
@nicosuave
nicosuave merged commit c5c9e2c into main Oct 28, 2026
11 checks passed
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.

Persistent per-session project overrides and additive tags

2 participants