Skip to content

Commit edc1519

Browse files
committed
Implement completed tasks tracking in the prompt view with state persistence, UI integration, and prompt context injection
- PromptField has such promp: 'on_task_completed', once it's called we should update an array of 'completed tasks' that is saved and restored from workspace state by simply cutting current instructions and appending the 'completed tasks' array. - SaveCompletedTasksMessage should not have 'completed tasks' key, instead simply use current instructions in the provider - in prompt field, add a red 10x10 square to the left of instructions which call 'on task completed' upon click. Also render 'completed tasks' in gray boxes in .input-wrapper. - text should float around the red square like it floats around tabs - display completed tasks in reverse order - add empty array [Fragment] to stories - in place of 'red square' use checkbox that is always unchecked, simply used to call [Fragment] - on_task_completed should be only provided in 'edit' prompt type. you can only edit `apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx` - replace [Pasted text] with constnat 'is edit prompt type' - should not show the checkbox if on_task_completed is undefined - although 'completed_tasks' should remain not interactive, it should still nicely render symbols, just like the main instructions do - is it possible to not use [Pasted text]? - pointer events on completed tasks should be disabled - each completed task should have its own 'checked' checkbox - in completed task, text should float around the checkbox (set paddings the same as for the primary instructions - create handler files for [Fragment] - in the prompt field, make completed tasks expandible with the default state being collapsed. - rename 'completed items' to 'completed tasks'. make chevron point right, not down when collapsed. down, not left when not collapsed - completed tasks should not be striked through - the backend should clear current instructions as user set them as complete. Support 'undo'. - move [Fragment] to a specific hadler file, updating translation key - add missing [Fragment] modifier - after 'undoing' completed task, backspace in the prompt field doesn't work - no character is removed - above 'attaching X files' add status bar 'Attaching Y completed tasks' and 'Clear all' action. - add 'in-between' placement to status bar, use for [Fragment]. this mode removes all radiuses - rename 'attaching x completed tasks' to 'attaching x task instructions' - Footer and Tabs should have individual stylesheets - current behavior: tab can be cleared/closed by clicking on its dot. expected bahavior: tab's dot only activates it. for clear/closing there is a separate persistently shown close button at the end - extract completed task to `packages/ui/src/components/editor/common/prompts/PromptField/components` - move [Fragment] to namespace PromptField - all 'completed tasks' stuff should be in `packages/ui/src/components/editor/common/prompts/PromptField/components/CompletedTask/CompletedTask.tsx`, including header - unify components in `packages/ui/src/components/editor/common/prompts/PromptField/components/CompletedTask/CompletedTask.tsx`, file names should be 'CompletedTasks' - rename 'attaching x task instructions to 'including x task instructions', icon use 'checklist' - make 'X completed tasks' in the prompt field have 'clear all' button on the right side, identical to status bar we show below. Move translation to `apps/editor/src/views/prompt/frontend/i18n/translations/prompt-field.ts` and remove this status bar completely. - 'clear all' should use small button - instead of .completed-tasks__header use .header - allow 'undo' for the 'clear all' action - apply [Fragment] specificallt to the text 'X completed tasks' - sometimes we don't use proper BEM convention, eg. &-left { should be &__left { - rename 'clear all' to 'clear session', with keys and translations - In constructed prompts, above `# Task` should place `# Completed tasks` with all the completed tasks. Do it only in 'Edit' prompt type. - start lowercase [Fragment] ├── apps │ └── editor │ └── src │ ├── constants │ │ └── state-keys.ts │ ├── i18n │ │ └── translations │ │ └── views │ │ └── prompt │ │ └── handlers │ │ ├── handle-agentic-search.ts │ │ ├── handle-autofill.ts │ │ ├── handle-clear-completed-tasks.ts │ │ ├── handle-copy-prompt.ts │ │ ├── handle-delete-task.ts │ │ ├── handle-hash-sign-quick-pick.ts │ │ ├── handle-invoke-agentic-cli.ts │ │ ├── handle-make-api-call.ts │ │ ├── handle-patch-repair.ts │ │ ├── handle-save-completed-tasks.ts │ │ ├── handle-select-edit-format-instructions.ts │ │ ├── handle-template-quick-pick.ts │ │ ├── handle-undo.ts │ │ ├── handle-voice-input.ts │ │ ├── index.ts │ │ └── utils │ │ ├── index.ts │ │ └── symbols │ │ ├── git │ │ │ ├── index.ts │ │ │ └── replace-git-symbols.ts │ │ └── index.ts │ ├── utils │ │ └── prompt-builder.ts │ └── views │ ├── prompt │ │ ├── backend │ │ │ ├── message-handlers │ │ │ │ ├── handle-apply-response-from-history.ts │ │ │ │ ├── handle-autofill.ts │ │ │ │ ├── handle-clear-completed-tasks.ts │ │ │ │ ├── handle-copy-prompt.ts │ │ │ │ ├── handle-delete-task.ts │ │ │ │ ├── handle-get-completed-tasks.ts │ │ │ │ ├── handle-get-instructions.ts │ │ │ │ ├── handle-make-api-call.ts │ │ │ │ ├── handle-preview-prompt.ts │ │ │ │ ├── handle-preview-web-configuration.ts │ │ │ │ ├── handle-save-completed-tasks.ts │ │ │ │ ├── handle-save-history.ts │ │ │ │ ├── handle-save-instructions.ts │ │ │ │ ├── index.ts │ │ │ │ └── utils │ │ │ │ ├── build-cli-prompt.ts │ │ │ │ └── build-prompt-payload.ts │ │ │ ├── prompt-view-provider.ts │ │ │ └── utils │ │ │ └── symbols │ │ │ └── replace-symbols.ts │ │ ├── frontend │ │ │ ├── Main │ │ │ │ ├── Main.tsx │ │ │ │ └── MainView │ │ │ │ ├── MainView.tsx │ │ │ │ └── components │ │ │ │ └── BrowserConnectionStatus │ │ │ │ └── BrowserConnectionStatus.tsx │ │ │ ├── Prompt.tsx │ │ │ ├── hooks │ │ │ │ ├── use-prompt │ │ │ │ │ └── hooks │ │ │ │ │ └── use-instructions.ts │ │ │ │ └── use-response-history.ts │ │ │ └── i18n │ │ │ └── translations │ │ │ ├── main.ts │ │ │ └── prompt-field.ts │ │ └── types │ │ └── messages.ts │ └── settings │ └── backend │ └── message-handlers │ ├── handle-delete-provider.ts │ └── handle-delete-template.ts └── packages └── ui └── src ├── components │ └── editor │ ├── common │ │ ├── Button │ │ │ └── Button.tsx │ │ ├── Checkbox │ │ │ ├── Checkbox.module.scss │ │ │ └── Checkbox.tsx │ │ └── prompts │ │ ├── PromptField │ │ │ ├── PromptField.module.scss │ │ │ ├── PromptField.stories.tsx │ │ │ ├── PromptField.tsx │ │ │ ├── components │ │ │ │ ├── CompletedTasks │ │ │ │ │ ├── CompletedTasks.module.scss │ │ │ │ │ ├── CompletedTasks.tsx │ │ │ │ │ └── index.ts │ │ │ │ ├── Footer │ │ │ │ │ ├── Footer.module.scss │ │ │ │ │ ├── Footer.tsx │ │ │ │ │ └── index.ts │ │ │ │ └── Tabs │ │ │ │ ├── Tabs.module.scss │ │ │ │ ├── Tabs.tsx │ │ │ │ └── index.ts │ │ │ ├── hooks │ │ │ │ ├── use-drag-drop.ts │ │ │ │ ├── use-dropdown.ts │ │ │ │ ├── use-ghost-text.ts │ │ │ │ ├── use-handlers │ │ │ │ │ ├── handle-copy.ts │ │ │ │ │ ├── handle-cut.ts │ │ │ │ │ ├── handle-input-change.ts │ │ │ │ │ ├── handle-input-click.ts │ │ │ │ │ ├── handle-key-down.ts │ │ │ │ │ ├── handle-paste.ts │ │ │ │ │ ├── handle-submit.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── types.ts │ │ │ │ │ ├── use-handlers.ts │ │ │ │ │ └── utils.ts │ │ │ │ └── use-keyboard-shortcuts.ts │ │ │ └── index.ts │ │ ├── Template │ │ │ ├── Template.module.scss │ │ │ ├── Template.tsx │ │ │ └── index.ts │ │ └── shared │ │ └── symbols │ │ ├── caret.ts │ │ ├── get-highlighted-text.tsx │ │ ├── index.ts │ │ ├── position-mapping.ts │ │ ├── prompt-symbols.module.scss │ │ ├── reconstruct-raw-value.ts │ │ └── use-symbol-deletion.ts │ └── prompt-view │ └── StatusBar │ ├── StatusBar.module.scss │ ├── StatusBar.tsx │ └── index.ts └── styles └── foundation └── _colors.scss
1 parent dd00e27 commit edc1519

