2026-05-18-input-textarea-length.md 3.98 KB

Input and Textarea Length Count Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Add concise length display to Input and a new shared Textarea component, then expose both through the UI library, demo page, and OpenSpec change.

Architecture: Keep Input as the existing single-line control and add a lightweight showCount footer/affix presentation without changing its core value handling. Introduce Textarea as a sibling base input component with the same status and value contract, a bottom-right count display, and a focused CSS module so the shared UI boundary stays small and easy to reason about.

Tech Stack: React, TypeScript, CSS Modules, Vitest, React Testing Library, OpenSpec


Task 1: Lock the spec and plan scope

Files:

  • Modify: architecture-spec/openspec/changes/define-ui-component-library/proposal.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/design.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/specs/ui-component-library/spec.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/tasks.md

  • Step 1: Update the OpenSpec artifacts

Add a concise input-control requirement that covers Input and Textarea, with showCount using the compact 12/100 style, and mark the implementation/demo tasks that will deliver it.

  • Step 2: Validate the change

Run: openspec validate define-ui-component-library --strict Expected: PASS

Task 2: Add tests for length count behavior

Files:

  • Modify: workspace/agent-admin/web/packages/ui/src/components/basic-controls.test.tsx

  • Step 1: Write the failing tests

Add assertions that Input renders a concise count when showCount is enabled and maxLength is present, and that Textarea is exported and shows the same style of count.

  • Step 2: Run the targeted test file

Run: npm test -- packages/ui/src/components/basic-controls.test.tsx Expected: FAIL because Textarea is not exported yet and count rendering is not implemented.

  • Step 3: Keep the tests red until implementation lands

Do not change production code in this task.

Task 3: Implement Input count and new Textarea

Files:

  • Modify: workspace/agent-admin/web/packages/ui/src/components/Input.tsx
  • Create: workspace/agent-admin/web/packages/ui/src/components/Textarea.tsx
  • Create: workspace/agent-admin/web/packages/ui/src/components/Textarea.module.css
  • Modify: workspace/agent-admin/web/packages/ui/src/index.ts

  • Step 1: Implement the minimal component changes

Add showCount support to Input and build a new Textarea that matches the same value/status contract, keeps the count display concise, and uses the existing shared UI token system.

  • Step 2: Run the focused tests

Run: npm test -- packages/ui/src/components/basic-controls.test.tsx Expected: PASS

Task 4: Surface the new controls in the demo

Files:

  • Modify: workspace/agent-admin/web/src/routes/components/ComponentsDemoPage.tsx
  • Modify: workspace/agent-admin/web/src/routes/components/ComponentsDemoPage.test.tsx

  • Step 1: Add demo examples

Show one Input with concise count and one Textarea with concise count in the basic interaction section so the component library demo reflects the new API.

  • Step 2: Run the demo test

Run: npm test -- src/routes/components/ComponentsDemoPage.test.tsx Expected: PASS

Task 5: Verify the library end to end

Files:

  • None

  • Step 1: Run typecheck, unit tests, and build

Run: npm run typecheck && npm test && npm run build Expected: PASS

  • Step 2: Confirm the demo visually

Open the /components route in the browser and verify the new Input and Textarea count display looks compact, aligned, and consistent with the design system.