Skip to content

feat(examples): browser page for native editing of one ConfigMap - #64

Merged
sunib merged 2 commits into
mainfrom
feat/native-editor-browser
Oct 5, 2026
Merged

sunib merged 2 commits into
mainfrom
feat/native-editor-browser

Conversation

@sunib

@sunib sunib commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • Adds examples/native-editor/index.html, a framework-free page. It watches one named ConfigMap through a host proxy (proxy, namespace, name are query parameters) and edits its data and ordinary annotations, using the existing nativeEditor, LiveResourceStore and connectNativeWatch.
  • It shows identity, connection state, server state, the draft and pending edits. The last-applied annotation is shown read-only; managedFields appear only in the read-only server-state summary.
  • Save is enabled only while the watch is live, there are no open conflicts and no request is in flight. Typing, focus and caret survive watch events, writes and recovery reads.
  • Each outcome gets its own message:
    • an accepted write waiting for its echo;
    • the echo arriving, or an explicit Confirm current state (editor.confirm()), each stating how many fields still differ;
    • a stale version that needs review and another Save;
    • field conflicts, resolved with store.revert or the keep-local recipe;
    • an unknown outcome (network failure or 5xx);
    • 401/403/422 refusals with the Kubernetes Status;
    • a deleted or replaced object, with copy-out from the recovery-copy recipe and an explicit "open the replacement".
  • Writes are never retried automatically.
  • Disconnect, or leaving the page, closes the watch, unsubscribes listeners, clears the echo timer and ignores late answers.

How it's built

  • editor.ts and the recipes stay TypeScript, run by the client suite. build.mjs (task build-native-editor) compiles them with the client's esbuild into a gitignored dist/, renaming their library import to @configbutler/krm-stream.
  • The page's import map points that name at index.js or the single-file bundle (?entry=bundle).
  • There is no second save controller, no new library API and no new dependency.
  • e2e-browser now depends on the new build task, and Playwright's web server rebuilds dist/ too.

Review fixes

  • Values are edited in text areas, since <input> silently dropped line breaks from multiline data and annotations.
  • The recovery-copy recipe's copy() and removed now capture first, so a host listener subscribed before the recipe (the page's render) shows a deleted object's edits at once. A disposed recipe stays empty.
  • Proposal 0009, the migration guide and the glossary now cover the native connector and native recovery reads. The glossary additions stay in docs(glossary): kubectl, apply, last-applied configuration, managed fields and SSA #63.

Validation

  • task fixtures-check, task lint-client, task test-client (218/218), task e2e-browser (48/48, 24 new) and task pack-client all pass. The new browser tests were also repeated 5×: 120/120.
  • The new native-editor.spec.ts runs the real page, connector, store and controller in Chromium on both entry points, against a test server that plays the host proxy and API server with a watch that stays open. It covers:
    • a conditional save and its echo;
    • typing during a save;
    • a 409, then a later deliberate Save;
    • explicit conflict resolution;
    • a lost response and a 502, each settled by a GET before any further PATCH;
    • an accepted write with no echo, then explicit confirmation;
    • 403 and 422 refusals;
    • multiline values;
    • a standalone deletion and a UID replacement, each with copy-out;
    • disconnect.
  • Manual run through kubectl proxy against a v1.36.4+k3s1 cluster: save and echo on both entry points, and a real 422 displayed.
  • task test-real-api was not rerun: the editor and the Go code are unchanged, and TestRealAPINativeEditThroughHostProxy is kept.

Limitations

  • One ConfigMap, data and annotations only. This is not a general resource editor.
  • Values are edited in text areas, which keep line breaks but normalize \r\n to \n: editing a value that contains carriage returns writes it back without them.
  • How long to wait for an echo is a page parameter (echoWaitMs, default 5 s).
  • "Confirmed" means the form now builds on the server's current state, not that every field was saved; remaining dirty fields are counted in the message.
  • kubectl proxy is for development only. It keeps the credential server-side and limits host names, but runs every request as your own identity and does no write validation, CSRF checks or audit. The README spells this out.
  • Native resume, pagination, gateway continuation, benchmarks and editor API cleanup remain separate work.

🤖 Generated with Claude Code

Add examples/native-editor/index.html: a framework-free page that watches one
named ConfigMap through a host proxy and edits its data and ordinary
annotations with the existing nativeEditor, LiveResourceStore and
connectNativeWatch. The last-applied annotation and managedFields stay
read-only. Save is enabled only while live, with one request at a time, and
inputs keep focus and caret through watch events, writes and recovery reads.
The page presents each outcome: an accepted write awaiting its echo, the echo
or an explicit confirm() with any remaining dirty fields, a stale version,
field conflicts resolved with store.revert or the keep-local recipe, an
unknown outcome, refusals and a deleted or replaced object with a recovery
copy. Disconnect closes the watch, unsubscribes, clears the echo timer and
ignores late answers.

editor.ts and the recipes stay TypeScript. build.mjs (task build-native-editor)
compiles them with the client's esbuild, renaming the library import to
@configbutler/krm-stream, which the page's import map points at the selected
entry point. dist/ is gitignored.

native-editor.spec.ts runs the page in Chromium on both entry points against
a test server that plays the host proxy and API server with a watch that
stays open. Document the run steps, the kubectl proxy setup and what it does
and does not protect, and record browser acceptance in the delivery plan and
field report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e25d57b6-ec58-4571-8cdb-1073572b6402
📥 Commits

Reviewing files that changed from the base of the PR and between ced7973 and 5898c99.

📒 Files selected for processing (19)
  • .gitignore
  • CONTRIBUTING.md
  • Taskfile.yml
  • docs/field-reports/third-our-identity.md
  • docs/glossary.md
  • docs/migrating.md
  • docs/proposals/0006-stream-and-save-implementation-plan.md
  • docs/proposals/0009-stream-and-editor-separation.md
  • examples/README.md
  • examples/editor-recipes/README.md
  • examples/editor-recipes/recoveryCopy.ts
  • examples/native-editor/README.md
  • examples/native-editor/build.mjs
  • examples/native-editor/index.html
  • examples/native-viewer/README.md
  • examples/vanilla-browser/README.md
  • examples/vanilla-browser/playwright.config.ts
  • examples/vanilla-browser/tests/native-editor.spec.ts
  • packages/krm-stream/test/recipes.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…s at once

Review fixes for the native editor page.

- Edit values in text areas. An <input> strips line breaks from its value,
  so editing a multiline data value or annotation and saving it wrote the
  value back without them.
- Make the recovery-copy recipe's reads independent of listener order.
  copy() and removed now capture first, so a host listener subscribed before
  the recipe, such as the page's render, sees a deletion immediately instead
  of "No unsaved edits." until a later render. A disposed recipe stays empty.
- Browser tests for multiline values and a standalone deletion, and a recipe
  test for the listener order; each fails without its fix.
- Docs: proposal 0009 and the migration guide name connectResourceStream the
  gateway connector, 0009 records that native editing has landed, and the
  glossary includes native recovery reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sunib
sunib merged commit 0834162 into main Oct 5, 2026
13 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
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