Skip to content

Commit 116fa46

Browse files
author
CrewCoder
committed
feat: add YuHeard renderer store for terminal agent notifications
- Implemented a Zustand store to manage YuHeard state transitions and notifications. - Added methods for applying reports, completing states, and clearing pane states. - Integrated sound notifications and OS notifications based on state changes. style: enhance mobile responsiveness in Mission Control and Prompt Builder - Adjusted styles for mobile layouts in Mission Control and Prompt Builder. - Increased max height for side panels and improved button layouts for better usability on smaller screens. - Implemented responsive design for various components to enhance user experience on phones and tablets. style: update Canvas Mode styles for better mobile usability - Modified styles for Canvas Mode to accommodate phone layouts, including FAB positioning and pane adjustments. - Ensured touch targets are appropriately sized and actions are easily accessible. style: add new animations to Tailwind CSS - Introduced a new pop-in animation for UI elements to enhance visual feedback. fix: extend PtyCreateOpts with YuHeard metadata - Added agentId, autoWrap, and wrapAgentIds to PtyCreateOpts for better integration with YuHeard. feat: define YuHeard types for shared protocol - Created a new types file for YuHeard to standardize state management and communication between agents and the application. - Included interfaces for reports, responses, and renderer events to facilitate IPC communication.
1 parent 9a1c5d1 commit 116fa46

95 files changed