39 files changed

Lines changed: 1128 additions & 560 deletions

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const CHECKPOINTS_STATE_KEY = 'checkpoints'
2323
export const TEMPORARY_CHECKPOINT_STATE_KEY = 'temporary-checkpoint'
2424
export const CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY =
2525
'checkpoint-operation-in-progress'
26+
export const COMPLETED_TASKS_STATE_KEY = 'completed-tasks'
2627

2728
export const CHATS_VIEW_CHAT_HISTORY_STATE_KEY = 'chats-view-chat-history'
2829

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const translations = {
2+
'views.prompt.handlers.handle-clear-completed-tasks.cleared': {
3+
en: 'Completed tasks cleared.',
4+
pl: 'Zakończone zadania wyczyszczone.',
5+
'zh-cn': '已完成任务已清除。',
6+
ja: '完了したタスクをクリアしました。',
7+
'zh-tw': '已完成任務已清除。',
8+
de: 'Abgeschlossene Aufgaben gelöscht.',
9+
es: 'Tareas completadas borradas.',
10+
fr: 'Tâches terminées effacées.',
11+
'pt-br': 'Tarefas concluídas limpas.',
12+
ru: 'Завершенные задачи очищены.',
13+
ko: '완료된 작업이 지워졌습니다.',
14+
it: 'Attività completate cancellate.',
15+
tr: 'Tamamlanan görevler temizlendi.',
16+
cs: 'Dokončené úkoly vymazány.',
17+
hu: 'Befejezett feladatok törölve.',
18+
bg: 'Завършените задачи са изчистени.'
19+
}
20+
} as const
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const translations = {
2+
'views.prompt.handlers.handle-save-completed-tasks.task-completed': {
3+
en: 'Task completed.',
4+
pl: 'Zadanie zakończone.',
5+
'zh-cn': '任务已完成。',
6+
ja: 'タスクが完了しました。',
7+
'zh-tw': '任務已完成。',
8+
de: 'Aufgabe abgeschlossen.',
9+
es: 'Tarea completada.',
10+
fr: 'Tâche terminée.',
11+
'pt-br': 'Tarefa concluída.',
12+
ru: 'Задача завершена.',
13+
ko: '작업이 완료되었습니다.',
14+
it: 'Attività completata.',
15+
tr: 'Görev tamamlandı.',
16+
cs: 'Úkol dokončen.',
17+
hu: 'Feladat befejezve.',
18+
bg: 'Задачата е завършена.'
19+
}
20+
} as const

