Skip to content

sivtr copy reports missing session log in non-git directories even when shell integration is active #30

Description

@YewFence

Summary

sivtr copy appears to require the current working directory to be inside a git repository before terminal session logs can be created or read.

When running in a normal directory without a .git parent, the zsh shell integration is active and SIVTR_TERMINAL_ID is set, but sivtr flush does not create any session log files and sivtr copy reports:

sivtr: no session log found
  hint: run `sivtr init <shell>`, restart the shell, then run some commands

The hint is misleading in this case because the shell integration is already installed and active.

Environment

Shell: zsh
Platform: Linux
Working directory: /home/yewfence/code/tmp

Reproduction

  1. Use a directory that is not inside a git repository.
cd /home/yewfence/code/tmp
git rev-parse --show-toplevel

Output:

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  1. Verify that shell integration is installed.
sivtr init show

Output:

  bash: not installed (/home/yewfence/.bashrc)
  zsh: installed in /home/yewfence/.zshrc
  nushell: not installed (no profile at /home/yewfence/.config/nushell/config.nu)
  tmux: not installed (no config)
  session log dir: /home/yewfence/.local/state/sivtr
  1. Verify that the current shell has the sivtr hook environment.
echo "$SHELL"
echo "$SIVTR_TERMINAL_ID"
echo "$SIVTR_NEXT_COMMAND_CWD"

Output:

/usr/bin/zsh
session_104522
/home/yewfence/code/tmp
  1. Run sivtr flush and look for generated session files.
sivtr flush
find "${XDG_CONFIG_HOME:-$HOME/.config}/sivtr" -name '*.capture' -o -name '*.jsonl' -o -name '*.state'

Output:

  1. Run sivtr copy.
sivtr copy out --print

Output:

sivtr: no session log found
  hint: run `sivtr init <shell>`, restart the shell, then run some commands

Actual Behavior

No session log is created in a non-git directory, even though the zsh hook is installed and active.

sivtr copy only reports that no session log was found and suggests installing the shell hook.

Expected Behavior

One of these would be more understandable:

  1. Terminal session logging works outside git repositories by falling back to a workspace key derived from the current directory.

  2. Terminal session logging works outside git repositories by using a global terminal workspace.

  3. sivtr copy and sivtr flush report that terminal session logging requires a git repository, if that is an intentional design constraint.

Implementation Notes

Based on a quick source inspection, the behavior seems to come from workspace resolution.

crates/sivtr-core/src/workspace.rs resolves a workspace through git_root(cwd).

If no .git directory or file is found in the current directory or its parents, resolve_workspace_for_dir returns Ok(None).

terminal_log_path_for_dir then returns Ok(None).

src/commands/flush.rs calls scrollback::command_session_log_path() and exits quietly if it receives None:

let Some(session_log_path) = scrollback::command_session_log_path()? else {
    return Ok(());
};

That makes the command a silent no-op outside git repositories.

Why This Is Confusing

The installed hook status and environment variables suggest the shell integration is working:

zsh: installed in /home/yewfence/.zshrc
SIVTR_TERMINAL_ID=session_104522
SIVTR_NEXT_COMMAND_CWD=/home/yewfence/code/tmp

The visible error only points users toward sivtr init <shell>, so it is natural to keep debugging shell setup even though the missing git repository is the deciding condition.

Suggested Fix

Allow non-git directories to become terminal workspaces, or update the diagnostic message to mention the git repository requirement explicitly.

For example:

sivtr: no session log found
  hint: shell integration is active, but the current directory is not inside a git repository
  hint: run from a git repository, run `git init`, or use pipe mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions