Skip to content

fix(ui): preserve exact metadata integers on save - #971

Merged
runkids merged 7 commits into
runkids:mainfrom
salmonumbrella:fix/okf-exact-metadata-integers
Nov 21, 2026
Merged

runkids merged 7 commits into
runkids:mainfrom
salmonumbrella:fix/okf-exact-metadata-integers

Conversation

@salmonumbrella

@salmonumbrella salmonumbrella commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Editing any frontmatter field in the skill/agent editor re-serialized the header from JavaScript values, so bare integers above Number.MAX_SAFE_INTEGER (for example 9007199254740993 in metadata.x-acme-event-id or a sources entry's x-acme key) were silently rounded on save, even when the user changed only the description.

Dirty saves now restore the exact original integers for unchanged form values before serializing the header. This covers nested metadata, sources entries, values reached through aliases, and root target migration. wiki/frontend.md gets one new paragraph.

Limitation: the form, JSON view and YAML preview still show ordinary JavaScript values, so they may display large integers rounded. Editing such a field itself can save the rounded value. The Save confirmation diff shows the exact content that will be saved.

Not covered: YAML mapping keys that aren't strings. They fall outside the strict JSON manifest boundary and are out of scope here.

#969 also touches wiki/frontend.md, but this PR adds a separate paragraph. It has no code dependency on #969 and is not stacked on it.

Verification

  • 20 focused frontmatter tests pass in the Linux devcontainer (vitest run src/lib/frontmatter.test.ts), including the real SkillEditor save wiring and the body-only path.
  • Typecheck, lint and the router check (python3 scripts/ai-context.py check) pass.
  • Full make check not run; only the focused checks above. Hosted CI: eight checks passed; two jobs (docker-sandbox-online, redteam-signal) were skipped.

AI-assisted implementation and review. A human has not yet reviewed every line.

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section
  • I've reviewed every line of the diff and can explain it
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Linked Issue

Refs #894
Refs #637

Reuse original YAML scalar nodes for unchanged values so unrelated field
edits do not round large integer identifiers through JavaScript numbers.
Resolve unchanged scalar aliases against the original document before
copying their values so metadata edits retain their exact integers.
Decode original values with the YAML library's cached alias conversion and
reconcile exact integers before building the output document.
Keep distinct alias and save scenarios while testing supported field edits
and eliminating duplicate assertions and dependency-internal spying.
Cover the actual target migration and nested source save path while
ensuring parsed form values remain JSON-serializable numbers.
@salmonumbrella

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T12:48:43.684980Z 1e5d619 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 1e5d619843

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@salmonumbrella
salmonumbrella marked this pull request as ready for review November 20, 2026 12:44
@runkids

runkids commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @salmonumbrella. The exact-integer restore does what the description says: nested metadata, sources entries, aliases, the body-only path and the save diff all check out, and it merges cleanly with #969.

Could you change a few things before we merge?

  1. Move the rendered test. The SkillEditor render test (ui/src/lib/frontmatter.test.ts:251-309) sits in the pure-logic test file. wiki/frontend.md (Dashboard Tests) keeps logic tests in plain .ts modules and rendered tests in .test.tsx, so please move it to ui/src/components/skill-editor/SkillEditor.test.tsx. Keep it to the new wiring (the original header reaches composeSkillMarkdown); the nested-metadata, sources and targets cases are already covered by the lib tests.
  2. Don't re-parse on every render. next in SkillEditor.tsx:120 is recomputed on each render, so once the form is dirty every body keystroke parses the original header again with intAsBigInt. Please memoize it (useMemo on fm, body and the initial header) or compute the exact output only when saving and for the confirmation diff.
  3. Checklist: please tick "reviewed every line" and run make check (or say in the description which checks you ran).

Optional, not blocking: keeping the parsed original Document and applying only changed keys (as ui/src/lib/formatYaml.ts does) would remove the restore step and the "editing such a field can save the rounded value" caveat. Fine to leave for later.

@runkids
runkids merged commit b271e5f into runkids:main Nov 21, 2026
10 checks passed
runkids added a commit that referenced this pull request Nov 23, 2026
The dashboard gave no way to tell which release of a skill was
installed: the only "Version" it showed was the install commit. The
resources API now returns the frontmatter's metadata.version, and the
list, cards, tree details, Updates tab and detail page show it as a
tag. The detail page's commit row is relabelled "Commit" so the two
are not mistaken for each other.

Saving a skill in the editor wrote an untouched `version: 1.10` back
as `1.1`, which would change the version the dashboard shows.
Unchanged decimals now keep their written form on save, extending the
integer preservation from #971.

Closes #975
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