Commit Graph
206 Commits
Author SHA1 Message Date
Claude 5f81ec49c2 merge: resolve conflicts with main branch
Merge github/main into feature/add_web_admin_v2.
- Go backend files auto-merged cleanly
- All web/ conflicts resolved by keeping feature branch version
  (feature branch has the latest, most complete web admin)
- Remove Logs.tsx brought in from main (no backend endpoint)
- Fix go.sum checksum for BurntSushi/toml

Made-with: Cursor
2026-03-30 11:54:58 +08:00
Claude 7461a64c60 feat: add /web command for one-click web admin install and npm publish config
- Add /web install|upgrade|status|uninstall slash command (privileged)
- Auto-install cc-connect-web via npm into ~/.cc-connect/web/
- Auto-configure [bridge] and [management] in config.toml with random tokens
- Management server serves SPA static files from dist/ with fallback to index.html
- Add config.EnableWebAdmin() for atomic bridge+management setup
- Add core/web_manager.go with npm registry integration
- Prepare web/package.json for npm publish as cc-connect-web (files: dist/)
- Add i18n translations for all /web messages (en, zh, zh-TW, ja, es)

Made-with: Cursor
2026-03-29 09:59:06 +08:00
Claude be13a75406 fix(core): wait for old session to close when recycling
When a session mismatch is detected (e.g., after /new or /switch), the
old agent session was closed asynchronously via closeAgentSessionAsync().
The new session started immediately without waiting for the old one to
fully terminate, causing both agents to potentially output simultaneously
and produce duplicate responses.

Fix: Change async close to synchronous close in session recycling path.
This ensures the old agent process is fully terminated before starting
a new one. The closeAgentSessionWithTimeout() has a 10s timeout to
prevent indefinite blocking.

Root cause analysis:
- getOrCreateInteractiveStateWith() detected session mismatch
- markStopped() was called, but event loop might be mid-processing
- closeAgentSessionAsync() ran in goroutine, new session started
- Old agent continued outputting until Close() completed
- User received two similar responses from two different agents

Fixes #327

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 10:13:28 +00:00
Claude e0e2be4e31 fix(core): 出站限流补全、工具结果展示与 i18n 收紧
- waitOutgoing/sendWithError:重启通知、SendToSession(含图片/文件)、权限与 AskQuestion 内联按钮路径纳入出站令牌桶

- EventResult 分块与 channelClosed 收尾使用 sendWithError,首包失败即停止发送

- ProgressStyleProvider 且 progress_style=legacy 时不再单独推送 EventToolResult 聊天消息(compact/card 仍走 writer)

- 工具结果 fallback 标签改为 MsgKey,补全日/西/繁中翻译

- config.example.toml:说明小数 max_per_second 时 burst 取 ceil

- 修复 processInteractiveEvents 测试参数;新增 SuppressStandaloneToolResultEvent 单测

- fix(codex): 假 codex 脚本用 stdin 读 prompt,适配 --json -
2026-03-28 00:42:35 +08:00
Jerry b56865fb06 feat(feishu): add configurable progress styles (compact/card) to reduce message spam
* feat(feishu): add compact progress style for thinking/tool updates

* feat(feishu): add card-style streaming progress updates
2026-03-28 00:16:13 +08:00
Max Qian d7bed29801 feat(core): add outgoing message rate limiting per platform 2026-03-27 23:59:11 +08:00
Deeka WongandDeeka Wong 1225b7ee18 feat(claudecode): add auto permission mode
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
2026-03-27 23:42:53 +08:00
Jerry 5639e863d5 fix(core): route workspace model changes through session context 2026-03-27 23:31:08 +08:00
xxb 526f52e5fc fix(codex): force kill session process group on stop (#340)
* fix(codex): force kill session process group on stop

* fix(codex): kill all active session processes on stop

* fix(core): stop stale event loops on stop
2026-03-27 23:11:16 +08:00
Buqian Zheng 1104739c90 feat(telegram): migrate to go-telegram/bot and add forum topic support (#321)
* feat(telegram): migrate to go-telegram/bot and add forum topic support

Migrate the Telegram platform from the unmaintained go-telegram-bot-api/v5
(last release 2021) to go-telegram/bot v1.20.0, which is actively maintained
and supports the full Telegram Bot API including forum topics.

Key changes:

- **Library migration**: Replace go-telegram-bot-api/v5 with go-telegram/bot.
  Redesign the telegramBot interface around the new library's typed API methods
  (SendMessage, SendPhoto, EditMessageText, etc.) instead of the old generic
  Send/Request pattern. The *bot.Bot type satisfies the interface directly.

- **Forum topic support**: Add threadID to replyContext and session key.
  Messages in forum groups (IsForum=true) now include the MessageThreadID
  in the session key (telegram:{chatID}:{threadID}:{userID}), giving each
  topic its own independent agent session. All send methods propagate
  MessageThreadID so replies land in the correct topic. Non-forum groups
  and private chats are unaffected.

- **Per-topic workspace binding**: Add ChannelKey field to core.Message so
  platforms can provide an explicit channel identifier for workspace binding.
  Telegram sets this to "chatID:threadID" for forum topics, enabling
  multi-workspace mode to bind different topics to different project
  directories. Add effectiveChannelID/effectiveWorkspaceChannelKey helpers
  and update all workspace resolution call sites in the engine.

- **Skill command registration fix**: GetAllCommands now respects
  disabled_commands for skills, matching the existing behavior for
  built-in commands. This prevents disabled skills from being registered
  as Telegram bot menu commands.

- **Connection management**: Simplify the reconnect architecture.
  bot.New() handles initial validation, bot.Start(ctx) manages long
  polling internally. Remove the stale bot detection (generation
  comparison in handlers) since the new library's blocking Start()
  ensures handlers are never called from a superseded bot instance.

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>

* fix: resolve lint errors exposed by engine.go and telegram_test.go changes

- Remove unused assignment to `s` in cmdNew (SA4006)
- Remove unused stubBotFactory and failingBotFactory helpers in telegram tests

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>

---------

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
2026-03-27 23:01:33 +08:00
Jerry b04ece2dd7 fix(core): normalize interactive session key lookup in multi-workspace mode (#267)
* fix(core): use interactive key for status card and SendToSession lookups in multi-workspace

* fix(core): remove unused new session assignment
2026-03-27 09:36:31 +08:00
Claude a6f6e720f7 feat(web): improve UI/UX, cron editor, config persistence, and theme consistency
- Remove bridge navigation and page (unused)
- Dashboard projects: grid layout (1/2/3 cols) instead of single column list
- System config: display raw TOML from config file instead of JSON summary
- Remove logs page (no backend endpoint)
- Cron page: grid layout, click-to-edit, friendly schedule dropdown,
  session key dropdown, mutually exclusive prompt/exec task type toggle
- Move language/theme/logout controls from sidebar to right header
- Unify accent color: use CSS variables with RGB format for proper
  Tailwind opacity support; light mode uses darker green (#16a34a),
  dark mode keeps neon green (#42ff9c)
- Fix Badge info variant from blue to accent green
- Align sidebar/header heights (both h-14)
- Add footer with copyright, version number, and GitHub link
- Fix project settings PATCH: persist quiet/language/admin_from/
  disabled_commands to config.toml via new SaveProjectSettings()
- Return admin_from and disabled_commands in project GET response
- Add GetDisabledCommands() to Engine for settings readback
- Backend: add PATCH support to cron job endpoint for editing
- Backend: /config endpoint returns raw TOML file content

Made-with: Cursor
2026-03-27 09:32:22 +08:00
cg33andClaude 9ca371e1f7 feat(wecom): 企业微信 HTTP 回调支持接收文件并交给 Agent (#330)
* feat(wecom): handle inbound file messages over HTTP callback

Parse MsgType=file (FileName + MediaId), download via media/get API,
and forward as core.FileAttachment for agents. Add MIME inference helper
and unit tests. Document inbound capabilities in config.example.toml.

WebSocket AI bot mode unchanged; file receive there depends on WeChat policy.

* chore(wecom): add Info/Warn logs for callback diagnostics

Log every POST (size, query flags), parsed msg_type/msg_id/from_user,
duplicate/old/allow_from drops, unsupported types at Warn, and Debug
preview of decrypted XML (truncated). Helps trace missing file pushes.

* feat(wecom-ws): receive image, file, mixed and quote media over AI bot WebSocket

Parse msgtype image/file/mixed and quote (text, voice, image, file, mixed)
per WeCom smart-bot protocol. Download encrypted media from signed URLs
and decrypt with AES-256-CBC (IV = first 16 bytes of base64 key), matching
@wecom/aibot-node-sdk. Voice accepts both content and legacy text fields.

Adds wsCollectInboundParts, deliverWSMediaInbound, unit tests for collect,
Content-Disposition parsing, and round-trip decryption.

* fix(wecom-ws): handle file in mixed payloads and normalize aeskey decoding

- Collect file items inside mixed.msg_item and merge top-level file/image
  when msgtype is file/image but a non-empty mixed block is also present.
- decodeWeComAESKey: trim whitespace, URL-safe base64, padding, optional hex.
- Add regression tests for mixed+file and aeskey variants.

* fix: satisfy golangci-lint (gosimple, staticcheck)

- wecom: use := for walkMixed/walkQuote closures (S1021).
- engine: drop unused assignment from sessions.NewSession in cmdNew (SA4006).

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-26 14:51:28 +08:00
xxb 6d8bf93e4c fix: harden Discord session routing and remove implicit continue bridge (#322)
* fix(discord): dedup duplicate interaction events

* fix(core): remove implicit continue bridge

* fix(discord): avoid empty button reply references
2026-03-25 14:31:27 +08:00
xxb a44b375bce fix(core): exact-resume saved session on workspace reconnect (#315) 2026-03-25 06:30:30 +08:00
Claude e065b6d22f feat(integration-tests): add integration test suite for real agent sessions
Add a new integration test suite that verifies real agent (Claude Code, Codex,
Cursor, Gemini, OpenCode) interactions with a mock platform. Tests are gated
by //go:build integration tag so they're excluded from normal CI.

core/engine.go:
- Add public ReceiveMessage(p, msg) method to allow test callers to
  inject messages into the engine

tests/integration/agent_integration_test.go:
- mockPlatform implementing core.Platform interface for test verification
- agentPool for reusing agent instances across tests
- Session tests: new session, /list, /switch, /stop, /new context clear, /history
- Agent tests: claude code, codex, cursor, gemini (skip if quota), opencode (skip if no gitlab auth)
- Command tests: /shell (skip if admin_from not set), /provider list
- i18n: /lang zh language switch
- Concurrency: session isolation, long text chunking, empty message handling

docs/plans/2026-03-24-integration-tests.md:
- Test plan listing all implemented and planned integration test cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 15:56:18 +08:00
Claude 2700b5b027 Merge remote-tracking branch 'github/main' (sync merged PRs) 2026-03-24 14:19:13 +08:00
0a2e860b56 fix: clear old session state in /new command to prevent stale resume (#248)
* fix: require explicit session key when sending attachments with multiple sessions

When cc-connect send --image or --file is called without an explicit
--session flag and there are multiple active sessions, the code would
arbitrarily pick the first session from a map (non-deterministic order).
This could cause attachments to be sent to the wrong chat.

Now returns an error when multiple sessions exist and no session key is
specified for attachment sends. Also adds debug logging to Telegram SendImage
to aid future diagnosis.

Fixes #242

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: clear AgentSessionID on old session in /new command

When /new is invoked, the old session's AgentSessionID was not being
cleared. This could cause the old session to be resumed on the next
message if GetOrCreateActive returned it instead of the newly created
session.

The fix clears the old session's AgentSessionID and clears its history
before creating a new session, similar to how cmdSwitch handles session
transitions.

Fixes #238

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Dev Claude <dev@cc-connect.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 14:17:06 +08:00
cg33andClaude dc8808ea1a fix(engine): /new must not reuse prior Claude process (fixes #238) (#297)
* fix(codex): avoid closing events channel before readLoop exits

Close() previously closed cs.events after an 8s wait even when wg.Wait
had not finished, while readLoop could still send in flushPendingAsText
(turn.completed), causing "panic: send on closed channel" after /stop
then /new. Defer channel close until readLoop completes.

Fixes https://github.com/chenhg5/cc-connect/issues/281

* fix(engine): recycle live agent when Session clears AgentSessionID (/new)

getOrCreateInteractiveStateWith reused any alive process when wantID was empty
because the condition treated empty wantID as always compatible. After /new the
Session has no resume ID but the old Claude process still reported the previous
session — messages kept going to stale context.

Recycle when the live process has a concrete ID but the Session expects none or
a different one.

Fixes #238

Made-with: Cursor

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-24 14:16:23 +08:00
cg33andClaude 87fa8e2e4d fix(session): do not persist __continue__ as agent_session_id (fixes #255) (#298)
* fix(codex): avoid closing events channel before readLoop exits

Close() previously closed cs.events after an 8s wait even when wg.Wait
had not finished, while readLoop could still send in flushPendingAsText
(turn.completed), causing "panic: send on closed channel" after /stop
then /new. Defer channel close until readLoop completes.

Fixes https://github.com/chenhg5/cc-connect/issues/281

* fix(session): never persist ContinueSession as agent_session_id (#255)

- Reject storing the __continue__ sentinel in SetAgentSessionID; normalize in SetAgentInfo.
- Let CompareAndSetAgentSessionID overwrite a mistaken persisted sentinel with a real ID.
- Strip sentinel when loading session JSON and when saving snapshots.
- Simplify engine post-start writeback to a single CompareAndSet path.

Fixes #255

Made-with: Cursor

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-24 14:16:17 +08:00
573b1d3eb3 fix: require explicit session key when sending attachments with multiple sessions (#247)
When cc-connect send --image or --file is called without an explicit
--session flag and there are multiple active sessions, the code would
arbitrarily pick the first session from a map (non-deterministic order).
This could cause attachments to be sent to the wrong chat.

Now returns an error when multiple sessions exist and no session key is
specified for attachment sends. Also adds debug logging to Telegram SendImage
to aid future diagnosis.

Fixes #242

Co-authored-by: Dev Claude <dev@cc-connect.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 14:15:43 +08:00
Claude ac79163082 fix(engine): pass replyCtx as parameter to processInteractiveEvents
Avoids race condition when cron and regular messages share the same
interactiveKey — the shared state.replyCtx was being overwritten by
concurrent goroutines, causing cron responses to be delivered to the
wrong session.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 04:14:51 +00:00
cg33andClaude 66f3007f07 feat(agent): ACP (Agent Client Protocol) stdio adapter MVP
* feat(agent): add ACP stdio JSON-RPC adapter (MVP)

Implement agent/acp as an ACP client over newline-delimited JSON-RPC: initialize,
session/new or session/load, session/prompt, session/update mapping to core.Event,
and session/request_permission wired to RespondPermission.

Includes plugin_agent_acp.go (!no_acp), Makefile ALL_AGENTS entry, config example,
unit tests for transport and mapping, and AgentDoctorInfo for doctor.

Made-with: Cursor

* fix(acp): Cursor CLI compatibility — authenticate + cursor/* RPC ack

- Optional auth_method (e.g. cursor_login) triggers JSON-RPC authenticate after initialize
- initialize includes minimal clientCapabilities (fs/terminal) per Cursor ACP docs
- Acknowledge cursor/* server requests with empty result to avoid blocking tool flows
- Add integration test against ~/.local/bin/agent when present
- Document auth_method and args in config.example.toml

* fix(telegram): use Request for sendChatAction typing indicator

Telegram returns result=true for sendChatAction; BotAPI.Send unmarshals
result as Message and fails. Request only checks ok and avoids that decode.

* fix(core): surface EventToolResult in IM; extend ACP tool/thinking mapping

- Engine: handle EventToolResult in interactive loop (was silently dropped);
  compress and relay paths append tool output too. Add MsgToolResult i18n.
- ACP: stream tool_call_update for in_progress/pending; optional reasoning_*
  sessionUpdate kinds -> EventThinking; fallback hook for unknown kinds.

* fix(core): run agent Send concurrently with interactive event loop

Agents that block inside Send (e.g. ACP session/prompt) can emit
EventPermissionRequest while blocked; the engine must consume Events()
in parallel or permission prompts never reach the platform.

- processInteractiveMessageWith: async Send + pass sendDone into processInteractiveEvents
- processInteractiveEvents: select on sendDone for errors and sync at turn boundaries
- drainPendingMessages: same async Send pattern as the main path
- Add TestProcessInteractiveEvents_PermissionWhileSendBlocked regression test

* docs(acp): document OpenClaw and Copilot CLI; add display_name option

- config.example.toml: Cursor, OpenClaw (`openclaw acp`), Copilot (`copilot --acp --stdio`) examples with upstream doc links
- acp agent: optional display_name for doctor (AgentDoctorInfo)
- agent_test.go: cover default and custom display_name

* fix(core): remove ineffectual pendingSend assignments (ineffassign)

pendingSend was set to nil immediately before return or before
reassignment to nextSend; golangci-lint flags these as ineffectual.

* test(core): fix race in PermissionWhileSendBlocked under -race

The test goroutine polled stubInlineButtonPlatform.buttonRows while
processInteractiveEvents wrote them from another goroutine. Use a
permSignalInlinePlatform wrapper that signals on perm:allow via a channel
instead of racy field reads.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-24 08:03:57 +08:00
buddhism5080andClaude Opus 4.6 888cfe2828 feat(discord): 为 mode 和 reasoning 添加按钮
* feat(discord): add mode and reasoning button controls

Use Discord buttons for /mode and /reasoning, and apply Claude Code mode changes to the current session when supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(discord): clean up mode labels and log button fallback errors

Remove the extra mode marker symbol, show the current mode with text instead, and include the underlying error when permission button fallbacks trigger.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-03-24 08:03:32 +08:00
Deeka WongandDeeka Wong 288107d6bf fix(core): surface model save failures
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
2026-03-24 08:03:29 +08:00
xxb ac34d94f05 feat(core): add shared workspace routing infrastructure
* feat(core): implement shared workspace routing and binding fallback

* fix(core): allow shared workspace commands for users

* fix(core): scope workspace bindings by platform
2026-03-24 08:03:18 +08:00
xxb aaffa0cc84 fix(core): preserve CC_SESSION_KEY in multi-workspace sessions 2026-03-24 08:03:14 +08:00
Claude cb2371c15a feat: /dir cards, context indicator toggle, Feishu flat send option
- core: interactive /dir card (nav/act) on CardSender platforms; dirApply refactor
- core+i18n: card strings for dir history UI
- config: projects.show_context_indicator (hide [ctx: ~N%] suffix)
- feishu/lark: reply_to_trigger=false posts via Create instead of Reply
- codex: skip flush when ctx done; sync.Once on session Close
- dingtalk: stream runner reconnect loop; cancel on Stop
- go.mod: mark rsc.io/qr as direct require
2026-03-23 16:49:42 +08:00
Leigh StillardandClaude Opus 4.6 401525931b feat: session resilience — --continue, resume recovery, context indicator
* feat: add session resilience with --continue, resume recovery, and context indicator

First connection after engine startup uses --continue to pick up the most
recent CLI session, bridging direct CLI usage and cc-connect. If resume
fails (e.g. prompt too long), automatically falls back to a fresh session.

Appends [ctx: ~XX%] to agent responses using SDK token counts, with
fallback to agent self-reported context percentage when SDK values are
unreliable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: --continue logic bug — respect fresh session intent after first connection

Remove the startSessionID == "" condition that forced --continue even
when users explicitly requested fresh sessions (e.g. via /new). Now only
the first connection after engine startup uses --continue; subsequent
connections respect the stored session ID or "" for fresh.

Add TestFreshSessionRespectedAfterFirstConnection to verify.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(npm): correct pre-release version comparison

The isNewerOrEqual function was comparing pre-release strings
lexicographically (e.g., "beta.2" > "beta.10" due to string comparison),
causing incorrect downgrade detection. Now parses pre-release into
id and numeric parts for proper numeric comparison.

Fixes: beta version upgrade being treated as outdated and downgrading to stable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore(npm): bump version to 1.2.2-beta.4

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: make hasConnectedOnce per-workspace so idle-reaped workspaces resume with --continue

hasConnectedOnce was engine-global, so after the first connection set it
to true, any workspace that got idle-reaped and later recreated would
skip --continue and spawn a fresh session — losing all prior context.

Move the flag into workspaceState so each workspace independently tracks
its first connection. When a workspace is reaped and GetOrCreate makes a
new one, the flag starts false again, enabling --continue on reconnection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: fork session on resume/continue to prevent context interleaving

When cc-connect picks up a session via --continue or --resume, add
--fork-session so the platform conversation gets its own independent
context branch. This prevents history interleaving when the user is
also working in the same session from the CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 08:30:19 +08:00
q107580018 fa9280b543 fix(feishu): preserve preview card finalization and silence ws heartbeat spam
* fix(feishu): preserve preview card and reduce ws heartbeat noise

* docs: document /dir usage and fix feishu reference link
2026-03-23 08:01:28 +08:00
Junyi Du e383792553 fix (discord): Discord cron thread retargeting when thread_isolation=true 2026-03-23 08:01:25 +08:00
Gaoyuan-SIATandKRATSZ da7fa2b77d feat: persist /dir work directory overrides across restarts
Restore persisted /dir overrides on startup, apply them to session and heartbeat wiring, and add /dir reset plus docs so work directory changes survive restart without editing config.toml.

Made-with: Cursor

Co-authored-by: KRATSZ <KRATSZ@users.noreply.github.com>
2026-03-22 16:33:18 +08:00
Claude e99b5781c8 fix(core): replace persisted ContinueSession sentinel with real agent ID
CompareAndSetAgentSessionID only fills an empty ID; after restart the
stored sentinel __continue__ would block writing the actual session id
from the running agent. Handle that case explicitly.
2026-03-22 12:26:09 +08:00
q107580018 8a75a00df5 feat(telegram): add async startup recovery
* docs: add telegram async recovery design

* feat(telegram): add async startup recovery

* fix(telegram): resolve lint nits

* fix(core): resolve errcheck lint issues

* chore: fix launchd lint issues

* test(telegram): wrap bot api fixtures for interface
2026-03-22 12:03:30 +08:00
alinnbandClaude Opus 4.6 6771598e0b feat(core): add directory history for /dir command
- Add DirHistory module to track recently used directories per project
- /dir now shows history list with indices for quick navigation
- Support /dir <number> to jump to history entry
- Support /dir - to return to previous directory
- History stored in data_dir/dir_history.json
- Initial work_dir from config is automatically added to history

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 11:03:25 +08:00
Claude e2d12c2454 fix: reserve CLI --continue bridge for real user traffic
- Only flip hasConnectedOnce when starting an agent for non-synthetic
  messages (exclude UserID cron and heartbeat) so scheduled jobs cannot
  consume the one-time ContinueSession bridge.
- Add regression tests and align Codex exec resume arg comments with
  the actual --json placement.
2026-03-21 20:58:42 +08:00
Claude 87141fe07c fix: auto-compress counts pending assistant; cron side sessions
- Estimate tokens including the current turn assistant text before AddHistory
  so auto-compress triggers match intent and tests stay green.
- Add SessionManager.NewSideSession for jobs that need an isolated Session
  without changing the user active session; use it for cron new_per_run.
2026-03-21 20:56:22 +08:00
huluma1314andHuluma 253ef30f4e Auto-compress context when token threshold exceeded (#231)
Co-authored-by: Huluma <huluma@HulumadeMac-mini.local>
2026-03-21 20:33:03 +08:00
5f7a558eda fix: codex mode switch not taking effect and --json flag position (#240)
Fixes issue #233 and #220.

## Changes

### 1. Fix /mode command not taking effect (Issue #233)

When switching mode via `/mode yolo`, the new mode was saved to the agent
but the existing session continued using the old mode. This caused YOLO
mode to not work until a new session was manually started.

Fix: Reset the session when mode changes, similar to how /model works.

File: core/engine.go

### 2. Fix --json flag position in codex exec resume (Issue #220)

The --json flag was placed before the thread_id positional argument in
`codex exec resume` command, causing "unexpected argument '--json'" error
on the second message in a session.

Fix: Move --json to the correct position after thread_id and before prompt.

Before: codex exec resume --json --skip-git-repo-check <tid> <prompt>
After:  codex exec resume --skip-git-repo-check <tid> --json --cd <dir> <prompt>

Files: agent/codex/session.go, agent/codex/session_test.go

Co-authored-by: Ubuntu <ubuntu@localhost.localdomain>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 20:32:52 +08:00
Leigh StillardandClaude Opus 4.6 df5cc64ef4 feat: fork session on --continue to prevent context contamination (#244)
When cc-connect starts up and picks up the most recent CLI session via
--continue, it now adds --fork-session to create an independent context
branch. This prevents history interleaving when the user is concurrently
working in the same workspace from both the CLI and a messaging platform.

Without this, resuming into an active CLI session corrupts both context
windows — the model sees interleaved tool calls and responses from two
different conversations, leading to hallucinations about files and state.

The fork only applies to --continue (first connection after startup,
where we grab "whatever is latest" which may be an active CLI session).
Plain --resume of cc-connect's own stored session ID is unaffected,
since that session belongs to cc-connect and has no interleaving risk.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 20:32:48 +08:00
术士木星 253a7a73e8 feat(cron): optional new session per run and per-job timeout (#236)
* feat(cron): optional new session per run and per-job timeout

- Add session_mode (reuse default, new_per_run) and timeout_mins to CronJob
- new_per_run uses isolated interactiveState + CC_SESSION_KEY unchanged
- Per-job scheduler/shell wait timeout; 0 = unlimited; nil = 30m
- Wire Unix socket, management API, CLI; docs + tests

Made-with: Cursor

* docs(cron): document optional flags and clean up variable naming
2026-03-21 20:32:24 +08:00
Deeka WongandDeeka Wong 9df8d494dd feat(core): align /model switching with provider flow (#246)
Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
2026-03-21 20:32:22 +08:00
Shawn 5e69ef8328 fix: workspace command prefix check missing leading slash in multi-workspace mode (#135)
In handleMessage, the check to skip handleWorkspaceInitFlow for
/workspace and /ws commands was comparing against "workspace" and "ws "
without the leading "/" prefix. Since content retains its "/" at this
point, the check always evaluated to false, causing /workspace commands
to be consumed by the init flow when it was active.

This meant that during an active workspace init flow, sending
"/workspace bind <name>" would trigger the "not a git URL" error
instead of being routed to the workspace command handler.
2026-03-21 14:38:14 +08:00
Claude b9af7ea7ba fix: handle errors and add error logging throughout codebase
The changes add error handling for previously ignored operations and introduce logging for critical errors and warnings. This includes:
- Adding error checks for file operations, JSON unmarshaling, system calls
- Logging warnings/errors for failed operations using slog
- Properly handling return values from functions that were previously ignored
- Adding context to error messages for better debugging
- Cleaning up unused code and variables

generated by llmgit

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-20 00:31:00 +08:00
Claude 32194025c3 feat(whoami): add card support and text formatting for whoami command
Implement card rendering for /whoami command when platform supports cards, with proper formatting of user identity information. Added extractPlatformName helper and new i18n messages. Includes test case for card rendering.

generated by llmgit

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-19 21:58:52 +08:00
Claude 8dfedee851 feat: add /whoami command to display user ID for allow_from/admin_from config
- Added new /whoami command (with /myid alias) to show user identity info
- Updated /status command to include User ID in output
- Modified allow_from guidance to recommend /whoami instead of manual lookup
- Added i18n strings and tests for new functionality
- Updated help menus and config example comments to reference /whoami

generated by llmgit

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-19 21:52:10 +08:00
Shawn 815cbe79e3 fix(core): clear stale platform prompt when platform has no formatting (#207)
SetPlatformPrompt is only called when the platform implements
FormattingInstructionProvider. If a Slack message sets the prompt to
mrkdwn instructions and then a Telegram message arrives (which does
not implement the interface), the stale Slack prompt persists and
leaks into the Telegram session.

Always call SetPlatformPrompt — with the platform's instructions if
available, or with an empty string to clear any stale prompt.
2026-03-19 11:49:12 +08:00
Claude 265e93e43d fix(i18n): replace remaining hardcoded error messages with i18n
- Replaced 15 occurrences of fmt.Sprintf("❌ %v", err) with e.i18n.Tf(MsgError, err)
- Replaced 3 occurrences of fmt.Sprintf("❌ %s", ...) with e.i18n.Tf(MsgError, ...)
- Added MsgFailedToDeleteSession with multi-language support
- Remaining uncounted: cron job errors (lines 750/752) have special formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 07:46:57 +08:00
Claude 28abf6c709 fix(i18n): add translations for failed to start agent session
- Added MsgFailedToStartAgentSession with EN/ZH/ZH-TW/JA/ES translations
- Updated engine.go to use i18n key directly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 07:42:21 +08:00
cg33 ed300bcbdc Merge pull request #213 from 0xsegfaulted/fix/multi-workspace-bugs
fix(core): multi-workspace mode bug fixes
2026-03-18 22:42:25 +08:00