Skip to main content

:LovelaceTask

Submit tasks to the Lovelace agent worker pool with automatic context collection.

Command Signature

vim
:LovelaceTask [description]

Alias: :LTask

Arguments:

  • description (optional) - Task description text. If omitted, prompts for input.

Description

The :LovelaceTask command is the primary method for submitting work to Lovelace agents. It automatically collects context from your current file and selection, then sends the task to an available agent worker for execution.

What it does:

  • Collects file path, selection range, and buffer content
  • Prompts for task description
  • Submits task to agent worker pool
  • Shows task ID and initial status
  • Auto-opens result buffer when complete

When to use:

  • Refactoring code
  • Adding types or documentation
  • Fixing bugs
  • Generating test cases
  • Any code-related task

Usage

From Visual Mode (Recommended)

Select code and submit task:

vim
" 1. Select code
V5j

" 2. Submit task
:LovelaceTask

" 3. Enter description when prompted
" Refactor this function to use async/await

Context collected:

  • File path: Absolute path to current file
  • Selection: Start and end line numbers
  • Content: Selected text
  • Working directory: Project root

From Normal Mode

Submit task for entire file:

vim
:LovelaceTask

Context collected:

  • File path: Absolute path to current file
  • Content: Entire buffer content
  • Working directory: Project root
  • No selection range

With Description Argument

vim
:LovelaceTask Add types to this function

Skips the input prompt and uses the provided description directly.

From Lua

lua
-- With prompt
require("lovelace.commands").task()

-- With description
require("lovelace.commands").task("Add error handling")

Task Submission Flow

Step 1: Select Code (Visual Mode)

vim
" Navigate to code
/function calculateTotal

" Select function
V}

Step 2: Run Command

vim
:LovelaceTask

Step 3: Enter Description

Prompt appears:

Task description:

Enter detailed description:

Refactor this function to use Array.reduce() instead of manual
accumulation. Add proper JSDoc comments and handle edge cases
for empty arrays.

Press <Enter> to submit.

Step 4: Confirmation

Task submitted (task_abc123def456) - Status: queued

Task ID is shown for tracking.

Step 5: Progress Notifications

Automatic notifications during execution:

[Task abc123] Started: Analyzing code...
[Task abc123] Progress: Generating refactored code...
[Task abc123] Progress: Running validation checks...
[Task abc123] Completed: 1 file changed

Step 6: Results Display

Result buffer opens automatically showing:

  • Suggested changes
  • File diffs
  • Explanations
  • Next steps

Context Collection

What Context is Collected

When you submit a task, the extension automatically includes:

Context ItemVisual ModeNormal Mode
File pathCurrent file (absolute)Current file (absolute)
SelectionStart/end line numbersNone
ContentSelected text onlyEntire buffer
Working dirGit root or cwdGit root or cwd
File typeDetected from extensionDetected from extension

Disable Context Collection

lua
require("lovelace").setup({
  tasks = {
    auto_collect_context = false
  }
})

Use when:

  • Asking general questions
  • Planning architecture (no code context needed)
  • Working with files not yet created

Writing Effective Task Descriptions

Be Specific

Bad: "Fix this"

Good: "Fix the null pointer error when user.data is undefined"

Bad: "Improve code"

Good: "Refactor to use TypeScript generics for type safety"

Include Technical Details

Good descriptions:

Convert this function to use the React hooks API instead of class components

Add comprehensive JSDoc comments explaining parameters, return values, and usage examples

Implement error handling with try-catch and proper error messages for API failures

Optimize this loop to use Array.reduce() instead of manual accumulation

Specify Desired Outcome

Include what you want and why:

Refactor this authentication flow to use JWT tokens instead of session cookies
(Why: Better for stateless API architecture)

Add TypeScript types to this component
(What: Interface for props, proper state typing, event handler types)

Task States

After submission, tasks progress through these states:

Queued

Task submitted (task_abc123) - Status: queued

Meaning: Waiting for an available agent worker

Duration: Typically 0-5 seconds

