Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions home-manager/programs/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@

# Function-based abbreviations
cliproxyapi = "_cliproxyapi_function";
clrc = "_clrc_function";
cltxe = "_cltxe_function";
cltxeh = "_cltxeh_function";
clwrc = "_clwrc_function";
clwxe = "_clwxe_function";
clwxeh = "_clwxeh_function";
clxe = "_clxe_function";
Expand Down Expand Up @@ -184,8 +186,10 @@
})
[
"_cliproxyapi_function"
"_clrc_function"
"_cltxe_function"
"_cltxeh_function"
"_clwrc_function"
"_clwxe_function"
"_clwxeh_function"
"_clxe_function"
Expand Down
9 changes: 9 additions & 0 deletions home-manager/programs/fish/functions/_clwrc_function.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function _clwrc_function --description "Run Claude Code remote-control with a stable binary in workspace git worktree"
# Resolve the symlink to the real inode before starting.
# When bun replaces the file (creates a new inode), the running node process
# keeps its reference to the old inode and is unaffected.
# Usage: clwrc [<claude remote-control args...>]

set -l claude_real (realpath (which claude))
node $claude_real remote-control --worktree $argv
Comment on lines +7 to +8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation lacks robust error handling. If the claude command is not found, which claude will fail, leading to a cascade of errors from realpath and node, which can be confusing for the user. It's better to explicitly check if the command exists and provide a single, clear error message.

  set -l claude_path (command -v claude)
  if test -z "$claude_path"
    echo "Error: 'claude' command not found." >&2
    return 1
  end
  set -l claude_real (realpath "$claude_path")
  node "$claude_real" remote-control --worktree $argv

Comment on lines +7 to +8
end
11 changes: 7 additions & 4 deletions scripts/update-local-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,13 @@ update_repo() {
return 1
fi
else
if ! (cd "$repo_dir" && git pull 2>&1); then
log_error " Git pull failed"
FAILURES+=("$repo_name (git pull failed)")
return 1
if ! (cd "$repo_dir" && git pull --ff-only 2>&1); then
log_warn " Fast-forward failed; rebasing onto remote..."
if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
log_error " Git pull failed"
FAILURES+=("$repo_name (git pull failed)")
return 1
fi
Comment on lines +242 to +246

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

git pull --rebase can enter an interactive state if there are merge conflicts, which would cause this script to hang. To make the script more robust, you should handle this case by aborting the rebase if the pull fails. This ensures the script can continue or exit gracefully without requiring user intervention.

Suggested change
if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
log_error " Git pull failed"
FAILURES+=("$repo_name (git pull failed)")
return 1
fi
if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
log_error " Git pull with rebase failed. Aborting rebase..."
# Abort any rebase that might have been started to avoid leaving the repo in a bad state.
(cd "$repo_dir" && git rebase --abort &>/dev/null) || true
FAILURES+=("$repo_name (git pull failed)")
return 1
fi

Comment on lines +240 to +246

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether the rebase failure path includes cleanup.
rg -n -C3 'git pull --rebase|git rebase --abort' scripts/update-local-binaries.sh

Repository: shunkakinoki/dotfiles

Length of output: 388


Add rebase cleanup on failure to prevent automation breakage.

At line 242, when git pull --rebase fails, the function returns without aborting the in-progress rebase state. This leaves the repository in a broken state for subsequent automation runs, which can cause them to fail or hang until manual intervention.

Suggested fix
   if ! (cd "$repo_dir" && git pull --ff-only 2>&1); then
     log_warn "  Fast-forward failed; rebasing onto remote..."
     if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
+      # Ensure repo is left in a clean state for future runs
+      (cd "$repo_dir" && git rebase --abort >/dev/null 2>&1 || true)
       log_error "  Git pull failed"
       FAILURES+=("$repo_name (git pull failed)")
       return 1
     fi
   fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! (cd "$repo_dir" && git pull --ff-only 2>&1); then
log_warn " Fast-forward failed; rebasing onto remote..."
if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
log_error " Git pull failed"
FAILURES+=("$repo_name (git pull failed)")
return 1
fi
if ! (cd "$repo_dir" && git pull --ff-only 2>&1); then
log_warn " Fast-forward failed; rebasing onto remote..."
if ! (cd "$repo_dir" && git pull --rebase 2>&1); then
# Ensure repo is left in a clean state for future runs
(cd "$repo_dir" && git rebase --abort >/dev/null 2>&1 || true)
log_error " Git pull failed"
FAILURES+=("$repo_name (git pull failed)")
return 1
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/update-local-binaries.sh` around lines 240 - 246, The git pull
--rebase failure handler leaves an in-progress rebase; update the failure branch
so that after a failed (cd "$repo_dir" && git pull --rebase ...) you first run a
cleanup (e.g., git rebase --abort and/or git reset --hard to leave the repo in a
clean state) before calling log_error and appending to FAILURES, to ensure
subsequent automation runs are not left with a broken rebase; locate the block
around the git pull --rebase call that references repo_dir, log_error, and
FAILURES and add the abort/reset cleanup there.

Comment on lines +240 to +246
fi
fi

Expand Down
Loading