Lines changed: 5795 additions & 472 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ packaging/arch/*.deb
4949
packaging/arch/*.pkg.tar.*
5050
tester/
5151
test-workspace/
52+
.commandcode/

‎AGENTS.md‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,20 @@ The shared React renderer supports desktop and direct browser clients. New rende
147147

148148
Remote-access credentials are authority boundaries. Pairing tokens must remain short-lived, memory-only, and single-use. Persist only device-session digests in owner-only atomic stores; enforce expiry and revocation. Browser HTTP/WebSocket origins must match exactly or be explicitly configured—never reflect arbitrary `Origin`/forwarded headers. Keep authentication limiters bounded, and do not hardcode CJ's `crewcode.logixhub.icu` deployment as a default Hub URL.
149149

150+
Browser delegation keeps its agent-facing endpoint Brain-loopback and bearer-scoped;
151+
delegate requests, editor watches, and LSP handles remain bound to the authenticated
152+
browser session that owns them. Browser plugin iframes load only approved plugin
153+
assets through expiring asset-only grants and continue to invoke capabilities through
154+
the trusted renderer plus manifest permission gate. Remote GitHub UI may drive the
155+
Brain's `gh` device login and registered-workspace publishing, but must never expose
156+
the Brain's GitHub credential or allow remote logout.
157+
150158
The self-hosted Hub is a separate `crewcode hub` process, not Electron renderer state. Keep its SQLite store owner-only and server-side; persist WebAuthn public credentials and only digests of browser/CSRF secrets. Bootstrap credentials and WebAuthn challenges stay short-lived and memory-only. Require user verification, exact configured RP origin/id, one-use challenges, secure HttpOnly SameSite cookies, and CSRF checks for mutations. Machine enrollment tokens must also stay short-lived, memory-only, single-use, and rate-limited; persist only machine bearer digests at the Hub and keep the brain credential file owner-only. Presence and relay connections are outbound-only and revocation must fail closed. Hub connection tickets remain short-lived, memory-only, one-shot, browser-session/user/machine bound, and exact-origin protected. Relay application frames must stay end-to-end encrypted and ordered; the Hub may route metadata but must not receive RPC/source/terminal/agent plaintext. Do not let Hub identity, machine presence, or requested ticket scope imply Brain execution authority: `crewcode brain` defaults to no RPC grants, and every decrypted method must pass both explicit Brain-local scope and registered-workspace validation. Relay loss means pending outcomes are interrupted, never successful.
151159

160+
Remote cross-thread conversation handoff stays Brain-local. Namespace browser replay shards under `web:`; never copy the replay store into browser persistence. Require an authenticated owner-held destination bridge and Brain-local `agent` scope, refuse handoff while the destination is running, perform bounded disposable summarization on the Brain, clear the destination native resume id, and replay the combined destination history exactly once on its next native-provider prompt. Missing history, lost ownership, or summary failure is an explicit failure, never inferred success.
161+
162+
The Hub mobile home is control-plane-only until a user selects an online machine. At ≤768px an authenticated Hub root may route to `/app?hub=mobile`, where `MobileDashboard` reads only cookie-authenticated Hub session and machine-presence data. Do not install a Brain runtime, request relay authority, expose fake agent/worktree statistics, or affect Electron/direct-server/desktop startup from this route. Machine selection enters `/app?hub=mobile&machine=…`, which may open a disposable end-to-end encrypted, Brain-scoped mobile overview; it must request only the scopes needed for real stats, render unavailable values explicitly, return bounded recent-thread metadata rather than transcript bodies, and close its relay before the full renderer opens. Compatibility fallback for an older Brain may use `transcripts.mtimes` to render untitled saved rows, but must never use `transcripts.loadAll` for this overview. Mobile overview counts must use the canonical Mission Control `deriveMissionStats` aggregation over Brain-visible transcript sessions and executions; do not duplicate `mc-stats` semantics, and do not classify completed solo turns as done. A recent-row deep link must carry a bounded workspace/tab/scope descriptor, validate workspace→tab→scope ownership after transcript hydration, preserve the exact transcript scope id when restoring a missing browser session, and refuse invalid/conflicting descriptors. Only the explicit full-app action enters `/app?machine=…` without a thread target. Keep `/?hub-admin=1` as the mobile escape hatch for Hub account and device administration.
163+
152164
### Path alias
153165

154166
`@renderer/*` → `src/renderer/src/*` (configured in both `electron.vite.config.ts` and `tsconfig.web.json`).
@@ -159,6 +171,12 @@ The design system lives in `.design/crewcode-design-system/`. The canonical CSS
159171

160172
Renderer components may use Tailwind v4 utilities through the utilities-only integration in `src/renderer/src/styles/tailwind.css`. Preflight must stay disabled so incremental conversions do not reset unrelated app surfaces. Use the `cc-*` semantic Tailwind colors, which map to the canonical live CSS tokens; see `docs/tailwind-renderer.md`.
161173

174+
The final work-log changed-file chips and Turn Changes drawer must use the same turn-change aggregation. A chip targets its exact turn/file in the drawer with the agent-summary/list sidebar closed; do not route it through the ordinary editor file-open action or rebuild a second, lossy file list.
175+
176+
Normalize multi-file provider output into one unified patch per file before rendering. Repeated edits to one file must merge their hunks under one canonical `diff --git` header so `PierreDiff` receives a single-file patch and does not drop to the raw fallback.
177+
178+
Git Sidebar `gs-changes-list` rows open the active worktree's diff in Code Editor's existing `PierreDiff` surface. Git Workspace and Git Sidebar share `useGitSidebar` comparison state and use the workspace-scoped Settings default branch as a read-only base; never checkout that branch implicitly, diff the primary workspace when a worktree is active, or expose staging actions for committed comparison-only rows.
179+
162180
**Hard rules:**
163181

164182
- Background: `#0f120f` (dark), never pure black
@@ -177,7 +195,7 @@ Three tsconfigs compose via project references:
177195

178196
## Current state
179197

180-
Read this file only when working on any of the features below and need the Current state of them `CrewCoder provider`, `ACP Grok Build`, `Sidebar Folder Creation`, `Crew Supervisor`, `Delegated Threads`,`Chat Archiving`, `Hide work Logs`, `Realtime Voice Orb`, `Notifcation Sound`, `Agent Messages`, `Agent Task Activity`, `Cusromization Panel`, `Queued Messages`, `Composer Execution Modes & reasoning`, `Claude SDK Global skills isolation`, `Provider Switch Handoff & Compact`, `Chat`, `Markdown Editor`, `Code Editor`, `Workbench Mode`, `Git Workspace/Sidebar`, [Current State](docs/current-state.md)
198+
Read this file only when working on any of the features below and need the Current state of them `CrewCoder provider`, `ACP Grok Build`, `Sidebar Folder Creation`, `Crew Supervisor`, `Delegated Threads`,`Chat Archiving`, `Hide work Logs`, `Realtime Voice Orb`, `Notifcation Sound`, `Agent Messages`, `Agent Task Activity`, `Cusromization Panel`, `Queued Messages`, `Composer Execution Modes & reasoning`, `Claude SDK Global skills isolation`, `Provider Switch Handoff & Compact`, `Chat`, `Markdown Editor`, `Code Editor`, `Workbench Mode`, `Git Workspace/Sidebar`, `Mobile-responsive Pages`, [Current State](docs/current-state.md)
181199

182200
Provider context handoff is initiated from the Solo Chat header or `/handoff`. Preserve the destination-card behavior, existing-chat provider/model/effort locking, visible destination meter, and disposable destination-provider summary flow documented in `docs/provider-context-handoff.md`.
183201

‎bin/yuheard.mjs‎

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env node
2+
// yuheard — CLI for the YuHeard terminal agent-done channel.
3+
//
4+
// Subcommands:
5+
// pane-id Print $YUHEARD_PANE_ID (or "(unset)").
6+
// socket Print the YuHeard socket path.
7+
// running [message] Report 'running' for the calling pane.
8+
// complete [message] Report 'complete' for the calling pane.
9+
// --help Show this help.
10+
//
11+
// Env:
12+
// YUHEARD_PANE_ID Set by CrewCode when it spawns a pty pane.
13+
// The CLI sends this verbatim.
14+
// YUHEARD_SOCKET Override the default socket path
15+
// (~/.crewcode/yuheard.sock).
16+
//
17+
// Exit codes:
18+
// 0 ok
19+
// 1 socket error / no pane for cwd
20+
// 2 bad arguments
21+
//
22+
// See docs/yuheard.md for the protocol and integration patterns.
23+
24+
import net from 'node:net'
25+
import os from 'node:os'
26+
import path from 'node:path'
27+
28+
const args = process.argv.slice(2)
29+
const sub = args[0]
30+
const SOCKET = process.env.YUHEARD_SOCKET
31+
?? path.join(os.homedir(), '.crewcode', 'yuheard.sock')
32+
33+
function send(line, { timeoutMs = 1000 } = {}) {
34+
return new Promise((resolve, reject) => {
35+
const sock = net.createConnection(SOCKET)
36+
let buf = ''
37+
let settled = false
38+
const t = setTimeout(() => {
39+
if (settled) return
40+
settled = true
41+
sock.destroy()
42+
reject(new Error(`socket timeout after ${timeoutMs}ms`))
43+
}, timeoutMs)
44+
sock.on('data', d => { buf += d.toString('utf8') })
45+
sock.on('end', () => {
46+
if (settled) return
47+
settled = true
48+
clearTimeout(t)
49+
resolve(buf.trim())
50+
})
51+
sock.on('error', e => {
52+
if (settled) return
53+
settled = true
54+
clearTimeout(t)
55+
reject(e)
56+
})
57+
sock.write(line + '\n')
58+
sock.end()
59+
})
60+
}
61+
62+
function reportLine(state, message) {
63+
return JSON.stringify({
64+
pane_id: process.env.YUHEARD_PANE_ID ?? '',
65+
state,
66+
source: 'yuheard-cli',
67+
message,
68+
ts: Date.now(),
69+
})
70+
}
71+
72+
async function resolvePaneId() {
73+
if (process.env.YUHEARD_PANE_ID) return process.env.YUHEARD_PANE_ID
74+
const cwd = process.cwd()
75+
const lookupLine = JSON.stringify({ method: 'pane-id-lookup', cwd })
76+
const reply = await send(lookupLine)
77+
let parsed
78+
try { parsed = JSON.parse(reply) } catch { throw new Error(`invalid server reply: ${reply}`) }
79+
if (!parsed.ok) throw new Error(parsed.error ?? 'lookup failed')
80+
return parsed.paneId
81+
}
82+
83+
function help() {
84+
process.stdout.write(`Usage: yuheard <subcommand> [args]
85+
86+
pane-id Print $YUHEARD_PANE_ID (or "(unset)").
87+
socket Print the YuHeard socket path.
88+
running [message] Report running for the calling shell's pane.
89+
complete [message] Report complete for the calling shell's pane.
90+
--help Show this help.
91+
92+
Env:
93+
YUHEARD_PANE_ID Set by CrewCode when it spawns a pty pane.
94+
YUHEARD_SOCKET Override default (~/.crewcode/yuheard.sock).
95+
96+
Exit codes:
97+
0 ok 1 error 2 bad arguments
98+
`)
99+
}
100+
101+
async function main() {
102+
switch (sub) {
103+
case 'pane-id':
104+
process.stdout.write(`${process.env.YUHEARD_PANE_ID ?? '(unset)'}\n`)
105+
return
106+
case 'socket':
107+
process.stdout.write(`${SOCKET}\n`)
108+
return
109+
case '--help':
110+
case '-h':
111+
case undefined:
112+
help()
113+
return
114+
case 'running':
115+
case 'complete': {
116+
const message = args.slice(1).join(' ').trim() || undefined
117+
const paneId = await resolvePaneId()
118+
const line = reportLine(sub, message).replace(
119+
'"pane_id":""',
120+
`"pane_id":"${paneId.replace(/"/g, '\\"')}"`,
121+
)
122+
const reply = await send(line)
123+
process.stdout.write(`${reply}\n`)
124+
return
125+
}
126+
default:
127+
process.stderr.write(`yuheard: unknown subcommand "${sub}"\n`)
128+
help()
129+
process.exitCode = 2
130+
}
131+
}
132+
133+
main().catch(err => {
134+
process.stderr.write(`yuheard: ${err?.message ?? String(err)}\n`)
135+
process.exit(1)
136+
})

‎docs/code-editor.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CrewCode's code editor uses a fork of CodeMirror 6 for the active editing surfac
55
## Current foundation
66

77
- `src/renderer/src/components/editor/CodeEditor.tsx` owns the surrounding product UI: tabs, file tree, save/format actions, disk-change conflict handling, plugin editor actions, and search-result jumps.
8+
- Git Sidebar changed-file rows open the active worktree's patch in the editor's existing `PierreDiff` review surface. The Settings-selected default branch is the comparison ref when configured; closing the review returns to the prior editor state without changing the checked-out branch.
89
- `src/renderer/src/components/editor/CrewCodeMirrorEditor.tsx` owns the live editing surface.
910
- CodeMirror is intentionally kept below `CodeEditor` so high-frequency typing, selection, autocomplete, and scroll state do not force broad React/App re-renders.
1011
- Source documents, including Markdown opened in the code editor, soft-wrap long lines by default. Wrapping is visual only: it never inserts newlines or changes line-number semantics.

‎docs/conversation-storage.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ On first access, CrewCode copies legacy entries into sharded files and writes `c
3232

3333
If a sharded file is missing or unreadable, CrewCode can lazily recover that session from the legacy monolith. Explicitly cleared sessions are recorded in `conversations/.agent-conversations-cleared.json` so legacy fallback does not resurrect deleted conversations.
3434

35+
### Browser/Brain conversation scopes
36+
37+
Remote browser replay history remains authoritative on the Brain, not in browser `localStorage`. The shared renderer supplies an opaque chat session id; the remote boundary namespaces it as `web:<session>` before `AgentBridgeService` reads or writes the same per-session conversation shards described above. This keeps desktop `thread:` keys and browser keys from aliasing each other.
38+
39+
Cross-thread browser handoff is a bounded Brain-side operation. The browser names a source chat and an already-owned destination bridge, but never downloads the source replay shard. The Brain summarizes the source with a disposable destination-provider bridge, appends only the resulting handoff packet to the destination shard, clears the destination's native resume id, and replays the combined destination history once on its next native-provider prompt. Stateless HTTP providers consume the updated shard directly. Missing source history, summary failure, a running destination, or lost destination ownership is an explicit failure and is never inferred as success.
40+
3541
## Session ids and the context-meter baseline
3642

3743
`src/main/agents/sessionStore.ts` persists per-session bridge state under `userData/agent-sessions.json`, keyed by the `tabId:agentId` composite the renderer uses for bridge registration:

0 commit comments

Comments
 (0)