Skip to content

fix(dts): allow platform-agnostic (help) overrides so they shadow the fallback - #176

Merged
jfberry merged 2 commits into
developfrom
fix/dts-agnostic-platform-save
Jul 27, 2026
Merged

fix(dts): allow platform-agnostic (help) overrides so they shadow the fallback#176
jfberry merged 2 commits into
developfrom
fix/dts-agnostic-platform-save

Conversation

@jfberry

@jfberry jfberry commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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="", from fallbacks/dts/help/*.json). But POST /api/dts/templates rejected platform="" (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)

  • Allow platform="" on save for platform-agnostic types via dts.IsPlatformAgnosticType (just help today; 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 (existing MissingFields400 test preserved).
  • Tidy entryFilename so an empty platform yields help-fort.json, not help-fort-.json.

Editor half (separate — poracle-embed-visualizer)

src/hooks/useDts.js coerces platform: e.platform || 'discord' on load, which is what turns the agnostic "" into "discord". For agnostic types it must preserve "" so it POSTs platform="". 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 to help-fort.json.
  • TestHumaDTSSaveTemplates_AgnosticHelpEmptyPlatformOK — help with platform="" now returns 200; MissingFields400 (monster without platform) still 400.
  • TestEntryFilenameEmptyPlatform, TestIsPlatformAgnosticType.
  • Full gate green: 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.json already saved on the running instance should be deleted (editor delete or filesystem) to clear the current duplicate.

🤖 Generated with Claude Code

jfberry and others added 2 commits July 27, 2026 20:40
…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>
@jfberry
jfberry merged commit a8ed29f into develop Jul 27, 2026
5 checks passed
@jfberry
jfberry deleted the fix/dts-agnostic-platform-save branch July 27, 2026 21:36
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.

1 participant