Skip to content

Add writer schema request copy and response import tools#208

Merged
eviltester merged 2 commits into
masterfrom
writer-schema-follow-on
Jun 14, 2026
Merged

Add writer schema request copy and response import tools#208
eviltester merged 2 commits into
masterfrom
writer-schema-follow-on

Conversation

@eviltester

@eviltester eviltester commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • add copy actions for the full Writer request JSON and a chat-friendly prompt version
  • add a Process AI Response workflow so pasted JSON can be turned into schema rows without re-running the browser Writer API
  • add focused Jest coverage for the copy helpers and pasted-response schema creation flow

Validation

  • pnpm test -- --runTestsByPath apps/web/src/tests/jest/writer-schema-page.test.js
  • pnpm run verify:ui
  • pnpm run verify:local

Summary by CodeRabbit

  • New Features

    • Added ability to copy API request JSON and prompts to clipboard.
    • Added new "Process AI Response" section to paste responses and generate schemas.
    • Added support for streaming generation.
  • Tests

    • Updated test coverage for clipboard operations and streaming behavior.
  • Style

    • Improved UI layout and text formatting for inline actions.

Copilot AI review requested due to automatic review settings June 14, 2026 11:46
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@eviltester, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 48 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a6748399-caaa-45ed-b766-e269d09a05d7

📥 Commits

Reviewing files that changed from the base of the PR and between d81b212 and 1255002.

📒 Files selected for processing (4)
  • apps/web/src/tests/jest/writer-schema-page.test.js
  • apps/web/src/writer-schema-page.mjs
  • apps/web/styles.css
  • apps/web/writer-schema.html
📝 Walkthrough

Walkthrough

The Writer Schema page gains clipboard-copy actions for the latest API request JSON and prompt text, plus a new "Process AI Response" card allowing schema rows to be generated from pasted AI output without invoking the browser Writer API. The generation result handling is refactored into a shared applySchemaResult function, and tests are updated to cover streaming, clipboard calls, and the new response-processing flow.

Changes

Writer Schema clipboard copy and AI response processing

Layer / File(s) Summary
Clipboard helpers and navigatorObj parameter
apps/web/src/writer-schema-page.mjs
Imports renderIconHtml, adds createCopyApiRequestPrompt() and copyTextToClipboard() utilities, and extends bootstrapWriterSchemaPage to accept an optional navigatorObj override for the Clipboard API.
Centralized schema-application flow
apps/web/src/writer-schema-page.mjs
Adds latestRequestDetails tracking and introduces applySchemaResult() and parseSchemaFromAiResponse() to centralize JSON output, raw output, normalization text, schema-editor updates, and status reporting; generateFromPrompt delegates to applySchemaResult.
New controller actions, DOM wiring, HTML, and CSS
apps/web/src/writer-schema-page.mjs, apps/web/writer-schema.html, apps/web/styles.css
Wires processResponseElement and copy buttons into the DOM with injected icon HTML; adds copyLatestRequestJson, copyLatestRequestAsPrompt, and createSchemaFromResponse actions with event listeners; adds "Full Request" copy buttons and a "Process AI Response" card in HTML; adds .writer-schema-inline-actions layout and .writer-schema-action-icon rules in CSS.
Test suite updates and new tests
apps/web/src/tests/jest/writer-schema-page.test.js
Adds navigatorObj mock with clipboard.writeText, expands JSDOM fixture, updates all bootstrap calls, revises status-text assertions, adds a streaming generation test with async generator verification and writer.destroy assertion, adds clipboard NthCalledWith assertions, and adds an end-to-end createSchemaFromResponse test.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • eviltester/grid-table-editor#205: Introduced the initial Writer schema prototype with the same bootstrapWriterSchemaPage bootstrapping and generation logic that this PR directly extends with navigatorObj, copy actions, and the response-processing flow.

Poem

🐰 Hop, hop! A button to copy the prompt,
And paste AI JSON — no Writer API stunt!
The schema rows fill from a clipboard-flung text,
applySchemaResult keeps the code at its best.
This bunny approved it, then nibbled a carrot — what's next? 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding copy functionality for writer schema requests and a response import tool, which align with the PR objectives and file modifications.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch writer-schema-follow-on

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 and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Writer schema prototype page by adding clipboard copy helpers for the most recent Writer request (raw JSON and a chat-friendly “prompt” format) and by introducing a “Process AI Response” workflow to turn pasted JSON responses into schema rows without re-calling the browser Writer API.

Changes:

  • Added UI actions to copy the latest Writer request as formatted JSON or as a reusable prompt.
  • Added a “Process AI Response” textarea + handler to parse pasted AI output into schema rows.
  • Updated styling and expanded Jest coverage for streaming output, copy helpers, and pasted-response processing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
