Skip to content

[codex] add import trim options#180

Merged
eviltester merged 3 commits into
masterfrom
codex/import-trim-options
Jun 10, 2026
Merged

[codex] add import trim options#180
eviltester merged 3 commits into
masterfrom
codex/import-trim-options

Conversation

@eviltester

@eviltester eviltester commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • add import-time trim settings to amend/import flows across core, app UI, REST API, CLI, and MCP
  • add shared core and UI helpers so trim rules stay consistent across surfaces
  • add coverage for core parity, UI wiring, CLI, API, MCP, Storybook, and browser import behavior

Why

This adds a consistent way to trim imported input values globally or by exact header name during amend/import workflows, without expanding the generator UI surface.

Validation

  • pnpm run verify:ui
  • pnpm run verify:local

Summary by CodeRabbit

Release Notes

  • New Features

    • Added input-trimming controls for amend workflows across CLI, REST API, and MCP interfaces
    • Option to trim whitespace from all imported fields or selectively from specific fields
    • New import settings UI with trimming configuration
  • Documentation

    • Updated API, CLI, and MCP documentation with new trimming parameters and examples

@coderabbitai

coderabbitai Bot commented Jun 10, 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 20 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ 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: 5c89de6f-5524-4dd9-a0f9-7d598a53c58d

📥 Commits

Reviewing files that changed from the base of the PR and between 10ef39a and 57983c1.

📒 Files selected for processing (4)
  • packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js
  • packages/core-ui/src/tests/app/import-export-import-control.test.js
  • packages/core/js/grid/import-trim-settings.js
  • packages/core/src/tests/core-api/import-trim-settings.test.js
📝 Walkthrough

Walkthrough

This PR adds configurable input trimming controls to the amend workflows across the CLI, REST API, MCP, and web UI. The implementation flows from a new core trim utility module through the importer, into the amendFromTextSpecAndData function, and out through all three interfaces plus a comprehensive web UI with import settings controls.

Changes

Input Trimming Feature for Amend

