Skip to content

Commit a387a9e

Browse files
committed
Rename Document symbol and related message handlers to PastedText across the editor and UI components
1 parent ef87ecc commit a387a9e

23 files changed

Lines changed: 158 additions & 127 deletions

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Code Web Chat (CWC) is a free and open-source (FOSS), privacy-first **AI coding
3434

3535
<p align="center"><img src="https://github.com/robertpiosik/CodeWebChat/raw/HEAD/packages/shared/src/media/screenshot-3.png"></p>
3636

37+
> [!TIP]
38+
> CWC includes many useful API tools. _Edit Context_ lets you do the above without leaving the editor.
39+
3740
## Enabling autofill
3841

3942
Got tired with copy and paste? Enable prompt autofill with a browser extension.

‎apps/editor/src/views/panel/backend/message-handlers/handle-code-at-cursor.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import { replace_saved_context_symbol } from '@/views/panel/backend/utils/replace-saved-context-symbol'
2525
import { replace_skill_symbol } from '../utils/replace-skill-symbol'
2626
import { replace_image_symbol } from '../utils/replace-image-symbol'
27-
import { replace_document_symbol } from '../utils/replace-document-symbol'
27+
import { replace_pasted_text_symbol } from '../utils/replace-pasted-text-symbol'
2828
import { replace_website_symbol } from '../utils/replace-website-symbol'
2929
import { replace_fragment_symbol } from '../utils/replace-fragment-symbol'
3030

@@ -392,8 +392,8 @@ export const handle_code_at_cursor = async (
392392
})
393393
}
394394

395-
if (processed_completion_instructions.includes('#Document(')) {
396-
processed_completion_instructions = await replace_document_symbol({
395+
if (processed_completion_instructions.includes('#PastedText(')) {
396+
processed_completion_instructions = await replace_pasted_text_symbol({
397397
instruction: processed_completion_instructions
398398
})
399399
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { replace_saved_context_symbol } from '@/views/panel/backend/utils/replace-saved-context-symbol'
1111
import { replace_skill_symbol } from '@/views/panel/backend/utils/replace-skill-symbol'
1212
import { replace_image_symbol } from '@/views/panel/backend/utils/replace-image-symbol'
13-
import { replace_document_symbol } from '../utils/replace-document-symbol'
13+
import { replace_pasted_text_symbol } from '../utils/replace-pasted-text-symbol'
1414
import { replace_website_symbol } from '../utils/replace-website-symbol'
1515
import { replace_fragment_symbol } from '../utils/replace-fragment-symbol'
1616
import {
@@ -148,8 +148,8 @@ export const handle_copy_prompt = async (params: {
148148
})
149149
}
150150

151-
if (processed_completion_instructions.includes('#Document(')) {
152-
processed_completion_instructions = await replace_document_symbol({
151+
if (processed_completion_instructions.includes('#PastedText(')) {
152+
processed_completion_instructions = await replace_pasted_text_symbol({
153153
instruction: processed_completion_instructions
154154
})
155155
}
@@ -238,8 +238,8 @@ export const handle_copy_prompt = async (params: {
238238
})
239239
}
240240

241-
if (processed_instructions.includes('#Document(')) {
242-
processed_instructions = await replace_document_symbol({
241+
if (processed_instructions.includes('#PastedText(')) {
242+
processed_instructions = await replace_pasted_text_symbol({
243243
instruction: processed_instructions
244244
})
245245
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-edit-context.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { replace_selection_symbol } from '@/views/panel/backend/utils/replace-se
2424
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2525
import { replace_skill_symbol } from '@/views/panel/backend/utils/replace-skill-symbol'
2626
import { replace_image_symbol } from '@/views/panel/backend/utils/replace-image-symbol'
27-
import { replace_document_symbol } from '../utils/replace-document-symbol'
27+
import { replace_pasted_text_symbol } from '../utils/replace-pasted-text-symbol'
2828
import { replace_website_symbol } from '../utils/replace-website-symbol'
2929
import { replace_fragment_symbol } from '../utils/replace-fragment-symbol'
3030
import { apply_reasoning_effort } from '@/utils/apply-reasoning-effort'
@@ -375,8 +375,8 @@ export const handle_edit_context = async (
375375
})
376376
}
377377

378-
if (processed_instructions.includes('#Document(')) {
379-
processed_instructions = await replace_document_symbol({
378+
if (processed_instructions.includes('#PastedText(')) {
379+
processed_instructions = await replace_pasted_text_symbol({
380380
instruction: processed_instructions
381381
})
382382
}

apps/editor/src/views/panel/backend/message-handlers/handle-open-prompt-document.ts renamed to apps/editor/src/views/panel/backend/message-handlers/handle-open-prompt-pasted-text.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import * as vscode from 'vscode'
22
import * as os from 'os'
33
import * as path from 'path'
44

5-
export const handle_open_prompt_document = async (message: {
5+
export const handle_open_prompt_pasted_text = async (message: {
66
hash: string
77
}) => {
88
try {
99
const hash = message.hash
10-
const filename = `cwc-document-${hash}.txt`
10+
const filename = `cwc-paste-${hash}.txt`
1111
const file_path = path.join(os.tmpdir(), filename)
1212

1313
const doc = await vscode.workspace.openTextDocument(file_path)
1414
await vscode.window.showTextDocument(doc)
1515
} catch (error) {
16-
vscode.window.showErrorMessage(`Failed to open document: ${error}`)
16+
vscode.window.showErrorMessage(`Failed to open pasted text: ${error}`)
1717
}
1818
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-preview-preset.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { Preset } from '@shared/types/preset'
1313
import { replace_skill_symbol } from '@/views/panel/backend/utils/replace-skill-symbol'
1414
import { replace_image_symbol } from '@/views/panel/backend/utils/replace-image-symbol'
15-
import { replace_document_symbol } from '../utils/replace-document-symbol'
15+
import { replace_pasted_text_symbol } from '../utils/replace-pasted-text-symbol'
1616
import { replace_fragment_symbol } from '../utils/replace-fragment-symbol'
1717
import { apply_preset_affixes_to_instruction } from '@/utils/apply-preset-affixes'
1818
import { dictionary } from '@shared/constants/dictionary'
@@ -118,8 +118,8 @@ export const handle_preview_preset = async (
118118
})
119119
}
120120

121-
if (processed_completion_instructions.includes('#Document(')) {
122-
processed_completion_instructions = await replace_document_symbol({
121+
if (processed_completion_instructions.includes('#PastedText(')) {
122+
processed_completion_instructions = await replace_pasted_text_symbol({
123123
instruction: processed_completion_instructions
124124
})
125125
}
@@ -211,8 +211,8 @@ export const handle_preview_preset = async (
211211
})
212212
}
213213

214-
if (processed_instructions.includes('#Document(')) {
215-
processed_instructions = await replace_document_symbol({
214+
if (processed_instructions.includes('#PastedText(')) {
215+
processed_instructions = await replace_pasted_text_symbol({
216216
instruction: processed_instructions
217217
})
218218
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-prune-context.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { replace_selection_symbol } from '@/views/panel/backend/utils/replace-se
2020
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2121
import { replace_skill_symbol } from '@/views/panel/backend/utils/replace-skill-symbol'
2222
import { replace_image_symbol } from '@/views/panel/backend/utils/replace-image-symbol'
23-
import { replace_document_symbol } from '@/views/panel/backend/utils/replace-document-symbol'
23+
import { replace_pasted_text_symbol } from '@/views/panel/backend/utils/replace-pasted-text-symbol'
2424
import { replace_website_symbol } from '@/views/panel/backend/utils/replace-website-symbol'
2525
import { replace_fragment_symbol } from '@/views/panel/backend/utils/replace-fragment-symbol'
2626
import { apply_reasoning_effort } from '@/utils/apply-reasoning-effort'
@@ -354,8 +354,8 @@ export const handle_prune_context = async (
354354
})
355355
}
356356

357-
if (processed_instructions.includes('#Document(')) {
358-
processed_instructions = await replace_document_symbol({
357+
if (processed_instructions.includes('#PastedText(')) {
358+
processed_instructions = await replace_pasted_text_symbol({
359359
instruction: processed_instructions
360360
})
361361
}

apps/editor/src/views/panel/backend/message-handlers/handle-save-prompt-document.ts renamed to apps/editor/src/views/panel/backend/message-handlers/handle-save-prompt-pasted-text.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ import * as os from 'os'
33
import * as path from 'path'
44
import * as fs from 'fs'
55
import * as crypto from 'crypto'
6-
import { SavePromptDocumentMessage } from '../../types/messages'
6+
import { SavePromptPastedTextMessage } from '../../types/messages'
77
import { PanelProvider } from '../panel-provider'
88

9-
export const handle_save_prompt_document = async (
9+
export const handle_save_prompt_pasted_text = async (
1010
panel_provider: PanelProvider,
11-
message: SavePromptDocumentMessage
11+
message: SavePromptPastedTextMessage
1212
) => {
1313
try {
1414
const hash = crypto.createHash('md5').update(message.text).digest('hex')
15-
const filename = `cwc-document-${hash}.txt`
15+
const filename = `cwc-paste-${hash}.txt`
1616
const file_path = path.join(os.tmpdir(), filename)
1717
await fs.promises.writeFile(file_path, message.text, 'utf-8')
1818
const token_count = Math.ceil(message.text.length / 4)
1919
panel_provider.add_text_at_cursor_position(
20-
`#Document(${hash}:${token_count})`
20+
`#PastedText(${hash}:${token_count})`
2121
)
2222
} catch (error) {
23-
vscode.window.showErrorMessage(`Failed to save document: ${error}`)
23+
vscode.window.showErrorMessage(`Failed to save pasted text: ${error}`)
2424
}
2525
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-send-to-browser.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@/views/panel/backend/utils/replace-git-symbols'
1212
import { replace_skill_symbol } from '@/views/panel/backend/utils/replace-skill-symbol'
1313
import { replace_image_symbol } from '@/views/panel/backend/utils/replace-image-symbol'
14-
import { replace_document_symbol } from '../utils/replace-document-symbol'
14+
import { replace_pasted_text_symbol } from '../utils/replace-pasted-text-symbol'
1515
import { replace_fragment_symbol } from '../utils/replace-fragment-symbol'
1616
import {
1717
code_at_cursor_instructions_for_panel,
@@ -158,8 +158,8 @@ export const handle_send_to_browser = async (params: {
158158
})
159159
}
160160

161-
if (processed_completion_instructions.includes('#Document(')) {
162-
processed_completion_instructions = await replace_document_symbol({
161+
if (processed_completion_instructions.includes('#PastedText(')) {
162+
processed_completion_instructions = await replace_pasted_text_symbol({
163163
instruction: processed_completion_instructions
164164
})
165165
}
@@ -278,8 +278,8 @@ export const handle_send_to_browser = async (params: {
278278
})
279279
}
280280

281-
if (processed_instructions.includes('#Document(')) {
282-
processed_instructions = await replace_document_symbol({
281+
if (processed_instructions.includes('#PastedText(')) {
282+
processed_instructions = await replace_pasted_text_symbol({
283283
instruction: processed_instructions
284284
})
285285
}

‎apps/editor/src/views/panel/backend/message-handlers/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export * from './handle-open-file-and-select'
6363
export * from './handle-open-external-url'
6464
export * from './handle-save-prompt-image'
6565
export * from './handle-open-prompt-image'
66-
export * from './handle-save-prompt-document'
67-
export * from './handle-open-prompt-document'
66+
export * from './handle-save-prompt-pasted-text'
67+
export * from './handle-open-prompt-pasted-text'
6868
export * from './handle-paste-url'
6969
export * from './handle-voice-input'
7070
export * from './handle-open-website'

0 commit comments

Comments
 (0)