ccpocket
repository·main·Indexed 21 days ago
https://github.com/k9i-0/ccpocketA mobile and desktop application for controlling AI coding agents like Codex and Claude remotely. It utilizes a self-hosted Bridge Server (@ccpocket/bridge) to connect interfaces to local agent sessions, allowing users to review code, approve actions, and manage git workflows via WebSockets.
What's inside ccpocket
- Linux desktop support in CC Pocket is currently in an experimental/in-progress state. Users should treat Linux artifacts as experimental and expect potential limitations in service availability and GUI behavior. The project is working towards a supported release by validating core integration tests, packaging strategies, and multi-environment stability.
Conflict detection rules for pending actions
mainThe system uses a conservative approach to determine if a pending action conflicts with the current Bridge state.
PendingInputActionis a CONFLICT if the delta sincebaseSeqcontains:user_inputfrom another device or client.- A
resultthat completes the current turn. - System events that change the conversation context (e.g.,
session switch,rewind,sandbox restart, orstop_session).
PendingInputActionis NOT a conflict if the delta contains:statusupdates.stream_deltaorthinking_delta.assistantmessages.tool_result.permission_requestorpermission_resolved.conversation_queueupdates.
Other Action Conflict Rules:
PendingStartSessionAction: Not a conflict ifprojectPath,provider, andstartOptionsare valid (since the session doesn't exist on the Bridge yet).PendingResumeSessionAction: Conflict if the provider session's metadata/timestamp has changed.PendingRenameSessionAction: Failed if the session cannot be resolved; otherwise, follows 'latest-wins'.PendingCodexQueueAction: Failed if the targetitemIdno longer exists in the Bridge'sconversation_queue.
Understand the Supporter program and its benefits
mainThe
Supporterprogram is an optional way to support the continued development of CC Pocket. It is designed to be lightweight and does not unlock core features or change how the application functions.Key points:
- No Paywalls: CC Pocket is free to use. Being a Supporter does not unlock restricted features; it is purely for supporting development costs (AI usage, testing devices, etc.).
- Supporter Benefits: Monthly Supporters unlock alternative application icons available in
Settings > App Icon. - Support Types: You can provide support via a one-time contribution (
Drink SupportorLunch Support) or a monthly subscription (Supporter Monthly). - Support Overview: All supporters (monthly or one-time) can view their support history/overview in the
Supportpage.
Understand the CC Pocket Architecture
mainCC Pocket is a client framework designed for self-hosting. It allows you to control local Codex or Claude agent sessions from mobile or desktop surfaces via a Bridge Server.
The Workflow Model:
- CC Pocket App: The control surface (mobile/desktop) used for sending prompts, approving actions, and browsing files.
- Bridge Server: Runs on the machine containing the project. It communicates with the app via a JSON WebSocket protocol and manages local agent tools, shell, git, and the filesystem.
- Local Agents: The actual Codex or Claude sessions running on the host machine.
Use AI to generate commit messages and PR content
mainccpocket uses the host machine's existing CLI authentication to generate commit messages and PR details via the official CLI interfaces (
claude -porcodex -q). This ensures compliance with existing user billing and authentication.Implementation logic:
- For Claude Code sessions: Uses
claude -p --model <model>. - For Codex sessions: Uses
codex -q --model <model>. - If no specific model is configured in the session, it falls back to the CLI default.
# Example: Generating a commit message for a Claude Code session echo "${diff}" | claude -p --model claude-sonnet-4-6 \ "Generate a commit message. ${customPrompt}" # Example: Generating a commit message for a Codex session echo "${diff}" | codex -q --model gpt-5.4-mini \ "Generate a commit message. ${customPrompt}"- For Claude Code sessions: Uses
Understand Agent Teams constraints
mainWhen working with Agent Teams, be aware of the following limitations:
- CLI-Only: It is a Claude Code CLI feature and cannot be controlled directly via the SDK.
- No Persistence: Teammates are not restored when resuming a session.
- No Nesting: Nested teams are not supported (a teammate cannot create its own team).
- Cost: Each teammate runs as an independent Claude instance, which increases token usage/costs.
- Single Team per Session: Only one team can exist per session.
Understand the Adaptive Workspace Layout
mainCC Pocket uses an adaptive layout system that switches between 1, 2, and 3 panes based on available screen width rather than device type. This allows the app to provide an optimized experience on tablets, foldables, and macOS.
Pane Roles
- Left Pane: Contains the session list, new session triggers, and navigation to settings/gallery.
- Center Pane: The primary workspace area, hosting
ClaudeSessionScreenorCodexSessionScreen. - Right Pane: An auxiliary area for tools like
GitScreen,ExploreScreen, orGalleryScreen.
Layout Modes
- 1 Pane (< 600dp): Standard full-screen mode. Navigation uses route pushes (e.g., moving from list to detail).
- 2 Pane (600 - 1099dp): Typically shows
Left + Center. If a right pane tool (like Git) is requested, the layout switches toCenter + Right, automatically collapsing the left pane to prioritize the center content. - 3 Pane (1100dp+): Shows
Left + Center + Rightsimultaneously. Both side panes can be manually collapsed.
Understand the CC Pocket Supporter model
mainCC Pocket is free to use. The
Supporterprogram is an optional way to support ongoing development and does not unlock core features or restrict app usage.Key Concepts:
- No Feature Locking: Core functionality is not gated behind a paywall.
- Privacy-First Design: The app avoids creating CC Pocket accounts or collecting long-term identifiers for monetization. This means there is no cross-platform synchronization between iOS and Android.
- Supporter Benefits: Primarily consists of a dedicated
Supportscreen to view history and access alternative app icons viaSettings > App Icon.
Authenticate Bridge requests with Push Relay Functions
mainThe Push Relay Functions use Firebase Anonymous Auth for security. The Bridge sends an ID token obtained via Firebase Anonymous Auth as aBearertoken. The Relay validates this token and uses the authenticatedUIDas theBridge ID. Because authentication is handled via the token itself, no additional environment variables or shared secrets need to be configured.Understand the Git Worker RPC architecture
mainThe system uses a Git Worker (running asworker.jswithin Electron) to handle Git plumbing operations via RPC calls from the UI. While the AI agent generates code changes, the application itself is responsible for branch creation, commits, pushes, and PR creation. This separation ensures that the agent only focuses on code generation while the app manages the repository state.Define Claude CLI Permission Rules
mainPermissions can be granularly defined using the pattern
ToolName(ruleContent). Rules can be set toallow,deny, oraskbehaviors.Rule Syntax Examples
Read: Matches any use of theReadtool.Bash(npm:*): Prefix match; matches any Bash command starting withnpm.Bash(git status): Exact match; matches only the specific commandgit status.Edit(.claude): Matches theEdittool when targeting.claudefiles.Write(/etc/*): Matches theWritetool for paths under/etc/.
Rule Scopes (Destinations)
Rules are stored in different locations depending on their intended lifecycle:
session: Volatile, in-memory approvals for the current session.cliArg: Passed via--allowed-toolsor--disallowed-tools.command: Provided via slash commands.localSettings: Stored in.claude/settings.local.json.projectSettings: Stored in.claude/settings.json(typically checked into version control).userSettings: Stored in~/.claude/settings.json.policySettings: Organization-level read-only policies.flagSettings: Runtime feature flags (read-only).
{ "permissions": { "allow": ["Bash(npm:*)", "Edit(.claude)", "Read"], "deny": ["Bash(rm -rf:*)"], "ask": ["Write(/etc/*)"], "defaultMode": "acceptEdits" } }Handle Codex ThreadEvents and Items
mainThe SDK communicates via a stream of
ThreadEventobjects. You should listen for these events to track the lifecycle of a thread and the progress of individual items (like reasoning or tool calls).Event Lifecycle Patterns
Standard Text Response:
thread.started$\rightarrow$turn.started$\rightarrow$item.completed(reasoning)$\rightarrow$item.completed(agent_message)$\rightarrow$turn.completedResponse with Command Execution:
thread.started$\rightarrow$turn.started$\rightarrow$item.completed(reasoning)$\rightarrow$item.completed(agent_message)$\rightarrow$item.started(command_execution)$\rightarrow$item.completed(command_execution)$\rightarrow$item.completed(agent_message)$\rightarrow$turn.completedThreadItem Types
Items represent the specific content generated during a turn:
AgentMessageItem: The actual text response from the agent.ReasoningItem: A summary of the agent's internal reasoning (e.g.,"**Planning file read execution**").CommandExecutionItem: Details about shell commands being run (includescommand,aggregated_output,exit_code, andstatus).FileChangeItem: Patches or file modifications.McpToolCallItem: Calls to MCP tools.WebSearchItem: Web search results.TodoListItem: Task lists generated by the agent.ErrorItem: Error details.
type ThreadEvent = | ThreadStartedEvent | TurnStartedEvent | TurnCompletedEvent | TurnFailedEvent | ItemStartedEvent | ItemUpdatedEvent | ItemCompletedEvent | ThreadErrorEvent; type ThreadItem = | AgentMessageItem | ReasoningItem | CommandExecutionItem | FileChangeItem | McpToolCallItem | WebSearchItem | TodoListItem | ErrorItem;