Layer / File(s) Summary
Core trim utilities and importer integration
packages/core/js/grid/import-trim-settings.js, packages/core/js/grid/importer.js
New module provides normalizeImportTrimSettings and applyImportTrimSettingsToDataTable functions; Importer class adds importSettings state and setImportSettings() method that post-processes converted tables.
Core amendFromTextSpecAndData API
packages/core/src/index.js
Core amend function signature extended with trimInput and trimInputFieldsCsv parameters; wires them into importer before parsing; re-exports trim utility functions.
REST API and OpenAPI schema
apps/api/src/openapi.js, apps/api/src/api-service.js, apps/api/src/tests/generate/v1-generate-amend.spec.js, apps/api/src/tests/health/health-endpoints.spec.js
POST /v1/generate/amend endpoint schema adds trimInput and trimInputFieldsCsv; API service destructures request fields and forwards to core amend; endpoint and schema tests validate new parameters.
MCP tool schema and integration
apps/mcp/src/index.js, apps/mcp/src/mcp.test.js
amend_data_from_spec tool schema extended with trimInput and trimInputFieldsCsv input options; tool tests validate schema exposure and amend behavior.
CLI options and amend command
apps/cli/src/cli-options.js, apps/cli/src/run-cli.js, apps/cli/src/tests/cli-options.test.js, apps/cli/src/tests/integration.cli-params.test.js
amend command adds --trim-input and --trim-input-fields yargs options; CLI runner forwards parsed values to amendFromTextSpecAndData; tests validate option parsing and end-to-end trimmed output.
Web UI shared trim state management
packages/core-ui/js/gui_components/app/import-export-trim-state.js
New module exports createImportTrimState and applyImportTrimProps helpers for consistent trim state creation and prop updates across web components.
Web import control UI with trim settings
packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-controller.js, packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js
ImportExportImportControlView adds "Import settings" <details> panel with trim-input radios and CSV field textbox; controller integrates shared trim state; view emits onImportTrimSettingsChange callback with settings.
Web toolbar and workspace trim integration
packages/core-ui/js/gui_components/app/import-export-toolbar/..., packages/core-ui/js/gui_components/app/import-export-workspace/...
Toolbar and workspace controllers/views integrate shared trim state; wiring propagates onImportTrimSettingsChange from UI to workflow service.
Web file transfer and workflow trim application
packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-file-transfer-service.js, packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-workspace-workflow-service.js
File transfer service applies trim settings from state to importer before each import path; workflow service exposes updateImportTrimSettings to propagate UI changes into controller state.
Web test automation helpers
apps/web/src/tests/browser/app/abstractions/components/import-export-workspace.component.js
Test helper adds locators for import-settings controls and methods: setTrimInput, setTrimInputFieldsCsv, openImportSettings.
Core API and importer unit tests
packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js, packages/core-ui/src/tests/grid/importer.test.js
Core amend tests verify trimInput trims all fields and trimInputFieldsCsv trims listed columns; importer tests validate setImportSettings post-processing of CSV tables.
REST API and MCP endpoint tests
apps/api/src/tests/generate/v1-generate-amend.spec.js, apps/api/src/tests/health/health-endpoints.spec.js, apps/mcp/src/mcp.test.js
API tests validate OpenAPI schema includes trim parameters and endpoint returns trimmed output; MCP tests validate tool schema and cross-surface amend behavior.
CLI tests
apps/cli/src/tests/cli-options.test.js, apps/cli/src/tests/integration.cli-params.test.js
Option parsing tests verify --trim-input and --trim-input-fields handling; integration test runs amend command and validates trimmed CSV output in JSON result.
Web component and workspace tests
packages/core-ui/src/tests/app/import-export-import-control.test.js, packages/core-ui/src/tests/app/import-export-workspace.test.js
Import control test validates UI radio/textbox behavior and callback emission; workspace tests verify trim settings threaded through all import paths and importer configuration calls.
Cross-surface parity and E2E tests
tests/integration/cross-surface-amend-trim-parity.test.js, apps/web/src/tests/browser/app/functional/import-export/csv-file-upload-trim-input.spec.js
Integration test validates trim behavior consistency across core library, API service, CLI, and MCP; E2E functional test verifies CSV upload with trim field controls in browser.
Documentation and Storybook
README.md, docs-src/docs/..., docs/..., apps/web/src/stories/import-export-toolbar.stories.js
README, REST API, MCP, and CLI docs updated with trim parameter descriptions and examples; Storybook ImportTrimSettings story and helpers added; test migration plan updated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • eviltester/grid-table-editor#77: Both PRs modify the shared amend pipeline notably the amendFromTextSpecAndData implementation and the API/MCP/CLI amend call paths, but this PR extends that pipeline with new trim parameters and trimming behavior.
  • eviltester/grid-table-editor#80: Changes to apps/api/src/api-service.js runAmend forwarding new trim parameters into amendFromTextSpecAndData are directly related to the refactor that introduced the createApiService/runAmend plumbing.

Poem

🐰 A trim for the input so neat,
Whitespace shaved off, the data's sweet,
Through CLI, API, and MCP it flows,
Web UI gleams as the setting glows,
Across all surfaces, one trim truth shows!

🚥 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 PR title '[codex] add import trim options' clearly and concisely summarizes the main change—adding import trim options across the system. It is specific, related to the primary objective, and uses appropriate descriptive language.
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 codex/import-trim-options

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.

@eviltester eviltester marked this pull request as ready for review June 10, 2026 10:57
Copilot AI review requested due to automatic review settings June 10, 2026 10:57

@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: 10ef39ac1d

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

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 introduces import-time whitespace trimming controls for amend/import workflows and wires them through core logic, UI, CLI, REST API, and MCP so behavior remains consistent across surfaces.

Changes:

  • Added core import trim settings (trimInput, trimInputFieldsCsv) and applied them during import-to-GenericDataTable conversion.
  • Threaded trim settings through the app import/export UI (including a settings disclosure) and through CLI/API/MCP schemas + handlers.
  • Added parity and end-to-end tests (core, UI unit tests, CLI/API/MCP integration, and Playwright browser coverage) plus documentation updates.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integration/cross-surface-amend-trim-parity.test.js Cross-surface parity checks for core/API/MCP/CLI trim behavior
