From 76349ad94b7a50003d4eeaca48d3de7971929a9e Mon Sep 17 00:00:00 2001 From: rootiest Date: Wed, 10 Jun 2026 21:54:56 -0400 Subject: [PATCH] fix(logging): register C5 event handlers in conf.d for reliable startup --on-variable handlers in functions/ are only autoloaded on explicit call, so they never fire when a universal variable changes. Moving the definitions to conf.d/logging-events.fish ensures they are registered at shell init. Also adds a startup __fish_config_sync_logging call so pre-set variable values (e.g. set before this shell was opened) take effect immediately without requiring a re-set. --- conf.d/logging-events.fish | 27 +++++++++++++++++++ functions/__fish_config_logging_changed.fish | 21 --------------- .../__fish_config_opinionated_changed.fish | 24 ----------------- 3 files changed, 27 insertions(+), 45 deletions(-) create mode 100644 conf.d/logging-events.fish delete mode 100644 functions/__fish_config_logging_changed.fish delete mode 100644 functions/__fish_config_opinionated_changed.fish diff --git a/conf.d/logging-events.fish b/conf.d/logging-events.fish new file mode 100644 index 0000000..892f518 --- /dev/null +++ b/conf.d/logging-events.fish @@ -0,0 +1,27 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# C5 — Logging & Capture: registers --on-variable event handlers at shell +# startup so that changes to __fish_config_op_logging or the master +# __fish_config_opinionated take effect immediately in every running shell. +# Also calls __fish_config_sync_logging once to reconcile sentinel-file and +# wrapper state with any variable values that were pre-set before this shell +# started. +# +# These functions must be defined in conf.d (not functions/) because fish +# only autoloads from functions/ on explicit call — event handlers that live +# solely in functions/ are never registered and their --on-variable triggers +# never fire. + +function __fish_config_logging_changed --on-variable __fish_config_op_logging \ + --description 'C5 event handler: sync logging state when __fish_config_op_logging changes' + __fish_config_sync_logging +end + +function __fish_config_opinionated_changed --on-variable __fish_config_opinionated \ + --description 'C5 event handler: sync logging state when master opinionated switch changes' + __fish_config_sync_logging +end + +# Sync once at startup so pre-set variable values take effect without a re-set +__fish_config_sync_logging diff --git a/functions/__fish_config_logging_changed.fish b/functions/__fish_config_logging_changed.fish deleted file mode 100644 index 4ac19fb..0000000 --- a/functions/__fish_config_logging_changed.fish +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2026 Rootiest -# SPDX-License-Identifier: AGPL-3.0-or-later - -# SYNOPSIS -# __fish_config_logging_changed -# -# DESCRIPTION -# Event handler that fires in every running shell when -# __fish_config_op_logging is set or erased. Delegates to -# __fish_config_sync_logging to update the Kitty sentinel file and -# paru/yay wrappers immediately without requiring a shell restart. -# -# RETURNS -# 0 Always -# -# EXAMPLE -# set -U __fish_config_op_logging 0 # triggers this automatically -function __fish_config_logging_changed --on-variable __fish_config_op_logging \ - --description 'C5 event handler: sync logging state when __fish_config_op_logging changes' - __fish_config_sync_logging -end diff --git a/functions/__fish_config_opinionated_changed.fish b/functions/__fish_config_opinionated_changed.fish deleted file mode 100644 index 40edac2..0000000 --- a/functions/__fish_config_opinionated_changed.fish +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2026 Rootiest -# SPDX-License-Identifier: AGPL-3.0-or-later - -# SYNOPSIS -# __fish_config_opinionated_changed -# -# DESCRIPTION -# Event handler that fires in every running shell when -# __fish_config_opinionated (the master opinionated switch) is set or -# erased. Delegates to __fish_config_sync_logging to keep C5 logging -# state in sync. Logging is the only category with external on-disk -# state (sentinel file, wrapper scripts) that requires real-time -# synchronisation when the master variable changes; C1-C4 guards -# evaluate at call-time and need no event handler. -# -# RETURNS -# 0 Always -# -# EXAMPLE -# set -U __fish_config_opinionated 0 # triggers this automatically -function __fish_config_opinionated_changed --on-variable __fish_config_opinionated \ - --description 'C5 event handler: sync logging state when master opinionated switch changes' - __fish_config_sync_logging -end