Skip to content

Add configurable workspace display substitutions - #15

Merged
qu8n merged 4 commits into
qu8n:mainfrom
engineersamuel:feature/workspace-name-substitutions
Sep 10, 2026
Merged

qu8n merged 4 commits into
qu8n:mainfrom
engineersamuel:feature/workspace-name-substitutions

Conversation

@engineersamuel

Copy link
Copy Markdown

Summary

  • add ordered WORKSPACE_SUBSTITUTE_SETS rules for directory-derived workspace labels
  • change only the displayed Herdr name, never the directory or Git worktree
  • preserve manual names that differ from Herdr's derived directory name
  • restore the original derived label when substitution rules are removed

Example

WORKSPACE_SUBSTITUTE_SETS=(
  's|^worktree-|wt-|'
)

This displays worktree-feature as wt-feature.

Validation

  • make syntax
  • make test
  • make lint

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d3a35c7-0a5f-4e6c-9a09-567c989e068d

@qu8n qu8n left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Great suggestion. I left two small comments.

Comment thread automatic-rename.sh Outdated
Comment thread automatic-rename.sh Outdated
qu8n added a commit that referenced this pull request Sep 10, 2026
WORKSPACE_SUBSTITUTE_SETS shortens the name herdr takes from the
directory without touching the directory or the worktree.

The rewrite is the sidebar's alone, so tabs go on deduping against the
derived name: deduping against the rewrite would have a tab re-inject
the long spelling the label was shortened to lose.

Numbering is no longer the only reason the workspace pass runs, since a
rewrite has to reach a workspace nobody numbered. That leaves the pass
needing a way to end: an owned workspace keeps it alive for one more
pass once the rules are deleted, which hands the derivation back and
drops the record, and herdr resumes labelling from there. `clear` takes
the same route, having otherwise stripped the number off a rewrite and
left that standing on the way to uninstall.

Refs #15
Co-authored-by: Samuel Mendenhall <smendenhall@workm5.local>
qu8n and others added 3 commits September 10, 2026 18:26
The branch was opened against 0.8.0 and main has moved to 0.10.0. The
engine it patched has been reworked since: per-session state took the
fourth ar_state_set argument this change also wanted, ar_fast_workspace
renames workspaces from the shell hook, and ar_renumber_workspaces reads
its rows with their status. Conflicts are resolved to main, and the
feature is rebuilt against it in the commits that follow.

# Conflicts:
#	CHANGELOG.md
#	README.md
#	automatic-rename.sh
#	tests/test_ws_cwd.sh
WORKSPACE_SUBSTITUTE_SETS shortens the name herdr takes from the
directory without touching the directory or the worktree.

The rewrite is the sidebar's alone, so tabs go on deduping against the
derived name: deduping against the rewrite would have a tab re-inject
the long spelling the label was shortened to lose.

Numbering is no longer the only reason the workspace pass runs, since a
rewrite has to reach a workspace nobody numbered. That leaves the pass
needing a way to end: an owned workspace keeps it alive for one more
pass once the rules are deleted, which hands the derivation back and
drops the record, and herdr resumes labelling from there. `clear` takes
the same route, having otherwise stripped the number off a rewrite and
left that standing on the way to uninstall.

Refs qu8n#15
Co-authored-by: Samuel Mendenhall <smendenhall@workm5.local>
A rewrite gave the workspace pass a second reason to run, and it went on
to do things the config never asked for.

The pass ran for a third reason too, that this plugin OWNS a workspace,
so it could take a rewrite back once the rules were deleted. That runs
for every config that has ever numbered one, and turning numbering off
then deleted every ownership record: a cd later, the workspace was opted
out of directory tracking for good, with no reset action to recover it.
The reason is gone. A rewrite is derived fresh from identity_cwd each
pass rather than built out of the last label, so deleting the rules
restores the derived names by itself wherever the pass still runs, and
where it does not the `clear` action is what puts them back.

What the pass does once it runs is now scoped the same way. Numbering
that was never named is not switched off but absent, so the pass carries
each row's own prefix over instead of stripping it, and a row it does
not own comes out unchanged. `clear` reads herdr's derivation only when
there is a rewrite to hand back, having otherwise renamed every
workspace to wherever identity_cwd pointed on the one pass with no
follow-up, and it reads the pane list beside it so a session.json that
lags a live cd cannot freeze the directory the workspace just left.

The prefix is taken back off the label rather than rebuilt from it.
ar_index_prefix is documented as ar_strip_prefix's exact inverse and is
not one: "[1]: [done] task" strips to itself while ar_index_prefix still
reads a "[1] " off it, and re-joining the two renamed a row the pass had
promised to leave alone. The shell hook answers all of this the way the
reconcile does, or the two undo each other every prompt.

Two more the rewrite could reach on its own. The debounce guard compares
the record against the pane's base rewritten, since the record holds a
label and a label carries the rules; compared raw it could never match a
workspace a rule touched, and the reconcile reverted every rename the
prompt made. And an empty rewrite is refused, because sed rejects a
malformed rule and hands back nothing, and a blank label would freeze
the derivation of the row it blanked.
@qu8n
qu8n merged commit 29703e3 into qu8n:main Sep 10, 2026
5 checks passed
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.

2 participants