Skip to content

Option to run the restored assistant through a wrapper command #138

Done

Description

@gwarf

Thanks for maintaining this plugin, I rely on it to get my assistant sessions back after a reboot.

I start claude through a small launcher that prepares the process environment before it executes the real binary: it unsets one variable and injects a few secrets that are decrypted only for that process tree. They are read by MCP servers at startup, so they have to be in the environment of the claude process itself.

Two things get in the way when a session started this way is restored. #137 fixes the first one, a saved -- in front of the prompt. This issue is about the second.

Restore types command claude <saved args> --resume <id> into the pane, so a restored session comes back without that environment. The existing options cover part of it:

  • @assistant-resurrect-claude-drop-env handles the variable to unset.
  • @assistant-resurrect-capture-env could replay the secrets, but it stores their values in the sidecar and types them into the shell, which is what the launcher exists to avoid.

What I am missing is a way to put a command in front of the restored one, per tool, something like

set -g @assistant-resurrect-claude-launch-prefix 'my-env-wrapper'

giving my-env-wrapper claude <saved args> --resume <id>, where the wrapper sets up the environment and executes its arguments unchanged. The plugin would keep building and quoting the assistant command exactly as today.

I understand command <tool> is deliberate, to bypass aliases and functions, and that #136 is about typed text running commands, so a free-form prefix may not be something you want. A stricter shape could be a single executable path with no arguments, checked to exist at restore time. I'm not sure which shape fits the project, if any, so I will let you decide. I can prepare a PR with tests if one of them does.

Activity

  1. timvw commented on Nov 24, 2026

    @timvw
    Owner

    Thanks for the detailed write-up, @gwarf, and for #137, which is merged.

    Let's go with the stricter shape:

    • @assistant-resurrect-<tool>-launch-prefix takes one absolute path to an executable, with no arguments.
    • At restore time, check it with -x and reject it if it contains whitespace or control characters. If it fails, log that and fall back to the plain command.
    • Quote it with shell_quote and put it in front of the command restore builds today: '/path/wrapper' claude <args> --resume <id>. Inside the wrapper, use exec "$@". With a wrapper, command no longer bypasses aliases and functions, and exec'ing the real binary covers that.
    • Only the tmux option sets it. It is never read from the sidecar.

    Please build on the control-character check in #139 (the fix for #136), so both share the same validation. A PR with tests is very welcome, including a note in the docs about the exec "$@" contract.

  2. gwarf commented on Dec 2, 2026

    @gwarf
    ContributorAuthor

    Thanks, @timvw! I'm now using this version, will report in case I've any issue.

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