diff --git a/debian/changelog b/debian/changelog index c1ec7f5..2cada41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +devdesk (0.2.1) bookworm; urgency=medium + + * Session hook and status line only record for panes on DevDesk's own + tmux server (Claude run with these settings elsewhere no longer writes + into DevDesk's state). + * The Claude wrapper re-reads /etc/devdesk/env before every Claude launch, + so Remote Control and CLAUDE_ARGS changes apply on the next restart. + + -- Jared Vititoe Wed, 07 Oct 2026 12:54:06 -0400 + devdesk (0.2.0) bookworm; urgency=medium * Sessions no longer need a project folder: any name works and starts in diff --git a/libexec/devdesk-claude-run b/libexec/devdesk-claude-run index fe6c738..878fadb 100755 --- a/libexec/devdesk-claude-run +++ b/libexec/devdesk-claude-run @@ -10,9 +10,18 @@ set -uo pipefail NAME=$(dd_current_session) [ -n "$NAME" ] || dd_die "not running inside a DevDesk session" -CLAUDE_BIN=${CLAUDE_BIN:-claude} SETTINGS="$DEVDESK_SHARE/claude-settings.json" -read -r -a EXTRA <<<"${CLAUDE_ARGS:-}" + +# Re-read /etc/devdesk/env before every Claude launch, so changes (Remote +# Control, CLAUDE_ARGS, …) apply on the next restart of Claude in a session. +reload_config() { + if [ -r "$DEVDESK_ENV" ]; then + # shellcheck source=/dev/null + . "$DEVDESK_ENV" + fi + CLAUDE_BIN=${CLAUDE_BIN:-claude} + read -r -a EXTRA <<<"${CLAUDE_ARGS:-}" +} ORANGE=$'\033[38;2;255;107;0m' CYAN=$'\033[38;2;0;212;255m' @@ -66,6 +75,7 @@ printf '\033]2;%s\033\134' "$NAME" # pane title (ST = ESC \\) mode=resume while :; do NAME=$(dd_current_session) # follow renames + reload_config if [ "$mode" = new ]; then run_new; else run_resume; fi rc=$? NAME=$(dd_current_session) diff --git a/libexec/devdesk-lib.sh b/libexec/devdesk-lib.sh index 817b182..440a30d 100644 --- a/libexec/devdesk-lib.sh +++ b/libexec/devdesk-lib.sh @@ -152,8 +152,10 @@ dd_resolve_dir() { # Name of the DevDesk session this process runs in. Asks tmux, so it stays # right after a rename; falls back to the DEVDESK_SESSION set at creation. dd_current_session() { - local name="" - if [ -n "${TMUX:-}" ] && [ -n "${TMUX_PANE:-}" ]; then + local name="" outer=${TMUX:-} + # Only DevDesk's own tmux server: a Claude started with these settings in + # some other tmux must not write into DevDesk's state. + if [ "${outer%%,*}" = "$DEVDESK_SOCKET" ] && [ -n "${TMUX_PANE:-}" ]; then name=$(tmux display-message -p -t "$TMUX_PANE" '#S' 2>/dev/null) fi printf '%s\n' "${name:-${DEVDESK_SESSION:-}}" diff --git a/libexec/devdesk-statusline b/libexec/devdesk-statusline index f484c6c..8b46f69 100755 --- a/libexec/devdesk-statusline +++ b/libexec/devdesk-statusline @@ -6,11 +6,12 @@ input=$(cat) -session="" -if [ -n "${TMUX:-}" ] && [ -n "${TMUX_PANE:-}" ]; then +# Only record for panes on DevDesk's own tmux server. +session="" outer=${TMUX:-} +if [ "${outer%%,*}" = "${DEVDESK_SOCKET:-/run/devdesk/tmux.sock}" ] && [ -n "${TMUX_PANE:-}" ]; then session=$(tmux display-message -p -t "$TMUX_PANE" '#S' 2>/dev/null) + session=${session:-${DEVDESK_SESSION:-}} fi -session=${session:-${DEVDESK_SESSION:-}} if [[ $session =~ ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ ]]; then dir="${DEVDESK_STATE_DIR:-/var/lib/devdesk}/context" diff --git a/tests/attach.bats b/tests/attach.bats index 1f79441..3ff0717 100644 --- a/tests/attach.bats +++ b/tests/attach.bats @@ -197,6 +197,20 @@ claude_args() { [ "$(jq -r '.sessions[] | select(.name=="alpha") | .context.model' <<<"$output")" = Opus ] } +@test "hooks ignore Claude running in some other tmux server" { + start_server + other="$TMP/other.sock" + tmux -S "$other" new-session -d -s stranger 'sleep 60' + pane=$(tmux -S "$other" display -p -t =stranger '#{pane_id}') + echo '{"session_id":"nope","source":"startup"}' | + TMUX="$other,1,0" TMUX_PANE="$pane" "$REPO/libexec/devdesk-session-hook" + echo '{"model":{"display_name":"Opus"},"context_window":{}}' | + TMUX="$other,1,0" TMUX_PANE="$pane" "$REPO/libexec/devdesk-statusline" >/dev/null + tmux -S "$other" kill-server + [ ! -e "$DEVDESK_STATE_DIR/registry.json" ] || [ "$(jq -r '.sessions | has("stranger")' "$DEVDESK_STATE_DIR/registry.json")" = false ] + [ ! -e "$DEVDESK_STATE_DIR/context/stranger.json" ] +} + @test "web actions run through attach and answer with JSON" { start_server run devdesk attach --new web1 alpha