Skip to content

feat(dashboard): multi-project switcher with runtime switching - #29

Open
Camille1024 wants to merge 2 commits into
feat/mobile-responsive-dashboard-aut-54from
feat/multi-project-switcher
Open

feat(dashboard): multi-project switcher with runtime switching#29
Camille1024 wants to merge 2 commits into
feat/mobile-responsive-dashboard-aut-54from
feat/multi-project-switcher

Conversation

@Camille1024

Copy link
Copy Markdown
Collaborator

Summary

  • Add a project switcher dropdown to the dashboard header — switch between KIP, KIP-infra, and any future sibling projects at runtime without restarting the server
  • Fix "render failed" in Nodes view when switching to a project without state.db
  • Add --lean-root argument to kip-state/index.py so it works for projects whose Lean source directory is not named KIP

Changes

Server

  • index.ts — introduce ProjectState (mutable) with allProjects; discoverProjects() scans sibling directories for .barchon/ or agents/
  • routes/project.ts — new endpoints: GET /api/project, GET /api/projects, POST /api/project/switch
  • All route handlers — path reads moved inside each handler so they pick up the switched project path at request time

Client

  • App.tsx<ProjectSwitcher /> replaces hardcoded <h1>KIP</h1>; renders a static badge when only one project is available, a dropdown otherwise
  • hooks/useApi.tsuseProjects(), useProjectSwitch() (invalidates all queries on switch)
  • Nodes.tsx — reset chaptersInit on project change; guard SVG fetch when graph has no nodes (avoids "render failed" for empty/no-DB projects)

Deploy

  • docker-compose.yml — mount both project roots as /projects/KIP and /projects/KIP-infra so they are siblings inside the container

Tools

  • kip-state/index.py — add --lean-root flag (default: <project>/KIP)

How to add a new project

1. Mount the project directory

Edit docker-compose.yml:

volumes:
  - .:/projects/KIP
  - /root/ai4math/KIP-infra:/projects/KIP-infra
  - /path/to/NEW-PROJECT:/projects/NEW-PROJECT   # add this line

Restart the container:

docker compose up -d dashboard

2. Build state.db

python3 /root/KIP/tools/kip-state/index.py \
  --project /path/to/NEW-PROJECT \
  --lean-root /path/to/NEW-PROJECT/LeanSourceDir   # omit if the Lean dir is named KIP

The database is written to /path/to/NEW-PROJECT/.dashboard/state.db.

3. Done

Refresh the dashboard — the new project appears automatically in the header dropdown. discoverProjects() scans all siblings of the primary project path for directories containing agents/ or .barchon/.

Notes

Situation Action
Lean directory is not named KIP Pass --lean-root
Blueprint updated Re-run kip-state to refresh state.db
New project has no agents/ dir Create an empty agents/ dir, or add .barchon/
Rebuilding the Docker image Only needed when ui/ source changes; adding a project only needs a container restart

Test plan

  • Switch from KIP to KIP-infra in the header dropdown — both projects render their graph correctly
  • KIP shows 199 nodes; KIP-infra shows 123 nodes
  • Switching back to KIP restores its graph without "render failed"
  • A project with no state.db shows "No graph data (state.db not built)" instead of "render failed"
  • Single-project deployment shows a static badge instead of a dropdown

🤖 Generated with Claude Code

chorewer and others added 2 commits May 21, 2026 17:14
Add a project switcher to the dashboard header that lets users switch
between KIP and KIP-infra (and any future sibling projects) without
restarting the server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- docker-compose.yml: change dashboard build context to Barchon repo
  (src/barchon) so the deployed image always reflects the canonical UI
- kip-state/index.py: change default output from .dashboard/state.db to
  .barchon/state.db to match Barchon's nodes route expectation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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