fix(audit): pass 1 — comment accuracy + drop dead null check

setPwd's header comment promised "tab-title fallback" — that's not
implemented in this PR. Reword to describe what the function actually
does today (store; consumers read via pwd()).

setPwd's body comment described a worktree integration as if it were
already wired. Drop it — the body is two lines, doesn't need a
forward-looking comment block.

COLOR_CHANGE handler: setColorScheme is a *process-global* style
hint; OSC 11 from any window flips chrome on every window. Note this
in the comment so a future reader doesn't misread the lambda's
window-scoped winp check as a per-window scheme.

PWD handler: drop the `p.pwd ?` defensive null check. libghostty's
Pwd struct (src/apprt/action.zig) ships a sentinel-terminated Zig
slice — its C ptr is always non-null; "cleared" is encoded as "".
The check was dead code.

Co-Authored-By: claude-flow <ruv@ruv.net>
pull/12846/head
ntomsic 2026-05-23 10:52:05 -05:00
parent e0a869e7fa
commit 3b771b4c3d
3 changed files with 12 additions and 9 deletions

View File

@ -468,10 +468,6 @@ void GhosttySurface::setRendererHealth(bool unhealthy) {
void GhosttySurface::setPwd(const QString &pwd) {
if (m_pwd == pwd) return;
m_pwd = pwd;
// Future work: when the worktree integration lands, this is the
// notification site that triggers the worktree-aware tab decoration.
// For now the value is held on the surface; setSurfaceTitle continues
// to drive the tab text on its own.
}
void GhosttySurface::toggleInspector(ghostty_action_inspector_e mode) {

View File

@ -135,9 +135,9 @@ public:
// Tracked working directory (from the PWD action). Updated whenever
// libghostty notifies the apprt that the surface's cwd has changed —
// either at spawn (from inherited config) or via shell integration /
// OSC 7. Used by MainWindow for the tab-title fallback when no
// terminal title has been set, and is the foundation for the
// worktree-aware tab decoration that lands on top of this branch.
// OSC 7. The value is currently stored only; future chrome
// (worktree-aware tab decoration, "new tab here", proxy icon) reads
// it via pwd().
void setPwd(const QString &pwd);
const QString &pwd() const { return m_pwd; }

View File

@ -2784,8 +2784,10 @@ bool MainWindow::onAction(ghostty_app_t, ghostty_target_s target,
// libghostty means "unknown / cleared" — pass it through so the
// surface can drop a stale value.
if (!src) return true;
const ghostty_action_pwd_s p = action.action.pwd;
const QString s = p.pwd ? QString::fromUtf8(p.pwd) : QString();
// libghostty's pwd is a sentinel-terminated Zig slice (see
// src/apprt/action.zig:Pwd) — its C ptr is always non-null;
// an "unknown / cleared" cwd is encoded as "".
const QString s = QString::fromUtf8(action.action.pwd.pwd);
post(src, [srcp, s]() {
if (srcp) srcp->setPwd(s);
});
@ -2803,6 +2805,11 @@ bool MainWindow::onAction(ghostty_app_t, ghostty_target_s target,
// can't go through refreshChrome; instead, derive the scheme
// straight from the action's RGB payload. macOS does the
// analogous thing in its color-change handler.
//
// Note: Qt's setColorScheme is a process-global style hint, so
// an OSC 11 from any window flips chrome on every window. This
// matches applyWindowConfig (also a global call) and is the
// documented Qt 6.8+ behaviour.
if (action.action.color_change.kind ==
GHOSTTY_ACTION_COLOR_KIND_BACKGROUND) {
const ghostty_action_color_change_s c = action.action.color_change;