‎apps/editor/src/i18n/translations/views/prompt/handlers/index.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { translations as handle_patch_repair } from './handle-patch-repair'
1111
import { translations as handle_agentic_search } from './handle-agentic-search'
1212
import { translations as handle_autofill } from './handle-autofill'
1313
import { translations as handle_invoke_agentic_cli } from './handle-invoke-agentic-cli'
14+
import { translations as handle_save_completed_tasks } from './handle-save-completed-tasks'
15+
import { translations as handle_clear_completed_tasks } from './handle-clear-completed-tasks'
1416

1517
export const translations = {
1618
...handle_delete_task,
@@ -25,5 +27,7 @@ export const translations = {
2527
...handle_patch_repair,
2628
...handle_agentic_search,
2729
...handle_autofill,
28-
...handle_invoke_agentic_cli
30+
...handle_invoke_agentic_cli,
31+
...handle_save_completed_tasks,
32+
...handle_clear_completed_tasks
2933
}

‎apps/editor/src/utils/prompt-builder.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export namespace PromptBuilder {
6767
skill_definitions?: string
6868
output_formatting?: string
6969
requirements?: string[]
70+
completed_tasks?: string[]
7071
user_instructions?: string
7172
}): { part1: string; part2: string; full_prompt: string } => {
7273
let part1 = ''
@@ -125,6 +126,14 @@ export namespace PromptBuilder {
125126
full_prompt += `${sys}\n\n`
126127
}
127128

129+
if (params.completed_tasks && params.completed_tasks.length > 0) {
130+
const tasks_str = params.completed_tasks
131+
.map((t) => `- [x] ${t}`)
132+
.join('\n')
133+
part2 += `# Completed tasks\n\n${tasks_str}\n\n`
134+
full_prompt += `# Completed tasks\n\n${tasks_str}\n\n`
135+
}
136+
128137
if (part1.length > 0 || part2.length > 0 || full_prompt.length > 0) {
129138
part2 = part2.trimEnd() + '\n\n# Task\n\n'
130139
full_prompt = full_prompt.trimEnd() + '\n\n# Task\n\n'

‎apps/editor/src/views/prompt/backend/message-handlers/handle-autofill.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ export const handle_autofill = async (params: {
7979
}
8080

8181
let output_formatting: string | undefined = undefined
82+
let completed_tasks: string[] | undefined = undefined
8283
const user_instructions = processed_instructions
8384
if (params.prompt_view_provider.web_prompt_type == 'edit') {
85+
completed_tasks = params.prompt_view_provider.completed_tasks
8486
output_formatting = {
8587
whole: EDIT_FORMAT_INSTRUCTIONS_WHOLE,
8688
truncated: EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
@@ -94,6 +96,7 @@ export const handle_autofill = async (params: {
9496
files_context_part2: recent_files,
9597
skill_definitions,
9698
output_formatting,
99+
completed_tasks,
97100
user_instructions
98101
})
99102

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { PromptViewProvider } from '../prompt-view-provider'
2+
import { COMPLETED_TASKS_STATE_KEY } from '@/constants/state-keys'
3+
import * as vscode from 'vscode'
4+
import { t } from '@/i18n'
5+
6+
export const handle_clear_completed_tasks = async (
7+
prompt_view_provider: PromptViewProvider
8+
) => {
9+
const original_completed_tasks = [...prompt_view_provider.completed_tasks]
10+
11+
prompt_view_provider.completed_tasks = []
12+
await prompt_view_provider.extension_context.workspaceState.update(
13+
COMPLETED_TASKS_STATE_KEY,
14+
prompt_view_provider.completed_tasks
15+
)
16+
prompt_view_provider.send_message({
17+
command: 'COMPLETED_TASKS',
18+
completed_tasks: prompt_view_provider.completed_tasks
19+
})
20+
21+
const selection = await vscode.window.showInformationMessage(
22+
t('views.prompt.handlers.handle-clear-completed-tasks.cleared'),
23+
t('common.undo')
24+
)
25+
26+
if (selection === t('common.undo')) {
27+
prompt_view_provider.completed_tasks = original_completed_tasks
28+
await prompt_view_provider.extension_context.workspaceState.update(
29+
COMPLETED_TASKS_STATE_KEY,
30+
prompt_view_provider.completed_tasks
31+
)
32+
prompt_view_provider.send_message({
33+
command: 'COMPLETED_TASKS',
34+
completed_tasks: prompt_view_provider.completed_tasks
35+
})
36+
}
37+
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-copy-prompt.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ export const handle_copy_prompt = async (params: {
3232
}
3333

3434
let output_formatting: string | undefined = undefined
35+
let completed_tasks: string[] | undefined = undefined
3536
const user_instructions = processed_instructions
3637

3738
if (params.prompt_view_provider.prompt_type == 'edit') {
39+
completed_tasks = params.prompt_view_provider.completed_tasks
3840
const edit_format = params.prompt_view_provider.edit_format
3941
output_formatting = {
4042
whole: EDIT_FORMAT_INSTRUCTIONS_WHOLE,
@@ -49,6 +51,7 @@ export const handle_copy_prompt = async (params: {
4951
files_context_part2: recent_files,
5052
skill_definitions,
5153
output_formatting,
54+
completed_tasks,
5255
user_instructions
5356
})
5457
const text = build_result.full_prompt
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { PromptViewProvider } from '../prompt-view-provider'
2+
3+
export const handle_get_completed_tasks = (
4+
prompt_view_provider: PromptViewProvider
5+
) => {
6+
prompt_view_provider.send_message({
7+
command: 'COMPLETED_TASKS',
8+
completed_tasks: prompt_view_provider.completed_tasks
9+
})
10+
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-make-api-call.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ export const handle_make_api_call = async (
9292
let edit_format: EditFormat = 'whole'
9393
let system_instructions = ''
9494
let user_content = ''
95+
let completed_tasks: string[] | undefined = undefined
9596

9697
if (prompt_type == 'edit') {
9798
edit_format = prompt_view_provider.edit_format
99+
completed_tasks = prompt_view_provider.completed_tasks
98100
const output_formatting = {
99101
whole: EDIT_FORMAT_INSTRUCTIONS_WHOLE,
100102
truncated: EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
@@ -113,6 +115,7 @@ export const handle_make_api_call = async (
113115
files_context_part2: recent_files,
114116
skill_definitions,
115117
output_formatting,
118+
completed_tasks,
116119
user_instructions: processed_instructions
117120
})
118121
user_content = build_user_content({

0 commit comments

Comments
 (0)