Skip to content

[Bug] Session history does not respect custom project-local sessionDir #1732

Closed

Description

@Yux256

What happened? / 问题描述

Description

When Pi is configured to store sessions inside the project's .pi directory, PI-Desktop correctly respects this configuration when creating new sessions.

However, after reopening PI-Desktop or the project, previously created sessions are not discovered.

It appears that PI-Desktop only searches Pi's default global session directory (~/.pi/agent/sessions/) instead of the custom session directory configured for the project.

Steps to reproduce / 复现步骤

Steps to Reproduce

  1. Configure Pi to use a project-local session directory in .pi/settings.json:

    {
      "sessionDir": ".pi/sessions"
    }
  2. Open the project in PI-Desktop.

  3. Create a new session and send a message.

  4. Verify that the session file is correctly saved under the project's .pi/sessions directory.

  5. Close and reopen PI-Desktop.

  6. Open the same project and check the session history.

Expected behavior / 预期行为

Expected Behavior

PI-Desktop should discover and load existing sessions from the configured sessionDir, just as it uses that directory when creating new sessions.

Actual behavior / 实际行为

Actual Behavior

New sessions are saved to the correct custom directory, but previously created sessions do not appear in the session history after reopening the application.

PI-Desktop appears to search only the default global Pi session directory.

Suggested Fix

Ensure that session discovery and session creation use the same resolved session directory, respecting the project's sessionDir configuration.

Ideally, session discovery should follow Pi's native session directory resolution behavior rather than assuming the default global path.

App version / 应用版本

0.13.3

Operating system / 操作系统

Windows

Extra environment / 其他环境信息

No response

Logs / 日志

Screenshots / 截图

No response

Activity

  1. muzimu217 commented on Oct 17, 2026

    @muzimu217
    Contributor

    Statically confirmed the asymmetry, with one important correction to the framing: sessionDir is not a setting PI-Desktop implements at all — the key has zero references across apps/, packages/ and crates/ (verified by grep over main @ 4f9f051e5).

    What each layer actually does:

    • @earendil-works/pi-coding-agent 1.1.0, core/session-manager.js: the default session directory for a cwd is the encoded global path ~/.pi/agent/sessions/--encoded-cwd-- (getDefaultSessionDirPath()); the SessionManager accepts a custom sessionDir parameter, but only if its caller passes one.
    • PI-Desktop's session history never passes one — so the desktop's list/discovery path reads only the encoded global dirs, exactly as you observed.

    So the likely split is: whatever created your sessions inside the project's .pi/sessions was honoring the project setting at a layer below the desktop (the pi CLI/agent entry — main.js does reference sessionDir), while the desktop's embedding never forwards that override. Net effect: creation and discovery disagree on the directory, which is your bug.

    Fix direction for the maintainers: either (a) have the desktop read the project sessionDir override and pass it through to the same SessionManager used for listing, so creation and history share one source of truth, or (b) document sessionDir as a CLI-only setting and have the desktop ignore it on creation too — currently the two halves of the product disagree, which is the worst of both.

  2. added 3 commits that reference this issue on Oct 20, 2026
    d6a7640
    caa76f2
    7a95fd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions