:LovelaceTask
Submit tasks to the Lovelace agent worker pool with automatic context collection.
Command Signature
: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:
" 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:
:LovelaceTask
Context collected:
- File path: Absolute path to current file
- Content: Entire buffer content
- Working directory: Project root
- No selection range
With Description Argument
:LovelaceTask Add types to this function
Skips the input prompt and uses the provided description directly.
From 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)
" Navigate to code
/function calculateTotal
" Select function
V}
Step 2: Run Command
: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 Item | Visual Mode | Normal Mode |
|---|---|---|
| File path | Current file (absolute) | Current file (absolute) |
| Selection | Start/end line numbers | None |
| Content | Selected text only | Entire buffer |
| Working dir | Git root or cwd | Git root or cwd |
| File type | Detected from extension | Detected from extension |
Disable Context Collection
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
" Select old code pattern
V10j
:LovelaceTask
" Description: Refactor this callback-based code to use async/await with proper error handling
Type Addition
" Select JavaScript function
V}
:LovelaceTask
" Description: Add TypeScript type annotations: parameter types, return type, and interface for the data object
Bug Fixes
" 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
" 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:
-
Check authentication:
vim:LovelaceAuth -
Check daemon connection:
vim:LovelaceHealth -
View error details:
vim:messages
"Task stuck in queued"
Symptom: Task shows "queued" for more than 30 seconds
Solutions:
-
Check agent workers:
vim:LovelaceAgents -
If no idle workers: Wait for current tasks to complete
-
Check task queue:
vim:LovelaceTasks
"Context collection failed"
Symptom: Error about buffer content or selection
Solutions:
-
Verify file is saved:
vim:w -
Check file permissions:
bashls -la current-file.js -
Try without selection (normal mode):
vim:LovelaceTask
No Result Buffer Opens
Symptom: Task completes but no result window appears
Solutions:
-
Check UI configuration:
luarequire("lovelace").setup({ ui = { result_window = "split" -- Ensure valid option } }) -
Manually view task results:
vim:LovelaceTaskStatus task_abc123
Advanced Usage
Batch Task Submission
Submit multiple tasks for parallel processing:
" 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)
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
-- 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
| Command | Purpose |
|---|---|
| :LovelaceTasks | List all tasks |
| :LovelaceTaskStatus | Check specific task status |
| :LovelaceAgents | View agent worker pool |
| :LovelaceCancel | Cancel running task |
Next Steps
- :LovelaceTasks Command - List and monitor all tasks
- Task Submission Guide - Best practices and patterns
- Task Monitoring Guide - Track task progress
- Workflow Examples - Real-world task patterns
Related Documentation
- Task Submission Guide - Complete submission workflows
- Quick Start Tutorial - First task walkthrough
- Configuration Deep Dive - Task configuration options