refactor(functions): consolidate 198 duplicate color declarations into one helper #131
No Reviewers
Labels
Clear labels
Area/CI
Area/Completions
Area/Components
Area/Config
Area/Docs
Area/Functions
Area/Integrations
Area/Prompt & Theme
Area/Scripts
Area/Tests
Compat/Breaking
Kind/Bug
Kind/Chore
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Performance
Kind/Refactor
Kind/Security
Kind/Testing
good first issue
help wanted
.github/workflows and repository automation
completions/ - tab-completion scripts
The opinionated-component system (C1-C6)
config.fish and conf.d/ - startup and environment
docs/manual/ and the generated manual, man page, and site
functions/ - user-facing functions and helpers
integrations/ - third-party tool wiring
themes/ and prompt appearance
scripts/ - standalone helper scripts
tests/ - the syntax lint and functional suite
Breaking change that won't be backward compatible
Something is not working
Tooling, dependencies, and housekeeping
Documentation changes
Improve existing functionality
New functionality
Makes existing behavior faster or lighter
Restructures code without changing behavior
This is security issue
Issue or pull request related to testing
Priority
Critical
1
The priority is critical
Priority
High
2
The priority is high
Priority
Low
4
The priority is low
Priority
Medium
3
The priority is medium
Reviewed
Confirmed
1
Issue has been confirmed
Reviewed
Duplicate
2
This issue or pull request already exists
Reviewed
Invalid
3
Invalid issue
Reviewed
Won't Fix
3
This issue won't be fixed
Status
Abandoned
3
Somebody has started to work on this but abandoned work
Status
Blocked
1
Something is blocking this issue or pull request
Status
Need More Info
2
Feedback is required to reproduce issue or to continue work
Well-scoped and self-contained; a good place to start
Maintainer is looking for someone to pick this up
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
rootiest (Rootiest)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: rootiest/fish-config#131
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
207
set -l c_*declarations across 39 files re-declared the same ~8 output roles, with names already drifted for the same color (c_reset/c_rst,c_cmd/c_bold,c_arg/c_primary). Replaced withfunctions/__fish_palette.fish(--no-scope-shadowing+ bareset, no globals, noeval), called once per function. Five drifted names retired across 67 sites.functions/fish_prompt.fish's hex Catppuccin palette is untouched — those are arguments toset_color, not captured escapes, and a different concern.The near-miss this PR's test harness caught
The first conversion attempt de-duplicated the palette call per indentation depth instead of per contiguous run. That silently stripped every escape from
logs --help(431 B → 150 B). It passedfish -n. It passedgrep -c '__fish_palette'(the call was still in the file, just not in the block that needed it). Only a byte-level diff against the original output caught it. That demonstration is preserved as a comment abovetest_functions_keep_their_paletteintests/functional.fish— the permanent check is runtime escape-presence, never a static grep, on purpose.Verification
main(25--helppaths + 4 error paths, stdout and stderr compared separately).config-settingsTUI files with no--helpwere driven under a real PTY on both trees with an identical keystroke feed: 9 redraws, 15068 bytes, byte-identical.functions/net −159 lines (excluding the new 63-line helper, which carries the full documented header this repo's conventions require).Scope limits
12 files have no reachable
--helpand no side-effect-free error path (the__config_settings_*helpers,upgrade,wake-lock, etc.) — covered structurally (proof no rendering line moved), not at runtime. No test cases were added that invokeupgradeorwake-lock— not worth the side effects during a test run.c_accentandc_okare both(set_color green)but kept as distinct roles — merging would change rendered output inlogs.fishandsmart_exit.fish. SeeAGENTS/JOB-BRIEF-FINDINGS.mdin this branch if you want that as a follow-up.Testing
fish tests/run-tests.fish— 227/227 lint, 17/17 functional, 317/317 vault.Compares rendered stdout and stderr of 29 colour-bearing cases between a pristine baseline ref and the working tree, in isolated XDG_CONFIG_HOMEs that carry the gitignored fish_variables so the opinionated guards resolve. Two traps this harness exists to avoid, both of which silently produce a meaningless comparison rather than an error: - `git archive main` omits fish_variables because it is untracked. Without it __fish_config_op_enabled is unresolvable and every guarded function short-circuits, so all cases render empty and trivially "match". - `qc --help` shells out to aichat and never reaches its colour path unless aichat is on PATH; the harness stubs it.27 duplicated declarations replaced by 5 calls. Output strings untouched. Four of these five files have no --help path, so the byte-identity harness cannot reach them. Covered instead by driving the real TUI under a pty on both the baseline and converted trees with an identical paced keystroke feed (down x3, Tab, Enter, Esc, Tab, down, q): 9 redraws, 15068 bytes, byte-identical on both sides c_sel (ESC[35;1m) x9, c_hi (ESC[37;1m) x8, c_head (ESC[36;1m) x9 all four draw helpers reached -- draw, pagetab, draw_subcat ("cascade default", "(category)"), draw_value ("Allow prev")