feat: support custom delimiters in the serve web workbench#7
Merged
Conversation
Swap the AI-generated placeholder banner.png for the polished yankrun-logo.png mascot, and add a recorded GIF of the serve workbench (scan -> fill -> preview -> apply) to the README so the UI is visible without running it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CLI users could already set --startDelim/--endDelim, but the web workbench only ever displayed the pair it started with - changing it meant restarting the server. Add an editable delimiter pair next to the directory path: typing a new pair and clicking Set validates it, updates the running server, and rescans immediately. Local, Clone, and Generate all read from the same server state, so the change applies everywhere without a restart. The change reuses the exact same workflow.Engine/services.Replacer functions the CLI already exercises - no new matching or replacement logic. New validation (ValidateDelimiters) closes a real bug found while building this: the literal scan in services/replacer.go finds delimiters with strings.Index, which returns 0 without consuming input for an empty needle, so an empty/empty pair would spin forever on any non-empty file. Empty, equal, and mutually-containing delimiter pairs are now rejected before they reach the scanner, and the previous pair stays active if a change is rejected. Also fixes a lock-discipline gap: settings() and handleIndex now read startDelim/endDelim under Server.mu, since they're mutable now instead of fixed at construction. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
StructLint — All checks passed85 rules validated against
|
It was only reachable by expanding the collapsed <details> for the serve command, so it was effectively invisible on first read. Move it right under the tagline where it's visible without clicking anything. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
doc/serve-demo.gif failed the naming-pattern check because .gif wasn't in the allowed extension list, alongside the existing .png/.jpg/.svg. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
serveweb workbench could only ever display the active[[]]delimiter pair (set at startup via--startDelim/--endDelim); changing it meant restarting the server. This adds an editable pair next to the directory path — type a new pair and click Set to validate, apply, and rescan instantly, no restart.Serverand read bysettings(), so it applies uniformly to Local, Clone, and Generate — the same single source of truth the CLI already uses.workflow.Engine/services.Replacerfunctions the CLI'stemplate,clone, andgeneratecommands already exercise (regexp.QuoteMeta-escaped regex for apply,strings.Indexliteral scan for preview — both already covered byservices/replacer_test.go).ValidateDelimiters, which closes a real bug found while building this: the literal scan (services/replacer.go) finds delimiters withstrings.Index, which returns0without consuming input for an empty needle — an empty/empty pair would spin forever on any non-empty file, hanging the request goroutine. Empty, equal, and mutually-containing delimiter pairs are now rejected up front (400 + clear message), and a rejected change leaves the previous pair active.settings()andhandleIndexnow readstartDelim/endDelimunderServer.mu, since they're mutable at runtime now instead of fixed at construction (verified race-free withgo test -race).README.md,docs/user/README.md,docs/AI/README.md,EXAMPLES.md,COMMANDS.md.Test plan
go build ./...,go vet ./...,gofmt -lclean on touched filesgo test ./... -race— full suite green, including the new tests, no data racesValidateDelimiters(table-driven): valid custom/default/unicode/regex-metachar/equal-length-non-overlapping pairs, plus empty/whitespace-only/equal/mutually-containing rejectionsTestSetDelimitersRejectsEmptyWithoutHanging) that guards the empty-pair hang bug with a 2s timeout, so it fails loudly instead of hanging CI if the validation is ever removed/api/applywrites the file using the new pair while an unrelated file using the old pair is untouched/api/delimiterscall returns 400 with a message and leaves server state (and subsequent scans) unchangedSetDelimiters/Scanfrom goroutines simultaneously (clean under-race)<%/%>live, watched the placeholder list update and old matches disappear, applied successfully, then confirmed the validation error path shows a clear message and leaves state untouchedBefore → after (live in browser)
[[ ]]scan<%%>NAMEonlyGREETINGonly, banner confirms rescan🤖 Generated with Claude Code