Skip to content

Commit af41ec3

Browse files
committed
docs: implement Claude Code integration restart functionality
- Document the lock file debugging process - New documentation for restarting the Claude Code integration - Add a script to diagnose lock file issues - Implement a `restart` function to stop and then start the Claude Code integration - Register a `:ClaudeCodeRestart` user command - Introduce a new environment variable `CLAUDE_IDE_LOCK_SUBDIR` to allow custom lock directories - Enhance the `get_lock_dir` function to use `CLAUDE_IDE_LOCK_SUBDIR` if set - Add a temporary debug log to reflect the custom lock directory in use - Update the devcontainer configuration to include a commented-out example for setting `CLAUDE_IDE_LOCK_SUBDIR` - Flush the file buffer after writing lock file content to ensure immediate persistence
1 parent 9dccc84 commit af41ec3

File tree

6 files changed

+1032
-4
lines changed

6 files changed

+1032
-4
lines changed

DEBUG_LOCKFILE.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# 🔍 Lock File 调试指南
2+
3+
## 第一步:在 devcontainer 中启动 Neovim
4+
5+
```bash
6+
# 1. 确保在 devcontainer 内
7+
cd /workspace
8+
9+
# 2. 清空旧的 lock 文件
10+
rm -rf ~/.claude/ide/*.lock
11+
12+
# 3. 启动 Neovim 并查看调试输出
13+
nvim
14+
15+
# 4. 在 Neovim 中执行
16+
:ClaudeCodeStart
17+
```
18+
19+
## 第二步:观察调试输出
20+
21+
你应该看到这些调试信息:
22+
23+
### 🔵 蓝色:模块加载时
24+
```
25+
🔵 DEBUG: Lock directory on module load: /home/node/.claude/ide
26+
🔵 DEBUG: Lock directory exists? true
27+
🔵 DEBUG: CLAUDE_CONFIG_DIR env: nil
28+
```
29+
30+
### 🟢 绿色:文件创建时
31+
```
32+
🟢 DEBUG: Lock file created at: /home/node/.claude/ide/xxxxx.lock
33+
🟢 DEBUG: Lock file exists after close? true
34+
🟢 DEBUG: Lock file size: xxx bytes
35+
```
36+
37+
### 🔴 红色:文件删除时(如果发生)
38+
```
39+
🔴 DEBUG: lockfile.remove() called from: [stack trace]
40+
🔴 DEBUG: Removing lock file: /home/node/.claude/ide/xxxxx.lock
41+
🔴 DEBUG: Lock file successfully removed
42+
```
43+
44+
## 第三步:并行监控文件系统
45+
46+
在另一个终端(同样在 devcontainer 内):
47+
48+
```bash
49+
# 方法 1:持续监控
50+
watch -n 0.5 'ls -la ~/.claude/ide/*.lock 2>&1'
51+
52+
# 方法 2:使用 inotifywait(如果可用)
53+
inotifywait -m ~/.claude/ide/ -e create -e delete -e modify
54+
```
55+
56+
## 第四步:关键测试场景
57+
58+
### 场景 1:正常启动
59+
```vim
60+
:ClaudeCodeStart
61+
" 观察调试输出
62+
" 检查文件是否存在
63+
:!ls -la ~/.claude/ide/*.lock
64+
```
65+
66+
### 场景 2:检查文件是否立即消失
67+
```bash
68+
# 在 Neovim 启动后立即执行
69+
ls -la ~/.claude/ide/*.lock
70+
cat ~/.claude/ide/*.lock | jq .
71+
```
72+
73+
### 场景 3:检查是否是 VimLeavePre 触发
74+
```vim
75+
" 在 Neovim 中
76+
:ClaudeCodeStart
77+
:autocmd VimLeavePre * echom "VimLeavePre triggered!"
78+
" 等待几秒,看看是否有意外触发
79+
```
80+
81+
## 预期结果
82+
83+
### ✅ 正常情况
84+
- 🔵 显示正确的 lock_dir 路径
85+
- 🟢 显示文件创建成功
86+
- **没有** 🔴 删除日志
87+
- 文件持续存在
88+
89+
### ❌ 异常情况 A:立即删除
90+
- 🔵 显示正确路径
91+
- 🟢 显示创建成功
92+
- 🔴 **立即**显示删除日志 + 堆栈跟踪
93+
- **→ 这说明代码逻辑有问题**
94+
95+
### ❌ 异常情况 B:延迟消失(无删除日志)
96+
- 🔵 显示正确路径
97+
- 🟢 显示创建成功
98+
- **没有** 🔴 删除日志
99+
- 但文件消失了
100+
- **→ 这说明是文件系统问题**
101+
102+
### ❌ 异常情况 C:路径错误
103+
- 🔵 显示路径不是 `/home/node/.claude/ide`
104+
- **→ 这说明 vim.fn.expand() 有问题**
105+
106+
## 报告格式
107+
108+
请把以下信息发给我:
109+
110+
```
111+
1. 调试输出(完整的 🔵🟢🔴 日志)
112+
2. 文件监控输出
113+
3. 异常情况类型(A/B/C)
114+
4. lock 文件内容(如果存在):cat ~/.claude/ide/*.lock
115+
```
116+
117+
这样我就能精确定位问题了。

0 commit comments

Comments
 (0)