README.md Documented new CLI flags and REST API amend trim fields
packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js Added core tests for trimInput/trimInputFieldsCsv semantics
packages/core/src/index.js Plumbed trim options into amend flow; exported trim helpers
packages/core/js/grid/importer.js Added importer-level trim settings and applied them post-parse
packages/core/js/grid/import-trim-settings.js New shared normalization + trimming implementation
packages/core-ui/src/tests/grid/importer.test.js Verified importer trimming via core importer in UI test suite
packages/core-ui/src/tests/app/import-export-workspace.test.js Ensured workspace threads trim settings into importer
packages/core-ui/src/tests/app/import-export-import-control.test.js Verified import trim UI emits correct settings payload
packages/core-ui/js/gui_components/app/import-export-workspace/import-export-workspace-view.js Wired trim settings callback through workspace view
packages/core-ui/js/gui_components/app/import-export-workspace/import-export-workspace-controller.js Added trim state to workspace controller + update support
packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-workspace-workflow-service.js Added workflow handler for updating trim settings
packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-workspace-runtime.js Connected runtime callback to workflow trim updates
packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-file-transfer-service.js Applied current trim settings to importer before imports
packages/core-ui/js/gui_components/app/import-export-trim-state.js New shared helpers for trim state creation/application
packages/core-ui/js/gui_components/app/import-export-toolbar/import-export-toolbar-view.js Threaded trim settings callback through toolbar view
packages/core-ui/js/gui_components/app/import-export-toolbar/import-export-toolbar-controller.js Added trim state handling to toolbar controller
packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js Added import settings disclosure + trim controls UI
packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-controller.js Added trim state handling to import control controller
docs/frontend-component-migration-plan.md Noted Storybook coverage for new import trim disclosure
docs-src/docs/070-interfaces-and-deployment/050-cli-node-and-bun.md Documented CLI trim flags and usage
docs-src/docs/070-interfaces-and-deployment/040-mcp.md Documented MCP amend trim inputs + example payload update
docs-src/docs/070-interfaces-and-deployment/030-rest-api.md Documented REST amend trim inputs + example payload update
apps/web/src/tests/browser/app/functional/import-export/csv-file-upload-trim-input.spec.js Playwright test covering selected-field trimming on file upload
apps/web/src/tests/browser/app/abstractions/components/import-export-workspace.component.js Added test component helpers to drive trim UI
apps/web/src/stories/import-export-toolbar.stories.js Storybook story + controls documenting trim UI behavior
apps/mcp/src/mcp.test.js MCP schema + behavior tests for trim options
apps/mcp/src/index.js Exposed trim options in MCP tool input schema
apps/cli/src/tests/integration.cli-params.test.js CLI integration test verifying trim affects amend output
apps/cli/src/tests/cli-options.test.js CLI option parser test for new trim flags
apps/cli/src/run-cli.js Passed parsed trim options into core amend call
apps/cli/src/cli-options.js Added yargs options and mapping for trim flags
apps/api/src/tests/health/health-endpoints.spec.js Verified OpenAPI includes trim properties for amend endpoint
apps/api/src/tests/generate/v1-generate-amend.spec.js API test verifying trimInputFieldsCsv behavior
apps/api/src/openapi.js Documented trim inputs in OpenAPI request schema
apps/api/src/api-service.js Threaded trim inputs into amend execution payload

Comment thread packages/core/js/grid/import-trim-settings.js
Comment thread packages/core/js/grid/import-trim-settings.js
@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds import-time whitespace trimming across all surfaces — core API, REST API, CLI, MCP, and the browser UI — with a new import-trim-settings.js core helper and a shared import-export-trim-state.js UI helper keeping the logic consistent everywhere.

  • Core: normalizeImportTrimSettings and applyImportTrimSettingsToDataTable normalize and apply trim rules (global or per-field) directly to the freshly-parsed data table before it leaves the importer.
  • UI: A new <details> settings panel with radio groups and a CSV field list is added to the import control; per-instance nextInstanceId isolates radio button groups when multiple controls are mounted simultaneously.
  • CLI / API / MCP: Each surface adds trimInput and trimInputFieldsCsv parameters and threads them through to amendFromTextSpecAndData; a cross-surface parity integration test validates alignment.

Confidence Score: 5/5

Safe to merge — trim logic is additive, defaults to off on all surfaces, and is well-covered by unit, integration, and browser tests.

The change is purely additive: existing behaviour is unchanged when the new parameters are absent or default. Core trim logic is isolated in a single helper, normalization handles all edge cases (non-string input, duplicates, empty entries), and every surface (API, CLI, MCP, UI) is covered by dedicated tests plus a cross-surface parity suite. No data migration, schema change, or breaking API surface is involved.

No files require special attention.

Important Files Changed

Filename Overview
packages/core/js/grid/import-trim-settings.js New core helper for normalizing trim settings and applying them to imported data tables — handles deduplication, non-string guard, and short-row safety correctly.
packages/core/js/grid/importer.js Adds importSettings state and setImportSettings to the Importer class; wires trim application into toGenericDataTable cleanly.
packages/core-ui/js/gui_components/app/import-export-trim-state.js New shared UI helper that encapsulates createImportTrimState and applyImportTrimProps — eliminates duplication across toolbar, import-control, and workspace controllers.
packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js Adds the Settings disclosure panel with trim radio groups and CSV text input; uses per-instance nextInstanceId to isolate radio groups correctly across multiple mounts.
packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-file-transfer-service.js Applies current trim settings to the importer before each import path (file, clipboard, text) — covers all three entry points.
tests/integration/cross-surface-amend-trim-parity.test.js New cross-surface parity test verifies core, API, MCP, and CLI all produce identical trim behavior; uses temp files and process spawning correctly with appropriate timeouts.
apps/web/src/tests/browser/app/abstractions/components/import-export-workspace.component.js Adds import-settings page-object helpers; importSettingsSummary uses a tag-name locator instead of the preferred role/name query (see comment).
apps/mcp/src/index.js Adds trimInput and trimInputFieldsCsv to the amend schema; spread-into-normalizedArgs pattern correctly passes both fields through to amendFromTextSpecAndData.
apps/api/src/api-service.js Destructures and forwards trimInput and trimInputFieldsCsv from the request payload; parseBooleanFlag correctly normalises the boolean.
apps/cli/src/cli-options.js Adds --trim-input and --trim-input-fields options; correctly gates both to the amend command only.

Sequence Diagram

sequenceDiagram
    participant UI as ImportControl (View)
    participant WC as WorkspaceController
    participant FT as FileTransferService
    participant IMP as Importer
    participant TRIM as import-trim-settings

    UI->>WC: "onImportTrimSettingsChange({trimInput, trimInputFieldsEnabled, trimInputFieldsCsv})"
    WC->>WC: setImportTrimSettings → updateProps(createImportTrimState)
    Note over WC: state.trimInput / trimInputFieldsEnabled / trimInputFieldsCsv updated

    UI->>FT: uploadFile / importFromClipboard / importText
    FT->>FT: applyImportTrimSettings()
    FT->>IMP: "setImportSettings({trimInput, trimInputFieldsCsv})"
    IMP->>IMP: store importSettings

    FT->>IMP: toGenericDataTable(type, text)
    IMP->>TRIM: applyImportTrimSettingsToDataTable(dataTable, importSettings)
    TRIM->>TRIM: normalizeImportTrimSettings
    TRIM->>TRIM: mutate rows in-place
    TRIM-->>IMP: trimmed dataTable
    IMP-->>FT: trimmed dataTable
    FT->>WC: setGridFromGenericDataTable(trimmed data)
Loading

Reviews (3): Last reviewed commit: "harden import trim settings" | Re-trigger Greptile

Comment on lines 264 to +291
await expect(canvas.getByText('Generating export text...')).toBeVisible();
},
};

export const ImportTrimSettings = {
args: {
trimInput: true,
trimInputFieldsEnabled: true,
trimInputFieldsCsv: 'Name, Email',
},
render: renderImportExportToolbarStory,
parameters: {
docs: {
description: {
story:
'Documents the import-only trim settings behind the import settings disclosure. Toggle the radio groups and edit the CSV textbox to confirm the emitted settings payload shown in the story log.',
},
},
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByLabelText('Import settings'));
const textInput = canvas.getByRole('textbox', { name: /trim input fields csv/i });
await userEvent.clear(textInput);
await userEvent.type(textInput, 'Name, Role');
await expect(canvas.getByText(/"trimInputFieldsCsv":"Name, Role"/)).toBeVisible();
},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Story play action doesn't cover the documented radio-group modes

