Skip to content

Commit 7db0578

Browse files
committed
Refactor timeline display, remove clipboard path finder command, and fix README typo
1 parent ede830a commit 7db0578

12 files changed

Lines changed: 86 additions & 202 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Like all of CWC, the extension is [open-source](https://github.com/robertpiosik/
7373
> With the browser extension you can include markdown-parsed websites in context. Go to target website, click the extension's icon in the browser's toolbar and click _Enable for context_.
7474
7575
> [!IMPORTANT]
76-
> The _Apply response_ button placed under responses is not a means of automatic output extraction, it's an alias for the original _copy to clipboard_ button. Review the [content script](https://github.com/robertpiosik/CodeWebChat/blob/dev/packages/browser/src/content-scripts/send-prompt-content-script/send-prompt-content-script.ts) for implementation details.
76+
> The _Apply response_ button placed under responses is not a means of automatic output extraction, it's an alias for the original _copy to s_ button. Review the [content script](https://github.com/robertpiosik/CodeWebChat/blob/dev/packages/browser/src/content-scripts/send-prompt-content-script/send-prompt-content-script.ts) for implementation details.
7777
7878
> [!NOTE]
7979
> Use [port forwarding](https://code.visualstudio.com/docs/debugtest/port-forwarding) on port _55155_ when using remote machine via SSH.

‎packages/ui/src/components/editor/panel/Timeline/Timeline.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
font-size: 11px;
3232
color: var(--cwc-text-color-dimmed);
3333
white-space: nowrap;
34-
width: 18vw;
34+
width: 60px;
3535
text-align: right;
3636
overflow: hidden;
3737
text-overflow: ellipsis;

‎packages/ui/src/components/editor/panel/Timeline/Timeline.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import styles from './Timeline.module.scss'
22
import cn from 'classnames'
33
import dayjs from 'dayjs'
4-
import relativeTime from 'dayjs/plugin/relativeTime'
54
import localizedFormat from 'dayjs/plugin/localizedFormat'
6-
import { use_periodic_re_render } from '../../../../hooks/use-periodic-re-render'
75
import { IconButton } from '../IconButton/IconButton'
86

9-
dayjs.extend(relativeTime)
107
dayjs.extend(localizedFormat)
118

129
export type TimelineItemProps = {
@@ -33,9 +30,6 @@ export const Timeline: React.FC<Props> = ({
3330
on_delete,
3431
on_edit
3532
}) => {
36-
// Re-render every minute to update the relative time of the timeline items.
37-
use_periodic_re_render(60 * 1000)
38-
3933
return (
4034
<div className={styles.timeline}>
4135
{items.map((item) => (
@@ -48,7 +42,7 @@ export const Timeline: React.FC<Props> = ({
4842
className={styles.item__time}
4943
title={dayjs(item.timestamp).format('LLLL')}
5044
>
51-
{dayjs(item.timestamp).fromNow()}
45+
{dayjs(item.timestamp).format('h:mm A')}
5246
</div>
5347
<div className={styles.item__connector}>
5448
<div className={styles.item__marker}>

‎packages/vscode/package.json‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@
136136
"category": "Code Web Chat",
137137
"icon": "$(checklist)"
138138
},
139-
{
140-
"command": "codeWebChat.findPathsInClipboard",
141-
"title": "%codeWebChat.findPathsInClipboard.title%",
142-
"category": "Code Web Chat"
143-
},
144139
{
145140
"command": "codeWebChat.checkAll",
146141
"title": "Check All",

‎packages/vscode/package.nls.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"codeWebChat.applyContext.title": "Apply Context",
33
"codeWebChat.applyChatResponse.title": "Apply Chat Response",
44
"codeWebChat.copyContext.title": "Copy context",
5-
"codeWebChat.checkpoints.title": "Checkpoints",
6-
"codeWebChat.findPathsInClipboard.title": "Find Paths in Clipboard"
5+
"codeWebChat.checkpoints.title": "Checkpoints"
76
}

‎packages/vscode/package.nls.pl.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"codeWebChat.applyContext.title": "Wybierz zapisany kontekst",
33
"codeWebChat.applyChatResponse.title": "Zintegruj wiadomość czatbota",
44
"codeWebChat.copyContext.title": "Kopiuj kontekst",
5-
"codeWebChat.checkpoints.title": "Punkty kontrolne",
6-
"codeWebChat.findPathsInClipboard.title": "Znajdź ścieżki plików w schowku"
5+
"codeWebChat.checkpoints.title": "Punkty kontrolne"
76
}

‎packages/vscode/src/commands/apply-context-command/apply-context-command.ts‎

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,8 @@ export const apply_context_command = (
258258
show_other_menu = false
259259

260260
const other_quick_pick_options: (vscode.QuickPickItem & {
261-
value?:
262-
| 'clipboard'
263-
| 'unstaged'
264-
| 'commit_files'
265-
| 'keyword_search'
261+
value?: 'unstaged' | 'commit_files' | 'keyword_search'
266262
})[] = [
267-
{
268-
label: 'Scan the clipboard for valid paths',
269-
value: 'clipboard'
270-
},
271263
{
272264
label: 'Unstaged files',
273265
value: 'unstaged'
@@ -284,11 +276,7 @@ export const apply_context_command = (
284276

285277
const other_quick_pick = vscode.window.createQuickPick<
286278
vscode.QuickPickItem & {
287-
value?:
288-
| 'clipboard'
289-
| 'unstaged'
290-
| 'commit_files'
291-
| 'keyword_search'
279+
value?: 'unstaged' | 'commit_files' | 'keyword_search'
292280
}
293281
>()
294282
other_quick_pick.title = 'Context Sources'
@@ -308,11 +296,7 @@ export const apply_context_command = (
308296
const other_selection = await new Promise<
309297
| 'back'
310298
| (vscode.QuickPickItem & {
311-
value?:
312-
| 'clipboard'
313-
| 'unstaged'
314-
| 'commit_files'
315-
| 'keyword_search'
299+
value?: 'unstaged' | 'commit_files' | 'keyword_search'
316300
})
317301
| undefined
318302
>((resolve) => {
@@ -351,12 +335,6 @@ export const apply_context_command = (
351335

352336
last_other_selection_value = other_selection.value
353337

354-
if (other_selection.value == 'clipboard') {
355-
await vscode.commands.executeCommand(
356-
'codeWebChat.findPathsInClipboard'
357-
)
358-
return
359-
}
360338
if (other_selection.value == 'unstaged') {
361339
await handle_unstaged_files_source(workspace_provider)
362340
return
@@ -373,9 +351,11 @@ export const apply_context_command = (
373351
return
374352
}
375353
if (other_selection.value == 'keyword_search') {
376-
const result =
377-
await handle_keyword_search_source(workspace_provider)
378-
if (result === 'back') {
354+
const result = await handle_keyword_search_source(
355+
workspace_provider,
356+
extension_context
357+
)
358+
if (result == 'back') {
379359
show_other_menu = true
380360
continue
381361
}

‎packages/vscode/src/commands/apply-context-command/sources/keyword-search-source.ts‎

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import * as fs from 'fs'
44
import { WorkspaceProvider } from '../../../context/providers/workspace/workspace-provider'
55
import { dictionary } from '@shared/constants/dictionary'
66
import { Logger } from '@shared/utils/logger'
7+
import { LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY } from '../../../constants/state-keys'
78

89
export const handle_keyword_search_source = async (
9-
workspace_provider: WorkspaceProvider
10+
workspace_provider: WorkspaceProvider,
11+
extension_context: vscode.ExtensionContext
1012
): Promise<'back' | void> => {
1113
try {
1214
const input_box = vscode.window.createInputBox()
@@ -221,15 +223,83 @@ export const handle_keyword_search_source = async (
221223
}
222224

223225
const selected_paths = selected_items.map((item) => item.file_path)
226+
const currently_checked = workspace_provider.get_checked_files()
227+
let paths_to_apply = selected_paths
228+
229+
if (currently_checked.length > 0) {
230+
const selected_paths_set = new Set(selected_paths)
231+
const all_current_files_in_new_context = currently_checked.every((file) =>
232+
selected_paths_set.has(file)
233+
)
234+
235+
if (!all_current_files_in_new_context) {
236+
const quick_pick_options = [
237+
{
238+
label: 'Replace',
239+
description: 'Replace the current context with selected files'
240+
},
241+
{
242+
label: 'Merge',
243+
description: 'Merge selected files with the current context'
244+
}
245+
]
246+
247+
const last_choice_label = extension_context.workspaceState.get<string>(
248+
LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY
249+
)
250+
251+
const quick_pick = vscode.window.createQuickPick()
252+
quick_pick.items = quick_pick_options
253+
quick_pick.placeholder = `How would you like to apply the ${selected_paths.length} selected files?`
254+
255+
if (last_choice_label) {
256+
const active_item = quick_pick_options.find(
257+
(opt) => opt.label === last_choice_label
258+
)
259+
if (active_item) {
260+
quick_pick.activeItems = [active_item]
261+
}
262+
}
263+
264+
const choice = await new Promise<vscode.QuickPickItem | undefined>(
265+
(resolve) => {
266+
let is_accepted = false
267+
quick_pick.onDidAccept(() => {
268+
is_accepted = true
269+
resolve(quick_pick.selectedItems[0])
270+
quick_pick.hide()
271+
})
272+
quick_pick.onDidHide(() => {
273+
if (!is_accepted) resolve(undefined)
274+
quick_pick.dispose()
275+
})
276+
quick_pick.show()
277+
}
278+
)
279+
280+
if (!choice) return
281+
282+
await extension_context.workspaceState.update(
283+
LAST_CONTEXT_MERGE_REPLACE_OPTION_STATE_KEY,
284+
choice.label
285+
)
286+
287+
if (choice.label == 'Merge') {
288+
paths_to_apply = [
289+
...new Set([...currently_checked, ...selected_paths])
290+
]
291+
}
292+
}
293+
}
224294

225295
Logger.info({
226296
message: `Selected ${selected_paths.length} files from keyword search.`,
227297
data: { paths: selected_paths }
228298
})
229299

230-
await workspace_provider.set_checked_files(selected_paths)
300+
await workspace_provider.set_checked_files(paths_to_apply)
231301
vscode.window.showInformationMessage(
232-
dictionary.information_message.SELECTED_FILES(selected_paths.length)
302+
dictionary.information_message.SELECTED_FILES(paths_to_apply.length)
233303
)
234304
} catch (error) {
235305
vscode.window.showErrorMessage(

‎packages/vscode/src/commands/find-paths-in-clipboard-command/find-paths-in-clipboard-command.ts‎

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)