What to do: Wait for agent pickup, or check agent workers with :LovelaceAgents

Running

[Task abc123] Started: Analyzing code...

Meaning: Agent worker is executing the task

Duration: 10 seconds to 5 minutes depending on complexity

What to do: Continue editing, wait for completion

Completed

[Task abc123] Completed: 2 files changed

Meaning: Task finished successfully

What happens: Result buffer opens automatically

Action: Review results in result buffer

Failed

[Task abc123] Failed: Error analyzing code

Meaning: Task encountered an error

What to do: Check error message, adjust description, resubmit

Common Task Patterns

Code Refactoring

vim
" Select old code pattern
V10j

:LovelaceTask
" Description: Refactor this callback-based code to use async/await with proper error handling

Type Addition

vim
" Select JavaScript function
V}

:LovelaceTask
" Description: Add TypeScript type annotations: parameter types, return type, and interface for the data object

Bug Fixes

vim
" Select problematic code section
V5j

:LovelaceTask
" Description: Fix the race condition where setState is called after component unmounts. Add cleanup in useEffect and AbortController for fetch.

Documentation

vim
" Select undocumented function
V}

:LovelaceTask
" Description: Add comprehensive JSDoc comments: parameter descriptions with types, return value documentation, usage examples, edge cases and error scenarios

Troubleshooting

"Task submission failed"

Symptom: Error notification immediately after :LovelaceTask

Solutions:

  1. Check authentication:

    vim
    :LovelaceAuth
    
  2. Check daemon connection:

    vim
    :LovelaceHealth
    
  3. View error details:

    vim
    :messages
    

"Task stuck in queued"

Symptom: Task shows "queued" for more than 30 seconds

Solutions:

  1. Check agent workers:

    vim
    :LovelaceAgents
    
  2. If no idle workers: Wait for current tasks to complete

  3. Check task queue:

    vim
    :LovelaceTasks
    

"Context collection failed"

Symptom: Error about buffer content or selection

Solutions:

  1. Verify file is saved:

    vim
    :w
    
  2. Check file permissions:

    bash
    ls -la current-file.js
    
  3. Try without selection (normal mode):

    vim
    :LovelaceTask
    

No Result Buffer Opens

Symptom: Task completes but no result window appears

Solutions:

  1. Check UI configuration:

    lua
    require("lovelace").setup({
      ui = {
        result_window = "split"  -- Ensure valid option
      }
    })
    
  2. Manually view task results:

    vim
    :LovelaceTaskStatus task_abc123
    

Advanced Usage

Batch Task Submission

Submit multiple tasks for parallel processing:

vim
" File 1
:e component1.tsx
VG
:LovelaceTask
" Description: Add TypeScript types

" File 2
:e component2.tsx
VG
:LovelaceTask
" Description: Add TypeScript types

" Monitor all tasks
:LovelaceTasks

Programmatic Submission (Lua API)

lua
local lovelace = require("lovelace")
local connection = lovelace.get_connection()

connection:call("task.submit", {
  description = "Add error handling",
  context = {
    file_path = vim.fn.expand("%:p"),
    selection = {
      start = vim.fn.line("'<"),
      ["end"] = vim.fn.line("'>")
    },
    buffer_content = table.concat(
      vim.api.nvim_buf_get_lines(0, 0, -1, false),
      "\n"
    )
  }
}, function(result, error)
  if result then
    vim.notify("Task submitted: " .. result.task_id)
  end
end)

Custom Keybindings

lua
-- Quick task submission
vim.keymap.set("v", "<F5>", "<cmd>LovelaceTask<cr>", {
  desc = "Submit task with selection"
})

-- Task with preset description
vim.keymap.set("v", "<leader>lt", function()
  require("lovelace.commands").task("Add types to selection")
end, {
  desc = "Add types to selection"
})

Related Commands

CommandPurpose
:LovelaceTasksList all tasks
:LovelaceTaskStatusCheck specific task status
:LovelaceAgentsView agent worker pool
:LovelaceCancelCancel running task

Next Steps

Related Documentation