You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add /bg inject to README, CLAUDE.md, and CHANGELOG
Update all documentation to reflect the new /bg inject command:
- README: commands table, background tasks section with inject example
- CLAUDE.md: BackgroundPool description, design decisions
- CHANGELOG: inject feature entry under background tasks
- Test count updated to 58 across all docs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Telegram --> Go Bot --> inbox.json --> Worker --> ProjectManager --> claude -p -
23
23
24
24
-**ProjectManager**: Owns per-project `Executor` instances. Routes all CLI calls to the active project. Persists config to `projects.json`. Switched via `/project` command.
25
25
-**Worker**: Single goroutine, sequential foreground processing from a buffered channel. Prevents concurrent `claude -p` calls on the main session.
26
-
-**BackgroundPool**: Up to 3 concurrent background tasks via `/bg`. Each task gets an ephemeral `Executor` (not stored in Manager). Independent approval flow routed by `bg_` prefix on callback IDs. Atomic counter for unique task IDs. Semaphore-based slot limiting. Shutdown-safe (`closed` flag rejects new submissions after `CancelAll`).
26
+
-**BackgroundPool**: Up to 3 concurrent background tasks via `/bg`. Each task gets an ephemeral `Executor` (not stored in Manager). Independent approval flow routed by `bg_` prefix on callback IDs. Atomic counter for unique task IDs. Semaphore-based slot limiting. Shutdown-safe (`closed` flag rejects new submissions after `CancelAll`).`/bg inject` merges completed results into main session as `/btw` context notes.
27
27
-**Session**: Explicit `--resume <session_id>` tracking per project. Never uses `--continue` (prevents conflicts with Claude Code terminal in same directory).
28
28
-**Permissions**: Two-phase execution. Phase 1: default permissions, check `permission_denials` in JSON output. Phase 2 (if approved): re-run with `--dangerously-skip-permissions`. Markdown fallback on parse errors.
29
29
-**Media**: Photos/documents downloaded from Telegram to `/tmp`, file path passed to Claude CLI for multimodal analysis.
@@ -64,7 +64,7 @@ internal/
64
64
65
65
```bash
66
66
make build # or: go build -o pocket-claude ./cmd/pocket-claude/
67
-
make test# or: go test ./... (57 cases)
67
+
make test# or: go test ./... (58 cases)
68
68
make test-race # or: go test -race ./... (with race detector)
69
69
make vet # or: go vet ./...
70
70
make fmt # or: gofmt -w .
@@ -93,7 +93,7 @@ Messages older than `MESSAGE_TTL_MINUTES` → auto `expired`. Prevents stale ret
93
93
Goroutine spawning for callbacks/messages bounded by semaphore (max 10). Falls back to synchronous execution when limit reached.
94
94
95
95
### Background tasks (/bg)
96
-
Each background task gets its own ephemeral `Executor` (not stored in Manager's map). This avoids session tracking race conditions between foreground and background. Approval callbacks are routed by ID prefix: `bg_` → BackgroundPool, `msg_` → Worker. Atomic counter (`sync/atomic.Int64`) for task IDs prevents millisecond collisions. `closed` flag prevents new submissions after `CancelAll` during shutdown. Typing indicators run independently per task.
96
+
Each background task gets its own ephemeral `Executor` (not stored in Manager's map). This avoids session tracking race conditions between foreground and background. Approval callbacks are routed by ID prefix: `bg_` → BackgroundPool, `msg_` → Worker. Atomic counter (`sync/atomic.Int64`) for task IDs prevents millisecond collisions. `closed` flag prevents new submissions after `CancelAll` during shutdown. Typing indicators run independently per task.`/bg inject <id>` takes a completed task's `ResultText` and queues it as a `/btw` message into the main session (truncated to 4000 runes). This enables "independent analysis → selective context merge" — a workflow unique to Pocket Claude.
97
97
98
98
### Multi-project support
99
99
Each project gets its own `Executor` with independent session, workDir, and addDirs. `ProjectManager` replaces the single executor in the Worker. Projects persist to `projects.json`. Default project auto-created from `CLAUDE_WORK_DIR` on first run. `/project` command for add/remove/switch via inline keyboard. `/project search <keyword>` scans home directory (depth 3) for git repos matching keyword, shows results as inline buttons for one-tap add. Path validation on add (must be existing directory).
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,7 +123,7 @@ go build -o pocket-claude ./cmd/pocket-claude/
123
123
### Test
124
124
125
125
```bash
126
-
make test# run all tests (57 cases)
126
+
make test# run all tests (58 cases)
127
127
make test-race # with race detector
128
128
make ci # full CI pipeline locally (fmt + vet + build + test)
129
129
```
@@ -177,6 +177,7 @@ retry - Force retry error messages
177
177
|`/bg <message>`| Run task in background (current project) |
178
178
|`/bg <project> <message>`| Run background task in specific project |
179
179
|`/bg status`| Show running background tasks |
180
+
|`/bg inject <id>`| Inject completed result into current session |
180
181
|`/bg cancel <id>`| Cancel a background task |
181
182
|`/cancel`| Cancel the currently processing foreground message |
182
183
|`/usage`| Show API-equivalent cost and message count (per project) |
@@ -318,7 +319,16 @@ When a background task finishes:
318
319
Found 3 potential security issues...
319
320
```
320
321
321
-
Background tasks have their own permission flow — if a background task needs approval, you'll see a separate inline keyboard tagged with the task ID, so it won't interfere with foreground approvals.
322
+
**Inject results into your main conversation:**
323
+
```
324
+
/bg inject bg_1710756000123
325
+
💉 Injected bg_1710756000123 into current session.
326
+
327
+
You: "Fix issue #3 from that analysis" <-- Claude knows the context
328
+
Bot: "Fixed the SQL injection in auth.go..."
329
+
```
330
+
331
+
This "independent analysis → selective context merge" workflow is unique to Pocket Claude. Background tasks have their own permission flow — if a background task needs approval, you'll see a separate inline keyboard tagged with the task ID, so it won't interfere with foreground approvals.
0 commit comments