Skip to content

Commit 6c4adf1

Browse files
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>
1 parent 77d6f31 commit 6c4adf1

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ Format based on [Keep a Changelog](https://keepachangelog.com/).
1717
- Atomic task ID counter prevents millisecond collisions
1818
- Shutdown-safe: `closed` flag rejects submissions after `CancelAll`, `Wait` ensures goroutine cleanup
1919
- Completed tasks auto-cleaned after 30 minutes
20+
- `/bg inject <id>` — merge completed task results into main session as `/btw` context note (truncated to 4000 runes). Enables "independent analysis → selective context merge" workflow unique to Pocket Claude
2021
- **GitHub Actions CI** (`.github/workflows/ci.yml`): automated build, vet, gofmt check, test with race detector on push/PR to main
2122
- **Makefile**: `make build`, `make test`, `make test-race`, `make vet`, `make fmt`, `make fmt-check`, `make ci` (full local pipeline), `make run`, `make clean`
22-
- **Test Suite**: 57 test cases across 6 packages, all passing with `-race`
23+
- **Test Suite**: 58 test cases across 6 packages, all passing with `-race`
2324
- `store`: CRUD, stats, clear, outbox, message age
2425
- `claude`: stream JSON parsing, permission denials, UTF-8 truncation
2526
- `project`: add/remove/switch/rename, background executor, usage tracking, persistence across reloads

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Telegram --> Go Bot --> inbox.json --> Worker --> ProjectManager --> claude -p -
2323

2424
- **ProjectManager**: Owns per-project `Executor` instances. Routes all CLI calls to the active project. Persists config to `projects.json`. Switched via `/project` command.
2525
- **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.
2727
- **Session**: Explicit `--resume <session_id>` tracking per project. Never uses `--continue` (prevents conflicts with Claude Code terminal in same directory).
2828
- **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.
2929
- **Media**: Photos/documents downloaded from Telegram to `/tmp`, file path passed to Claude CLI for multimodal analysis.
@@ -64,7 +64,7 @@ internal/
6464

6565
```bash
6666
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)
6868
make test-race # or: go test -race ./... (with race detector)
6969
make vet # or: go vet ./...
7070
make fmt # or: gofmt -w .
@@ -93,7 +93,7 @@ Messages older than `MESSAGE_TTL_MINUTES` → auto `expired`. Prevents stale ret
9393
Goroutine spawning for callbacks/messages bounded by semaphore (max 10). Falls back to synchronous execution when limit reached.
9494

9595
### 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.
9797

9898
### Multi-project support
9999
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).

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ go build -o pocket-claude ./cmd/pocket-claude/
123123
### Test
124124

125125
```bash
126-
make test # run all tests (57 cases)
126+
make test # run all tests (58 cases)
127127
make test-race # with race detector
128128
make ci # full CI pipeline locally (fmt + vet + build + test)
129129
```
@@ -177,6 +177,7 @@ retry - Force retry error messages
177177
| `/bg <message>` | Run task in background (current project) |
178178
| `/bg <project> <message>` | Run background task in specific project |
179179
| `/bg status` | Show running background tasks |
180+
| `/bg inject <id>` | Inject completed result into current session |
180181
| `/bg cancel <id>` | Cancel a background task |
181182
| `/cancel` | Cancel the currently processing foreground message |
182183
| `/usage` | Show API-equivalent cost and message count (per project) |
@@ -318,7 +319,16 @@ When a background task finishes:
318319
Found 3 potential security issues...
319320
```
320321

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.
322332

323333
### Permission System
324334

0 commit comments

Comments
 (0)