Skip to content

feat(vscode): add cross-platform keep-awake toggle - #12974

Merged
marius-kilocode merged 16 commits into
mainfrom
implement-caffeine-button
Sep 7, 2026
Merged

feat(vscode): add cross-platform keep-awake toggle#12974
marius-kilocode merged 16 commits into
mainfrom
implement-caffeine-button

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Agent sessions can be interrupted by idle system sleep. Add an optional Keep Awake control without changing the agent runtime.

Why This Change Was Made

The PR is limited to the extension: 46 files / 1,380 added lines, down from 75 files / 4,331 added lines (68% fewer additions). Twenty-one files contain only translation strings.

Backend activity tracking, CodeMode hooks, protocol/schema changes, and SDK changes have been removed. The feature uses existing session-status events and snapshots, with no new packages.

User Impact

  • Default off: each VS Code window starts with Keep Awake disabled, including after reload.
  • One-time notice: the first accepted notice is remembered per VS Code profile. It is not shown on every enable, and remembering it does not enable the feature automatically.
  • Enabled while idle: the toggle is armed, but no sleep inhibitor runs.
  • Busy or retrying work: one inhibitor runs while any tracked session in that window is busy or retry, including background agents and other worktrees using the shared backend.
  • All sessions idle/offline: the inhibitor stops, but the toggle stays armed and resumes inhibition for the next busy session.
  • Disable, disconnect, or close: the inhibitor is released. Turning Keep Awake off does not cancel agent sessions.
  • Failure: the control reports the error and supports explicit off/on retry, with awaited cleanup and directory-alias handling.

Scope limits: approval waits can still report busy, so they can keep the computer awake. This PR does not infer exact paused-agent activity or add an organization opt-out. Native control is limited to local VS Code windows.

Display sleep and screen locking remain enabled; no user input is simulated. macOS uses caffeinate -i, Windows requests system sleep prevention only, and Linux inhibits sleep, not idle. Linux can also block manual suspend until Keep Awake is disabled. A locked computer can still use files, network access, and available credentials, so device policy still applies.

Evidence

Bun 1.3.14: 4,870 extension unit tests pass (2 platform/existing skips), plus extension typechecks, lint, build, and Knip. The Storybook build also passes. No backend, CodeMode, schema, or SDK diff remains.

Isolated VS Code with a local fake model: verified default-off, remembered notice across reload, conservative busy/approval-wait behavior, and release after a task completes. Real macOS assertions were system-sleep-only and removed on cleanup. Native Windows/Linux verification remains a platform follow-up.

One-time Keep Awake notice explaining conservative busy-session behavior and normal screen locking

Multi-project toolbar: verified all five controls are inside the header and reachable at 200px, 260px, and 320px sidebar widths. Keyboard and Help open correctly at the minimum width. Added a 200px visual regression story; Linux CI generates its baseline.

All five multi-project toolbar controls visible at the 200px minimum sidebar width

Comment thread packages/kilo-vscode/src/services/caffeination/service.ts
Comment thread packages/kilo-vscode/src/services/caffeination/service.ts Outdated
Comment thread packages/kilo-vscode/docs/caffeination-plan.md Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (27 files)
  • .changeset/caffeination.md
  • packages/kilo-docs/public/img/screenshot-tests/kilo-vscode/visual-regression/agentmanager/multi-project-sidebar-200-chromium-linux.png
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectsSection.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/agent-manager.css
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/br.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/da.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/de.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/en.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/es.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/it.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/no.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/th.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/zht.ts
  • packages/kilo-vscode/webview-ui/src/stories/agent-manager.stories.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts
Previous Review Summary (commit 261b09a)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 261b09a)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (26 files)
  • .changeset/caffeination.md
  • packages/kilo-vscode/webview-ui/agent-manager/ProjectsSection.tsx
  • packages/kilo-vscode/webview-ui/agent-manager/agent-manager.css
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/br.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/da.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/de.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/en.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/es.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/it.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/no.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/th.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/agent-manager/i18n/zht.ts
  • packages/kilo-vscode/webview-ui/src/stories/agent-manager.stories.tsx
  • packages/kilo-vscode/webview-ui/src/types/messages/agent-manager.ts

Reviewed by grok-4.6 · Input: 131.6K · Output: 14.6K · Cached: 750.8K

Review guidance: REVIEW.md from base branch main

Comment thread packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts Outdated
Comment thread packages/kilo-vscode/tests/unit/caffeination.test.ts Outdated
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
# Conflicts:
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/ar.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/br.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/bs.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/da.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/de.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/en.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/es.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/fa.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/fr.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/it.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/ja.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/ko.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/nl.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/no.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/pl.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/ru.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/th.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/tr.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/uk.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/zh.ts
#	packages/kilo-vscode/webview-ui/agent-manager/i18n/zht.ts
@JeanLuX

JeanLuX commented Sep 2, 2026

Copy link
Copy Markdown

Hello,

I'm not sure if this topic is still active, but I created a similar feature for my own needs, which I've been using for a few weeks now. I hadn't seen this PR, and I'm not sure if it's a duplicate. If it is, I apologize, and please feel free to close the PR.

@marius-kilocode

Copy link
Copy Markdown
Collaborator Author

I think this is reasonable to ship as a default-off productivity feature, not as an exception to workstation-security policy.

The important distinction is keeping a computer awake versus keeping it unlocked. This implementation makes temporary OS sleep-prevention requests. It does not simulate keyboard/mouse input, request that the display stays on, disable screen locking, or change permanent power settings. Microsoft explicitly documents that the Windows API does not stop the screen saver or prevent user-requested sleep.

The safeguards here are concrete:

  • Nothing is enabled automatically. The user enables it, receives a one-time explanation, and can turn it off. Enablement resets after the window reloads.
  • The request follows existing busy/retry session status and is released when sessions become idle/offline, when disabled, on connection loss, or at shutdown. Helper cleanup and failure handling are explicit.
  • It grants no additional agent permissions. It extends the time during which already-authorized work can run, rather than changing what that work can access.
  • Busy approval waits can keep the request active. That limitation is documented rather than hidden behind an unreliable claim of exact activity detection.

This is an established product category, not something unique to Kilo. Copilot CLI defaults keep-alive to off, supports explicit session/busy/timed modes, and even documents staying awake while waiting for user input. Claude Desktop and Codex CLI also offer sleep prevention. The Linux primary request here also matches the systemd-inhibit --what=sleep --mode=block approach shown with KDE evidence in #13690. That supports the native mechanism, not a claim that both implementations have identical lifecycle testing.

We should still be clear about the boundary: a locked computer can continue using files, credentials, and the network. A company that requires mandatory suspend or prohibits unattended execution may disallow this. We do not provide a dedicated organization opt-out yet, and we must not bypass device restrictions. Linux can also block manual suspend until the request is released; native Windows/Linux verification remains a checklist item.

On that basis, I do not see a reason to block this scoped, opt-in feature merely because it prevents sleep. The defensible claim is that it supports intentional background work without deliberately suppressing locking, not that every corporate policy automatically permits it or that there is zero platform risk.

Comment thread packages/kilo-vscode/src/agent-manager/vscode-host.ts
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.

3 participants