Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

macOS: setStableProcessTitle() runs every 5 s → one LaunchServices check-in per session every 5 s (launchservicesd CPU)

未關閉 適合新手
#1,000 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
74/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, macos, node.js
領域
cli, performance

研究方向

閱讀 issue 中展示的 writeTitle() 和 setStableProcessTitle() 程式碼,接著追蹤 useTerminalTitle 在哪裡排程 reassertTerminalTitle()。在 macOS 上檢查最小 Node 重現,以確認重複指派會觸發 check-in。完成標準是:無須重複指派程序標題,仍可每 5 秒重新設定終端機標題,且重現中不再出現週期性的 check-in。

由索引模型根據 Issue 內容生成。

描述

Summary

Since the fix for #764 (v1.50.1), the process title is stable (command-code) — thanks.
But writeTitle() calls setStableProcessTitle() on every call, and
useTerminalTitle re-asserts the terminal title every 5 s:

function setStableProcessTitle(){process.title="command-code"}
function writeTitle(e){setStableProcessTitle(),process.stderr.isTTY&&process.stderr.write(SN(e))}
function reassertTerminalTitle(){null!==wN&&writeTitle(wN)}
// useTerminalTitle:
const e=setInterval(reassertTerminalTitle,5e3)

On macOS, every process.title assignment goes through libuv's darwin
proctitle code, which checks the process in with LaunchServices. lsd logs
pid N registering self and the check-in is rejected with -10811
(kLSNotAnApplicationErr), but launchservicesd still does the work (code
signature validation) each time. So every interactive session costs one
LaunchServices check-in every 5 s, forever, idle or not, even though the
value never changes.

Impact (measured)

macOS 26.6 (25G72), Apple Silicon (M5 Max, 18 cores), Node v24.21.0 arm64,
Command Code 1.79.1, ~20–30 interactive sessions open in a terminal multiplexer:

  • 12 check-ins / min per session, constant (10-min idle window: 119–120 per session).
  • 45-min audit: launchservicesd was the #1 CPU consumer of the machine:
    353 % average, 433 % p95
    (≈3.5 cores); 84 of 87 registering self
    events per probe window came from Command Code processes.
  • Controlled experiment with throw-away sessions (--no-session, no prompt sent):
    baseline 257 % → +4 sessions 316 % → +8 sessions 362 % launchservicesd CPU
    (≈12–15 % of a core per session, ≈0.7 s of launchservicesd CPU per check-in).
    Those throw-away sessions ran Node x86_64 under Rosetta; arm64 sessions show
    the same 12 / min cadence.

Minimal repro (no Command Code needed)

node -e 'setInterval(()=>{process.title="command-code"},5000)' & A=$!   # rewrite every 5 s
node -e 'process.title="command-code"; setInterval(()=>{},5000)' & B=$!  # write once
sleep 42
log show --last 40s --style compact \
  --predicate 'process == "lsd" AND eventMessage CONTAINS "registering self"' > lsd.txt
grep -c "pid $A registering self" lsd.txt   # → 8
grep -c "pid $B registering self" lsd.txt   # → 0
kill $A $B

With Command Code itself: start one session in a terminal, then
log stream --predicate 'process == "lsd" AND eventMessage CONTAINS "registering self"'
shows its pid every 5.000 s.

Suggested fix

Only write the process title when it changes, e.g.

function setStableProcessTitle(){ if (process.title !== "command-code") process.title = "command-code" }

or call it once at startup instead of inside writeTitle(). The OSC terminal
title write can stay on the 5 s interval — it does not touch LaunchServices.

Local workaround (until a release)

A user mod in ~/.commandcode/mods/ that performs the native write once and
then backs process.title with a plain JS property removes the check-ins
(same loop: 8 → 0 per 40 s; ps still shows command-code). It only takes
effect after a session's first message (mods load with the harness).

主要語言
沒有語言資料
星號
4.1k
分支
363
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

CommandCodeAI/command-code 的其他 Issue

查看 CommandCodeAI/command-code 的全部 Issue

相似的 Issue

更多 CLI Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。