Skip to content

Herdr callbacks can target the wrong named session when HERDR_SOCKET_PATH conflicts with HERDR_SESSION #90

Description

@adam-paterson

Summary

When Herdr launches plannotator-tui in a named session, child Herdr CLI calls can target the wrong Herdr session if the process environment contains both of these values:

  • HERDR_SESSION=<intended-session>
  • HERDR_SOCKET_PATH=<another-session-socket>

Herdr resolves the target in this order:

  1. explicit CLI --session <name>
  2. HERDR_SOCKET_PATH
  3. HERDR_SESSION
  4. default session socket

plannotator-tui calls HERDR_BIN_PATH directly without passing --session, so HERDR_SOCKET_PATH wins over HERDR_SESSION. In a multi-session setup, plannotator-tui herdr last and herdr last --newest can open or query the wrong Herdr session.

User-visible symptom

With two Herdr sessions running, for example:

herdr session list
# default   running ...
# personal  running ...

Invoking Herdr Annotate actions from personal:

  • annotate.last
  • annotate.last-newest

can behave as if they are operating against default.

The original observation was that annotate.last in the personal session appeared to select data or panes from the default session.

Minimal behavior that exposes the cause

This Herdr CLI command shows the problem:

HERDR_SESSION=personal \
HERDR_SOCKET_PATH="$HOME/.config/herdr/herdr.sock" \
herdr pane list

It routes to the socket in HERDR_SOCKET_PATH, which is usually default, not personal.

Explicit --session wins:

HERDR_SESSION=personal \
HERDR_SOCKET_PATH="$HOME/.config/herdr/herdr.sock" \
herdr --session personal pane list

That command routes to personal.

Any Herdr integrated tool that needs to preserve the named session should pass explicit --session "$HERDR_SESSION" when HERDR_SESSION is present.

Investigation findings

Herdr

Herdr gives HERDR_SOCKET_PATH higher precedence than inherited HERDR_SESSION unless the command includes explicit CLI --session.

Relevant upstream areas inspected:

  • src/session.rs
    • configure_from_args consumes explicit --session and calls apply_explicit_name.
    • If HERDR_SOCKET_PATH is present and no explicit --session was passed, Herdr clears the explicit-session flag instead of treating inherited HERDR_SESSION as explicit.
  • src/session.rs

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions