fix(keys-tree): keep Redis hash tags in a single tree node (#308) - #309
Open
claude[bot] wants to merge 1 commit into
Open
claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
The key tree split key names on the configured delimiter without any
awareness of hash tags, so a hash tag spanning several groups
(`{portal2:co}:something`) was torn apart into a `{portal2` folder with
`co}` children.
Delimiters that fall inside a hash tag are now skipped when a key name is
split into tree levels. The hash tag is resolved exactly like Redis does
in `keyHashSlot`: the first `{`, the first `}` after it, and only when
there is at least one character in between. Keys with no braces,
unbalanced braces or an empty `{}` keep the previous behaviour.
The split lives in a new `splitKeyName` helper and is duplicated inline
inside `constructKeysToTree`, which is stringified into a Web Worker Blob
and therefore cannot reference module scope.
Closes #308
claude
Bot
force-pushed
the
claude/issue-308-hash-tags-in-tree
branch
from
August 27, 2026 11:32
88bdb7b to
7f0ecf4
Compare
valkirilov
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested via Slack thread
What
Fixes #308.
Redis lets you pin related keys to the same cluster slot by wrapping part of the key name in curly braces — a "hash tag", for example
{portal2:co}:sessions:42.The keys tree builds its folders by splitting key names on the delimiter (
:by default), and it did that without noticing the braces. A hash tag containing a delimiter got cut in half:{portal2:co}and{portal2:tb}collapsed into one{portal2folder holdingco}andtb}. Neither half means anything on its own, and the two portals looked like one.Now a hash tag stays in one piece, so it becomes a single folder with its braces intact. Keys without a hash tag group exactly as before.
Technical solution
Key names are split by a new
splitKeyNamehelper that ignores delimiters falling inside a hash tag. It resolves the tag the same way Redis does when picking a slot: the first{, then the first}after it, and only when there is at least one character between them. Anything else — no braces, unbalanced braces, an empty{}— splits exactly as before.Two places split key names, and both use the helper now: the tree structure itself, and the leaf label in
VirtualTree. Fixing only the first would groupfoo:{a:b}under{a:b}while labelling itb}.The helper's logic is deliberately duplicated inline inside
constructKeysToTree, because that function is stringified into a Web Worker and cannot reference imports. An import there would throw inside the worker and silently leave the tree stale. Both copies carry a "keep in sync" comment, matching the pattern Redis Insight already uses forsplitWithPrefixThreshold.Open questions
a{b:c}:d:{e:f}still shows{e/f}. Treating every balanced pair as one piece would look tidier but is not what Redis means by a hash tag. Happy to switch.redisinsight/ui/src/helpers/constructKeysToTree.ts. Not touched here — worth a separate issue?KeysTree.tsx's auto-expand-to-selected-key builds parent names with a trailing delimiter that no folder name can match, and splits on the delimiter pattern as a plain string so it never splits at all when more than one delimiter is configured. Left alone. I can file it separately.Testing
How to verify by hand
{portal2:co}and{portal2:tb}as two separate folders, each with asessionsfolder inside.userandbroken{taggroup as usual.main: you get one{portal2folder containingco}andtb}._) and addSET {a:b_c}:d_e x. The tag{a:b_c}stays one folder whiledandesplit.Automated tests
28 new cases: a table-driven spec for
splitKeyName, plus tree-shape cases in the existingconstructKeysToTreespec that exercise the inlined copy — the one that actually runs in the worker. Covered: the reported keys, a tag with no delimiter inside, multiple brace pairs, an empty{}, both flavours of unbalanced brace, and a two-delimiter setup.Whole webviews suite:
188 passed | 3 skipped (191)files,1406 tests passed.yarn compileis clean and lint reports no new problems on the changed files.The before/after screenshots above are the extension's real tree components rendered in a browser against the unmocked Web Worker, so the folder structure shown is genuinely what the worker produces.