apps/web/writer-schema.html Adds copy buttons under “Full Request” and a new “Process AI Response” section.
apps/web/styles.css Styles inline action buttons and adds an icon sizing class; adjusts wrapping behavior for JSON output.
apps/web/src/writer-schema-page.mjs Implements clipboard copy helpers, request/prompt formatting, and pasted-response schema creation flow.
apps/web/src/tests/jest/writer-schema-page.test.js Adds focused Jest tests for streaming Writer chunks, copy helpers, and pasted-response processing.

Comment thread apps/web/src/writer-schema-page.mjs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d81b212de5

ℹ️ 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".

Comment thread apps/web/src/writer-schema-page.mjs
@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds clipboard copy actions for the Writer API request (raw JSON and a chat-prompt variant) and a new "Process AI Response" card that lets users paste any AI-generated JSON and create schema rows without re-invoking the browser Writer API. Streaming generation is also exercised through new test coverage.

  • writer-schema-page.mjs — three new page-controller functions (copyLatestRequestJson, copyLatestRequestAsPrompt, createSchemaFromResponse) backed by createCopyApiRequestPrompt, copyTextToClipboard, and decorateWriterCopyButton helpers; streaming support threaded through the onStatus callbacks.
  • writer-schema.html / styles.css — flag-copy buttons in the setup instructions, inline copy buttons in the Full Request card header, and a new "Process AI Response" section; new flex utility classes for layout and button decoration.
  • writer-schema-page.test.js — expanded JSDOM fixture, mock navigator/clipboard, and new tests for streaming accumulation, clipboard writes, and the pasted-response workflow.

Confidence Score: 5/5

Safe to merge — the new clipboard helpers and pasted-response workflow are self-contained, error paths are handled, and the test suite covers the happy path and streaming accumulation correctly.

All three new page-controller functions guard their entry conditions, propagate errors to the UI, and are exercised through the bootstrapped page API in tests. The only finding is cosmetic double-spacing on the flag copy buttons from redundant margin and gap values in CSS.

apps/web/styles.css — minor icon-spacing inconsistency between flag-copy-button and inline-actions contexts.

Important Files Changed

Filename Overview
apps/web/src/writer-schema-page.mjs Adds copyLatestRequestJson, copyLatestRequestAsPrompt, createSchemaFromResponse, and decorateWriterCopyButton helpers alongside streaming support; logic is clean and consistent with existing patterns
apps/web/src/tests/jest/writer-schema-page.test.js Adds navigatorObj fixture, flag-copy-button and process-response DOM elements to the test harness, and new test cases for streaming, clipboard copy, and pasted-response schema creation
apps/web/styles.css Adds flag-links, inline-actions, and action-icon rules; expands button selector list; writer-schema-action-icon uses margin-right that double-counts with gap in flag-copy-button flex containers
apps/web/writer-schema.html Adds clipboard copy buttons for each Chrome flags URL in setup instructions, inline copy buttons in the Full Request card header, and a new Process AI Response section with textarea and button

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([User]) -->|Click Generate| B[generateFromPrompt]
    B --> C[runWriterSchemaGeneration]
    C --> D{writeStreaming\navailable?}
    D -->|Yes| E[Accumulate stream chunks\nvia onStatus callbacks]
    D -->|No| F[writer.write]
    E --> G[parseWriterStructuredOutput]
    F --> G
    G --> H[normalizeStructuredSchemaPayload]
    H --> I[applySchemaResult\nsourceLabel: Writer API output]

    A -->|Click Copy JSON| J[copyLatestRequestJson]
    J --> K{latestRequestDetails\nset?}
    K -->|No| L[setStatus: warning]
    K -->|Yes| M[copyTextToClipboard\nJSON.stringify]

    A -->|Click Copy Prompt| N[copyLatestRequestAsPrompt]
    N --> O{latestRequestDetails\nset?}
    O -->|No| L
    O -->|Yes| P[createCopyApiRequestPrompt\ncopyTextToClipboard]

    A -->|Paste + Click Create Schema| Q[createSchemaFromResponse]
    Q --> R[parseSchemaFromAiResponse\nuses writerContextDomainCommands]
    R --> S[applySchemaResult\nsourceLabel: pasted AI response]

    I --> T[(latestRequestDetails\nupdated)]
    S -.->|requestDetails = latestRequestDetails\nno-op if null| T
Loading

Reviews (2): Last reviewed commit: "Add copy buttons for Chrome flag URLs" | Re-trigger Greptile

Comment thread apps/web/src/writer-schema-page.mjs
Comment thread apps/web/src/tests/jest/writer-schema-page.test.js
@eviltester eviltester merged commit ec7867a into master Jun 14, 2026
14 checks passed
@eviltester eviltester deleted the writer-schema-follow-on branch June 14, 2026 13:54
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