Skip to content

fix: use atomic write for tui.toml config to prevent corruption - #6

Closed
hobostay wants to merge 1 commit into
MoonshotAI:mainfrom
hobostay:fix/atomic-tui-config-write
Closed

fix: use atomic write for tui.toml config to prevent corruption#6
hobostay wants to merge 1 commit into
MoonshotAI:mainfrom
hobostay:fix/atomic-tui-config-write

Conversation

@hobostay

Copy link
Copy Markdown

Summary

  • saveTuiConfig was writing directly to the target file, risking corruption on crash/power loss
  • Now uses the same write-to-temp-then-rename pattern as writeJsonFile in persistence.ts
  • On crash, the temp file is left behind (harmless) rather than a truncated config file

Test plan

  • Verify config saves and loads correctly
  • Confirm temp file is cleaned up on error

🤖 Generated with Claude Code

saveTuiConfig was writing directly to the target file. If the process
crashed or lost power mid-write, tui.toml would be truncated and the
user's theme, editor, and notification preferences silently lost on
next startup. Now uses the same write-to-temp-then-rename pattern as
writeJsonFile in persistence.ts.

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

Copy link
Copy Markdown
Collaborator

Thank you for your interest in contributing to kimi-code.
However, we currently do not accept bulk AI-generated submissions that have not undergone thorough human review, so we will be closing these PR.

@liruifengv liruifengv closed this May 23, 2026
zha-ji-tui added a commit to zha-ji-tui/kimi-code that referenced this pull request Jun 1, 2026
- Gate the readdir fallback on `gitCache.isGitRepo()` instead of `snapshot === null`, so a transient `git ls-files` failure inside a real git repo does not expose `.gitignore`d files. The previous gate conflated "not a git repo" with "git ls-files failed transiently".

- Break out of the per-entry `walkDir` loop once `READDIR_MAX_ENTRIES` is reached, so a single large directory does not `statSync` every remaining file after the cap is filled. The cap was previously only checked on entry to `walkDir`.

- Handle the snapshot-null case after the `isGitRepo()` gate to avoid NPE when `getSnapshot()` returns null transiently inside a real git repo.

- Add a transient-failure test (isGitRepo=true, getSnapshot=null) and extend `stubGitCache` to decouple `isGitRepo` from snapshot presence.

Refs PR MoonshotAI#268 codex review (P2 MoonshotAI#5, MoonshotAI#6).
sailist added a commit that referenced this pull request Jun 5, 2026
…@ifoo (P2.5)

VSCode-style ctor migration for the seven in-process service implementations:

* SessionServiceImpl, MessageServiceImpl, ToolServiceImpl,
  McpServiceImpl, TaskServiceImpl: ctor goes from
  `(private readonly bridge: IHarnessBridge)` to
  `(@IHarnessBridge private readonly bridge: IHarnessBridge)`.

* PromptServiceImpl: ctor goes from
  `(private readonly bridge, private readonly eventBus)` to
  `(@IHarnessBridge ..., @IEventBus ...)` — same shape, services decorated.

* HarnessBridge: ctor reorders from
  `(eventBus, approvalBroker, questionBroker, options = {})` to
  `(options, @IEventBus eventBus, @IApprovalBroker approvalBroker,
   @IQuestionBroker questionBroker)` — VSCode-convention static-first.
  Inline `options = {}` default is dropped because TS forbids a required
  param after an optional one, and `options` now precedes the 3
  service params. Daemon start.ts already passes
  `opts.bridgeOptions ?? {}` explicitly, so the change is local.

  HarnessBridge singleton invariant is preserved: start.ts continues to
  `services.set(IHarnessBridge, built)` after construction, so every
  consumer's `a.get(IHarnessBridge)` resolves to the same instance from
  the ServiceCollection cache.

* packages/services/test/bridge.test.ts: 3 `new HarnessBridge(...)` call
  sites reordered to the new
  `(options, eventBus, approvalBroker, questionBroker)` shape.

* packages/daemon/src/start.ts: six `ix.createInstance(...Impl, a.get(IHarnessBridge), ...)`
  call sites collapse to single-arg `ix.createInstance(Impl)`;
  HarnessBridge construction collapses to
  `ix.createInstance(HarnessBridge, opts.bridgeOptions ?? {})`.

agent-core/src/di/ untouched (sealed for Phase 2). services test green
(120 pass); daemon test green (241 pass after one flake-rerun on
fs-watch.e2e.test.ts:302). services build is gated on test only per
phase-1 reviewer handoff #6 (pre-existing tsdown .yaml issue is
out-of-scope).

VERDICT: PASS — 7 impls decorated at session/message/tool/mcp/task-service-impl.ts:144/266/34/42/44 + prompt-service-impl.ts:156 + harness-bridge.ts:108; bridge.test.ts call-site swap; 241/241 daemon + 120/120 services tests green.
wintrover added a commit to wintrover/kimy that referenced this pull request Jun 29, 2026
…nshotAI#8

Replace manual file-set declarations with build engine introspection.

- tsdown native config: add manifestPlugin() that writes build-manifest.json
  via OutputChunk.moduleIds (850 bundled modules, zero test files)
- kimy wrapper: lockfile-based dependency hashing via pnpm-lock.yaml importers
- kimy wrapper: manifest-based native hashing (bundledModules only)
- kimy wrapper: double-checked locking inside flock (TOCTOU fix)
- kimy wrapper: atomic hash file writes via temp + mv
asdshuaishuai pushed a commit to d2rabbit/kimi-code that referenced this pull request Jul 21, 2026
)

Wires up the user's request to use codegraph
(https://github.com/colbymchenry/codegraph) as the project indexer and
auto-sync the index whenever a code task finishes.

Rust (commands.rs / lib.rs):

  · update_codegraph_index(cwd): spawns the codegraph CLI outside the
    webview (no ACL). Strategy:
      - if <cwd>/.codegraph/ exists → 'codegraph sync <cwd>' (incremental)
      - otherwise → 'codegraph init <cwd>' (first-time build)
      - if codegraph isn't on PATH → silent Ok (hook is opt-in; users
        without codegraph see no errors or toasts)
    Runs with --quiet and a 5-minute timeout so a stuck build can't
    hold the async runtime. Failures return Ok with the stderr text
    rather than Err (codegraph errors are often 'language unsupported'
    non-issues that would just annoy users).

  · resolve_codegraph_cli(): PATH-only lookup. No in-repo fallback
    because codegraph is an external tool installed separately via
    curl | bash (per upstream docs).

Frontend (client.svelte.ts):

  · maybeUpdateCodegraphIndex(sessionId): invoked from the
    sessionStatusChanged === 'idle' branch in connectEvents(). Reads
    the session's cwd, calls update_codegraph_index, surfaces an info
    toast on success ('codegraph 索引已更新'). Throttled to one
    in-flight call per session (overlapping syncs would just re-index
    the same changes). Silently no-ops in browser mode.

The hook fires on EVERY session-idle transition, which is exactly the
'task complete' moment the user asked for — by then the agent has
finished editing files and the graph can pick up the new state. The
result is that codegraph-aware features (symbol search, call graph,
etc.) stay current without a manual reindex step.

svelte-check 0 errors, cargo check 0 warnings.
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.

2 participants