The ImportTrimSettings story description says "Toggle the radio groups and edit the CSV textbox to confirm the emitted settings payload", but the play function only exercises the CSV text input — the radio group interactions are left for reviewers to do manually. Per the AGENTS.md Storybook quality rules, when docs describe behavior modes, each mode should have its own primary story with a play interaction that clearly demonstrates it. As-is, the trim-all (trimInput: on) mode and the per-field (trimInputFieldsEnabled: selected-fields) mode are described in prose but never automated. A reviewer reading the story docs won't have a verified example for either radio path.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +72 to +80
const trimInputFieldsText = root.querySelector('[data-role="trim-input-fields-text"]');

expect(trimInputFieldsText.disabled).toBe(true);

trimInputOnRadio.click();
trimInputFieldsSelectedRadio.click();
trimInputFieldsText.value = 'Name, Role';
trimInputFieldsText.dispatchEvent(new dom.window.Event('input', { bubbles: true }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 data-role selectors used where role/name queries are available

AGENTS.md says "prefer role/name queries in DOM/component tests" and allows data-* hooks only when role/name queries are not practical. All three elements here are accessible by their ARIA roles and names: the radios have visible <span> text labels and the text input has aria-label="Trim input fields CSV". Using data-role selectors instead couples the test to the internal DOM contract rather than to user-visible semantics. The Storybook play action for the same component already uses getByRole('radio', { name: 'On' }) and getByRole('textbox', { name: /trim input fields csv/i }), so the role/name approach is already established in this PR.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js`:
- Line 69: Remove the inline attribute interpolation of state.trimInputFieldsCsv
from the input template (the input with data-role="trim-input-fields-text") to
avoid HTML attribute injection; instead rely on the existing property assignment
that sets the element's value later (the code that queries the input and sets
.value). Locate the template string that renders <input ...
value="${state.trimInputFieldsCsv || ''}"> and delete the value="..." portion so
the initial DOM is safe, keeping the subsequent logic that assigns the input's
value via JavaScript intact.

In `@packages/core/js/grid/importer.js`:
- Around line 57-63: setImportSettings is clobbering the existing trimInput flag
when callers pass partial settings (e.g., {trimInputFieldsCsv}) because
trimInput is set to settings.trimInput === true unconditionally; change it so
trimInput is only updated when the incoming settings include a trimInput
property (use settings.hasOwnProperty('trimInput') or check for undefined) and
otherwise preserve this.importSettings.trimInput (falling back to false if that
is undefined); update the assignment in setImportSettings to reference
this.importSettings.trimInput and keep trimInputFieldsCsv logic the same.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6004bf16-ac53-43ab-be4f-d56c5ad09ec0

📥 Commits

Reviewing files that changed from the base of the PR and between 099215a and 10ef39a.

📒 Files selected for processing (36)
  • README.md
  • apps/api/src/api-service.js
  • apps/api/src/openapi.js
  • apps/api/src/tests/generate/v1-generate-amend.spec.js
  • apps/api/src/tests/health/health-endpoints.spec.js
  • apps/cli/src/cli-options.js
  • apps/cli/src/run-cli.js
  • apps/cli/src/tests/cli-options.test.js
  • apps/cli/src/tests/integration.cli-params.test.js
  • apps/mcp/src/index.js
  • apps/mcp/src/mcp.test.js
  • apps/web/src/stories/import-export-toolbar.stories.js
  • apps/web/src/tests/browser/app/abstractions/components/import-export-workspace.component.js
  • apps/web/src/tests/browser/app/functional/import-export/csv-file-upload-trim-input.spec.js
  • docs-src/docs/070-interfaces-and-deployment/030-rest-api.md
  • docs-src/docs/070-interfaces-and-deployment/040-mcp.md
  • docs-src/docs/070-interfaces-and-deployment/050-cli-node-and-bun.md
  • docs/frontend-component-migration-plan.md
  • packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-controller.js
  • packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js
  • packages/core-ui/js/gui_components/app/import-export-toolbar/import-export-toolbar-controller.js
  • packages/core-ui/js/gui_components/app/import-export-toolbar/import-export-toolbar-view.js
  • packages/core-ui/js/gui_components/app/import-export-trim-state.js
  • packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-file-transfer-service.js
  • packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-workspace-runtime.js
  • packages/core-ui/js/gui_components/app/import-export-workspace/create-import-export-workspace-workflow-service.js
  • packages/core-ui/js/gui_components/app/import-export-workspace/import-export-workspace-controller.js
  • packages/core-ui/js/gui_components/app/import-export-workspace/import-export-workspace-view.js
  • packages/core-ui/src/tests/app/import-export-import-control.test.js
  • packages/core-ui/src/tests/app/import-export-workspace.test.js
  • packages/core-ui/src/tests/grid/importer.test.js
  • packages/core/js/grid/import-trim-settings.js
  • packages/core/js/grid/importer.js
  • packages/core/src/index.js
  • packages/core/src/tests/core-api/amendFromTextSpecAndData.test.js
  • tests/integration/cross-surface-amend-trim-parity.test.js

</label>
<label class="import-export-import-control__settings-text">
<span>Field names (CSV)</span>
<input type="text" data-role="trim-input-fields-text" value="${state.trimInputFieldsCsv || ''}" aria-label="Trim input fields CSV">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid HTML attribute injection in initial trim CSV rendering.

Line 69 injects trimInputFieldsCsv into an innerHTML attribute value. If the string contains quotes/markup, it can break attribute context and inject DOM/script on mount. Since Line 146 already sets the input value safely via property assignment, remove inline value interpolation in the template.

Suggested fix
-                <input type="text" data-role="trim-input-fields-text" value="${state.trimInputFieldsCsv || ''}" aria-label="Trim input fields CSV">
+                <input type="text" data-role="trim-input-fields-text" aria-label="Trim input fields CSV">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/core-ui/js/gui_components/app/import-export-import-control/import-export-import-control-view.js`
at line 69, Remove the inline attribute interpolation of
state.trimInputFieldsCsv from the input template (the input with
data-role="trim-input-fields-text") to avoid HTML attribute injection; instead
rely on the existing property assignment that sets the element's value later
(the code that queries the input and sets .value). Locate the template string
that renders <input ... value="${state.trimInputFieldsCsv || ''}"> and delete
the value="..." portion so the initial DOM is safe, keeping the subsequent logic
that assigns the input's value via JavaScript intact.

Comment on lines +57 to +63
setImportSettings(settings = {}) {
this.importSettings = {
...this.importSettings,
...settings,
trimInput: settings.trimInput === true,
trimInputFieldsCsv: settings.trimInputFieldsCsv ?? this.importSettings.trimInputFieldsCsv ?? '',
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Preserve previously enabled trimInput on partial settings updates.

setImportSettings({ trimInputFieldsCsv: ... }) currently forces trimInput back to false, so sequential partial updates can silently disable global trimming.

Suggested fix
   setImportSettings(settings = {}) {
+    const hasTrimInput = Object.prototype.hasOwnProperty.call(settings, 'trimInput');
     this.importSettings = {
       ...this.importSettings,
       ...settings,
-      trimInput: settings.trimInput === true,
+      trimInput: hasTrimInput ? settings.trimInput === true : this.importSettings.trimInput,
       trimInputFieldsCsv: settings.trimInputFieldsCsv ?? this.importSettings.trimInputFieldsCsv ?? '',
     };
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
setImportSettings(settings = {}) {
this.importSettings = {
...this.importSettings,
...settings,
trimInput: settings.trimInput === true,
trimInputFieldsCsv: settings.trimInputFieldsCsv ?? this.importSettings.trimInputFieldsCsv ?? '',
};
setImportSettings(settings = {}) {
const hasTrimInput = Object.prototype.hasOwnProperty.call(settings, 'trimInput');
this.importSettings = {
...this.importSettings,
...settings,
trimInput: hasTrimInput ? settings.trimInput === true : this.importSettings.trimInput,
trimInputFieldsCsv: settings.trimInputFieldsCsv ?? this.importSettings.trimInputFieldsCsv ?? '',
};
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/js/grid/importer.js` around lines 57 - 63, setImportSettings is
clobbering the existing trimInput flag when callers pass partial settings (e.g.,
{trimInputFieldsCsv}) because trimInput is set to settings.trimInput === true
unconditionally; change it so trimInput is only updated when the incoming
settings include a trimInput property (use settings.hasOwnProperty('trimInput')
or check for undefined) and otherwise preserve this.importSettings.trimInput
(falling back to false if that is undefined); update the assignment in
setImportSettings to reference this.importSettings.trimInput and keep
trimInputFieldsCsv logic the same.

@eviltester eviltester merged commit bde250a into master Jun 10, 2026
16 checks passed
@eviltester eviltester deleted the codex/import-trim-options branch June 10, 2026 12:06
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