Skip to content

bug: Fix branch assignments lost in dev mode after Pi update #296

Description

@marcinkardas

Operating system(s)

  • Windows
  • macOS
  • Linux

What happened?

After switching from bunx howcode@dev (published build) to bun run dev (local dev build), all session threads appear under "Unassigned" instead of their git branches (e.g. main, my-branch-name). The branch names still exist in the database — the issue is that Electron dev mode uses a separate SQLite database (~/Library/Application Support/howcode/dev/state/desktop.sqlite) while the published build used ~/Library/Application Support/howcode/state/desktop.sqlite. Branch assignments (threads.branch_name) were written to the prod DB and are absent in the dev DB.

Steps to reproduce

  1. Use the published build (bunx howcode@dev) for any amount of time — sessions get assigned to git branches via the Composer.
  2. Switch to local dev mode (bun run dev).
  3. Open any project — all sessions appear under "Unassigned" despite having branch_name set in the prod DB.

Root: resolveConfiguredUserDataPath() in src/electron/main/ appends /dev to app.getPath("userData") when !app.isPackaged, creating a fresh isolated database with no branch assignments.

Agent implementation prompt

In src/electron/main/, resolveConfiguredUserDataPath() returns path.join(app.getPath("userData"), "dev") in dev mode, giving dev mode a separate SQLite database from the production build. Branch name assignments (threads.branch_name in desktop.sqlite) are only written via assignThreadBranch() called from the Howcode Composer — they are not stored in Pi session JSONL files and cannot be reconstructed by syncShellIndex.

When a user switches from the published build to dev mode, the dev database has no branch assignments and all threads appear as "Unassigned" in the sidebar.

Investigate and implement a fix. Options to consider:

  1. On dev-mode startup, when the dev DB is freshly created or has no branch assignments, copy branch_name from the prod DB if it exists at the standard path.
  2. During syncShellIndex, for sessions missing branch_name, attempt retroactive assignment via git log (compare session startedAt timestamp from .meta.json against branch commit history).
  3. Store branch_name in the Pi session JSONL as a session_info entry when assignThreadBranch is called, then read it back in readSessionSummary / mapSessionSummaryToRecord.

Relevant files:

  • src/electron/main/ (user data path),
  • desktop/pi-threads/shell-index.ts (syncShellIndex),
  • desktop/thread-state-db/session-writes.ts (syncSessionSummaries,
  • assignThreadBranch),
  • desktop/pi-threads/session-index.ts (mapSessionSummaryToRecord).

App version or commit

0.1.66-dev

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions