Skip to content

fix(web): show errors for failed actions and add daemon request/operation logging - #1711

Merged
wbxl2000 merged 3 commits into
mainfrom
fix/web-server-error-logging
Jul 14, 2026
Merged

fix(web): show errors for failed actions and add daemon request/operation logging#1711
wbxl2000 merged 3 commits into
mainfrom
fix/web-server-error-logging

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

In the web UI, many actions failed silently: clicking stop/archive, toggling plan/swarm/permission mode, OAuth login polling, and file preview could all fail with no visible feedback and no log anywhere. On the server side, several blind spots made these failures undiagnosable:

  • Routes that map errors to envelope codes themselves (prompts, sessions, fs, messages, files, sessionExport) never logged them — including the 50001 internal-error fallback.
  • The whole /api/v2 REST RPC surface and the v2 WS connection logged nothing on dispatch failure or timeout.
  • WS upgrade auth rejections (401/403) bypass Fastify hooks and produced no log at all.
  • Key operations (abort, cancel, approval decisions, archive, shutdown, config changes) left no trace in server.log.
  • Three void promise sites could crash the process with an unhandled rejection.

What changed

Web UI (apps/kimi-web):

  • pushOperationFailure (the shared error-toast path used by stop/archive/send/approve/etc.) now also writes console.error and an always-on operation:failed trace event that lands in the exported web log, with error code, request id, and HTTP status.
  • Silent failure sites fixed: mode/permission/thinking toggles now toast when the daemon rejects the profile update; file preview shows an error state instead of a fake empty file; OAuth login polling gives up with an explicit error page after repeated failures instead of spinning forever; workspace/session-load fallbacks and the dev-backend switch log warnings.

Server (packages/kap-server):

  • The 50001 fallback in the six self-mapping routes now logs at error level; POST /config and /api/v2 RPC dispatch failures are logged (error for internal/timeout, warn for business codes).
  • The v2 WS connection takes a logger and logs call/listen/send failures; WS upgrade 401/403 rejections are logged with remote address and reason.
  • The v1 session-event broadcaster's seven empty catches (which silently dropped events and skipped seqs) now warn, and the three unhandled-rejection sites log instead of crashing.
  • Info-level lines for key operations: prompt/session abort, task cancel, approval decisions (with decision and scope), archive/restore/compact/undo/fork, question answer/dismiss, terminal create/close, skill activate, workspace/file delete, OAuth login/logout, config changes (field names only, never values), and shutdown requests.
  • Rate-limit bans, gui.toml parse failures, download-stream errors, and open-in-app launch failures now warn.

Approach: logging only where the information was previously unrecoverable — the existing per-request access log already carries envelope codes, so new logs add session/operation context rather than duplicating it.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works. (Logging-only change; existing suites pass: kimi-web 492 tests + typecheck, kap-server 630 tests + typecheck.)
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (No new flags or config; docs already cover --log-level and server logs.)

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 99c2175

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@99c2175
npx https://pkg.pr.new/@moonshot-ai/kimi-code@99c2175

commit: 99c2175

@wbxl2000
wbxl2000 merged commit 9eff230 into main Jul 14, 2026
14 checks passed
@wbxl2000
wbxl2000 deleted the fix/web-server-error-logging branch July 14, 2026 11:17
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant