fix(dts): allow platform-agnostic (help) overrides so they shadow the fallback - #176
Merged
Conversation
…dow the fallback Saving an override of a platform-agnostic fallback (the per-command help templates, loaded from fallbacks/dts/help/*.json with platform="") produced a DUPLICATE in the editor's template list: the readonly fallback (help, fort, "") plus the user's copy (help, fort, "discord"). Root cause: POST /api/dts/templates rejected platform="" (400 "missing required fields"), forcing the editor to save help with a concrete platform. That platform-specific entry has a different entryKey than the agnostic fallback (entryKey includes platform), so the dedup — which drops a readonly fallback only when a user entry shares its (type, platform) surface — never dropped it. Both surfaced. Fix (server half of the coordinated fix): allow platform="" on save for platform-agnostic types via dts.IsPlatformAgnosticType (help today). A saved (help, fort, "") override then shares the fallback's key and cleanly shadows it — one entry, not two. Non-agnostic types (monster, raid, …) still require a concrete platform. Also tidy entryFilename so an empty platform yields "help-fort.json" rather than "help-fort-.json". The editor half (poracle-embed-visualizer) must stop coercing empty platform to "discord" (useDts.js: `e.platform || 'discord'`) for agnostic types so it sends platform="". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Companion to the server fix in this PR: the editor half (stop coercing empty platform to discord for help; show agnostic entries in every platform tab; save help with platform=""; surface readonly fallbacks in the list with a badge). Notes that help is the only agnostic type. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
Loading a fallback help template (e.g.
help/fort) in the editor and saving it to edit later produced a duplicate in the editable-templates list: the readonly fallback plus the user's saved copy.Root cause
The help fallbacks are platform-agnostic (
platform="", fromfallbacks/dts/help/*.json). ButPOST /api/dts/templatesrejectedplatform=""(huma_dts_writes.go:entry.Platform == ""→ 400), so the editor was forced to save help with a concrete platform (discord). The override key (entryKey=type|platform|language|id) then differs from the fallback's, and the list dedup drops a readonly fallback only when a user entry shares its(type, platform)surface — so(help, fort, "")and(help, fort, "discord")both survived.Fix (server half of the coordinated fix you chose)
platform=""on save for platform-agnostic types viadts.IsPlatformAgnosticType(justhelptoday; extensible). A saved(help, fort, "")override now shares the fallback's key and cleanly shadows it — one entry, not two. Non-agnostic types (monster/raid/…) still require a concrete platform (existingMissingFields400test preserved).entryFilenameso an empty platform yieldshelp-fort.json, nothelp-fort-.json.Editor half (separate — poracle-embed-visualizer)
src/hooks/useDts.jscoercesplatform: e.platform || 'discord'on load, which is what turns the agnostic""into"discord". For agnostic types it must preserve""so it POSTsplatform="". Once both land, saving a help template overwrites the fallback in place across repeated saves.Testing
TestSaveEntryAgnosticHelpOverrideShadowsFallback— after saving an agnostic override, the help/fort editor list shows exactly one (non-readonly) entry, written tohelp-fort.json.TestHumaDTSSaveTemplates_AgnosticHelpEmptyPlatformOK— help withplatform=""now returns 200;MissingFields400(monster without platform) still 400.TestEntryFilenameEmptyPlatform,TestIsPlatformAgnosticType.go build,go vet,go test -count=1 ./...,golangci-lint run(0 issues).Note for existing data
This prevents new duplicates. The stray
config/dts/help-fort-discord.jsonalready saved on the running instance should be deleted (editor delete or filesystem) to clear the current duplicate.🤖 Generated with Claude Code