cc-viewer 1.9.3 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,14 +61,14 @@ Once started in programming mode, the web page opens automatically.
61
61
 
62
62
  cc-viewer also ships as a native desktop app: [download page](https://github.com/weiesky/cc-viewer/releases)
63
63
 
64
- ### SDK mode (headless, `ccv -SDK`)
64
+ ### SDK mode (headless, `ccv --sdk`)
65
65
 
66
- `ccv -SDK` runs the session through the Agent SDK instead of an interactive terminal — no terminal panel, messages are sent from the web UI, and everything else (session logs, streaming typewriter, usage stats) works the same as in terminal mode.
66
+ `ccv --sdk` runs the session through the Agent SDK instead of an interactive terminal — no main PTY, messages are sent from the web UI, and everything else (session logs, streaming typewriter, usage stats) works the same as in terminal mode. The header still exposes a **Terminal** button, but it opens the standalone scratch multi-tab shell (unrelated to the SDK session), not a project PTY.
67
67
 
68
68
  ```bash
69
- ccv -SDK # headless session; chat from the browser
70
- ccv -SDK -c # continue the most recent session
71
- ccv -SDK --model sonnet # pick a model
69
+ ccv --sdk # headless session; chat from the browser
70
+ ccv --sdk -c # continue the most recent session
71
+ ccv --sdk --model sonnet # pick a model
72
72
  ```
73
73
 
74
74
  Approvals (Bash/Edit/Write/WebFetch/…) pop up in the browser with allow / deny / allow-for-session, and `AskUserQuestion` / plan prompts appear as modals. `npm publish` always requires an explicit approval — even with `--d`. Requires the `@anthropic-ai/claude-agent-sdk` package (bundled with cc-viewer); falls back to terminal mode if unavailable.
package/cli.js CHANGED
@@ -788,6 +788,13 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
788
788
  const childEnv = {
789
789
  ...process.env,
790
790
  ANTHROPIC_BASE_URL: proxyBaseUrl,
791
+ // Opt the CLI child into emitting `session_state_changed` messages (idle /
792
+ // running / requires_action) — the authoritative turn-level busy signal the
793
+ // conversation spinner needs. Gated emission point in the CLI binary; harmless
794
+ // on older CLIs (unknown env is ignored, sdk-manager falls back to
795
+ // push-running/result-idle broadcasts). Top-level childEnv, not settings.env:
796
+ // the settings merge path could be overridden by user settings.
797
+ CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: '1',
791
798
  // 与 PTY 子进程同款(pty-manager.js:247):SDK 子进程的 cli.js 若已被 -logger/PTY 注入
792
799
  // interceptor,CCV_PROXY_MODE=1 让它只装 fetch hook 而不再自起 server;wire 捕获本来
793
800
  // 就发生在主进程 proxy 的出站 fetch(ANTHROPIC_BASE_URL 指过来),此键保证子进程不双起。
@@ -863,6 +870,20 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
863
870
  onQueryError: (message) => serverMod.broadcastWsMessage({ type: 'sdk-error', message }),
864
871
  });
865
872
 
873
+ // Per-cwd multi-session (2026-10-12): hand the boot launch config (proxy env, model,
874
+ // permission, executable, user args) to the manager as a process-level template. The
875
+ // workspace-launch route uses it to register a session for a NEW cwd — without it the new
876
+ // session would get no env (bypassing the proxy → no transcript, no per-cwd routing).
877
+ // launchResume is boot-only and deliberately NOT templated.
878
+ sdkManager.setSdkLaunchConfig({
879
+ permissionMode,
880
+ env: childEnv,
881
+ settings: JSON.parse(settingsMerge.settingsJson),
882
+ model: sdkArgs.model,
883
+ userArgs: sdkArgs.rest,
884
+ claudeExecutable: sdkClaudePath,
885
+ });
886
+
866
887
  // 注册 SDK 回调到 server.js(WS 消息路由用)
867
888
  serverMod.setSdkResolveApproval(sdkManager.resolveApproval);
868
889
  serverMod.setSdkCancelApproval(sdkManager.cancelApproval);
@@ -870,6 +891,9 @@ async function runSdkMode(extraClaudeArgs = [], cwd, noOpen = false) {
870
891
  serverMod.setSdkInterruptTurn(sdkManager.interruptTurn);
871
892
  serverMod.setSdkGetPendingApprovals(sdkManager.getPendingApprovals);
872
893
  serverMod.setSdkGetInitSnapshot(sdkManager.getSdkInitSnapshot);
894
+ serverMod.setSdkGetContextUsageSnapshot(sdkManager.getContextUsageSnapshot);
895
+ serverMod.setSdkGetMcpStatusSnapshot(sdkManager.getMcpStatusSnapshot);
896
+ serverMod.setSdkGetSessionStateSnapshot(sdkManager.getSessionStateSnapshot);
873
897
  // Busy-queue bubble actions (queue-send-now / queue-remove / queue-clear / replay).
874
898
  serverMod.setSdkSendQueuedNow(sdkManager.sendQueuedNow);
875
899
  serverMod.setSdkRemoveQueued(sdkManager.removeQueued);