Skip to content

AI-powered text input component with context-aware default generation #12096

@linear

Description

@linear

Summary

Create a reusable text input component/element that accepts context and generates intelligent default values using a cheap AI model.

Concept

A generic component that can be attached to any text input field. You pass it context, and it generates a sensible default value.

Use Cases

Use Case Context Passed Generated Default
Output names Connected blocks/inputs in graph Descriptive output name
Schedule names Schedule time/frequency "Daily morning run", "Weekly Monday sync"
Block names Graph context, block type Descriptive block label
Agent names Agent description/blocks Descriptive agent name

Behavior

  1. Component receives context (structured data relevant to the field)
  2. Calls cheap LLM (GPT-4o-mini) to generate appropriate text
  3. Shows as preview/default in the input field
  4. Auto-saves when parent form is submitted (e.g., graph run, schedule save)

Technical Approach

Backend

  • Generic endpoint: POST /api/generate-default-text
  • Request: { context_type: string, context: object }
  • Response: { generated_text: string }
  • Different prompt templates per context_type

Frontend Component

<AITextInput
  contextType="output_name"
  context={{ connectedBlocks: [...], inputSources: [...] }}
  value={name}
  onChange={setName}
  placeholder="Enter name or let AI suggest..."
/>

Implementation Notes

  • Debounce generation (dont call on every keystroke)
  • Cache results for same context
  • Show loading state while generating
  • Fallback gracefully if generation fails
  • Cost: ~$0.0001/generation (GPT-4o-mini)

Open Questions

  • How to integrate with existing input components? (wrapper vs new component)
  • Should it show "AI suggested" indicator?
  • Regenerate button, or one-shot?

Requested by

Nick Tindle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions