Skip to content

Commit cb8e571

Browse files
committed
Refactor context restoration utilities into a dedicated feature module and reorganize commands
- 'context restoration' should be organized like commit message generation - primarily in 'features' - fix imports/exports in `apps/editor/src/views/prompt/backend/utils/symbols/saved-context/replace-saved-context-symbol.ts``apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/saved-context-symbol.ts` `apps/editor/src/commands/index.ts` └── apps └── editor └── src ├── commands │ ├── generate-commit-message-command │ │ ├── actions │ │ │ ├── get-prompt-data.ts │ │ │ └── run-generate-action.ts │ │ ├── generate-commit-message-command.ts │ │ └── index.ts │ ├── index.ts │ ├── restore-file-selection-command │ │ ├── actions │ │ │ ├── restore-from-json-file.ts │ │ │ └── restore-from-workspace-state.ts │ │ ├── index.ts │ │ └── restore-file-selection-command.ts │ └── save-file-selection-command │ ├── actions │ │ ├── save-to-json-file.ts │ │ └── save-to-workspace-state.ts │ ├── index.ts │ └── save-file-selection-command.ts ├── features │ ├── commit-messages │ │ ├── index.ts │ │ └── utils │ │ ├── build-commit-message-prompt.ts │ │ ├── generate-commit-message-with-api.ts │ │ ├── get-commit-message-config.ts │ │ └── strip-wrapping-quotes.ts │ └── context-restoration │ ├── index.ts │ └── utils │ ├── ask-for-new-context-name.ts │ ├── context-file-utils.ts │ ├── create-context-description.ts │ ├── file-contexts.ts │ ├── global-storage-utils.ts │ ├── path-utils.ts │ ├── resolve-context-paths.ts │ ├── resolve-glob-patterns.ts │ ├── resolve-paths.ts │ ├── select-context-paths.ts │ └── source-selector.ts └── views └── prompt └── backend ├── message-handlers │ └── handle-hash-sign-quick-pick │ └── symbols │ └── saved-context-symbol.ts └── utils └── symbols └── saved-context └── replace-saved-context-symbol.ts
1 parent 12b496a commit cb8e571

23 files changed

Lines changed: 57 additions & 38 deletions

‎apps/editor/src/commands/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export * from './open-url-command'
1616
export * from './reference-in-prompt-command'
1717
export * from './rename-command'
1818
export * from './save-all-command'
19-
export * from './context-restoration/save'
20-
export * from './context-restoration/restore'
19+
export * from './restore-file-selection-command'
20+
export * from './save-file-selection-command'
2121
export * from './set-ranges-command'
2222
export * from './search-files-commands'
2323
export * from './select-referencing-files-command'

apps/editor/src/commands/context-restoration/restore/restore-from-json-file.ts renamed to apps/editor/src/commands/restore-file-selection-command/actions/restore-from-json-file.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ import { WorkspaceProvider } from '../../../context/providers/workspace/workspac
55
import { SavedContext } from '@/types/context'
66
import { Logger } from '@shared/utils/logger'
77
import { dictionary } from '@shared/constants/dictionary'
8-
import { select_context_paths } from '../utils/select-context-paths'
9-
import { load_and_merge_file_contexts } from '../utils/file-contexts'
108
import {
9+
select_context_paths,
10+
load_and_merge_file_contexts,
1111
save_contexts_to_file,
1212
get_contexts_file_path,
13-
load_contexts_from_file
14-
} from '../utils/context-file-utils'
15-
import { group_files_by_workspace, condense_paths } from '../utils/path-utils'
13+
load_contexts_from_file,
14+
group_files_by_workspace,
15+
condense_paths,
16+
create_context_description
17+
} from '@/features/context-restoration'
1618
import { t } from '@/i18n'
17-
import { create_context_description } from '../utils/create-context-description'
1819

1920
export const restore_from_json_file = async (params: {
2021
workspace_provider: WorkspaceProvider

apps/editor/src/commands/context-restoration/restore/restore-from-workspace-state.ts renamed to apps/editor/src/commands/restore-file-selection-command/actions/restore-from-workspace-state.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import { WorkspaceProvider } from '../../../context/providers/workspace/workspac
33
import { SavedContext } from '@/types/context'
44
import { Logger } from '@shared/utils/logger'
55
import { dictionary } from '@shared/constants/dictionary'
6-
import { select_context_paths } from '../utils/select-context-paths'
76
import {
7+
select_context_paths,
88
load_and_merge_global_contexts,
99
save_contexts_for_workspace,
10-
load_contexts_for_workspace
11-
} from '../utils/global-storage-utils'
12-
import { group_files_by_workspace, condense_paths } from '../utils/path-utils'
10+
load_contexts_for_workspace,
11+
group_files_by_workspace,
12+
condense_paths,
13+
create_context_description
14+
} from '@/features/context-restoration'
1315
import { t } from '@/i18n'
14-
import { create_context_description } from '../utils/create-context-description'
1516

1617
let active_deletion_timestamp: number | undefined
1718

apps/editor/src/commands/context-restoration/restore/index.ts renamed to apps/editor/src/commands/restore-file-selection-command/index.ts

File renamed without changes.

apps/editor/src/commands/context-restoration/restore/restore-file-selection-command.ts renamed to apps/editor/src/commands/restore-file-selection-command/restore-file-selection-command.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode'
2-
import { WorkspaceProvider } from '../../../context/providers/workspace/workspace-provider'
3-
import { select_context_source } from '../utils/source-selector'
4-
import { restore_from_workspace_state } from './restore-from-workspace-state'
5-
import { restore_from_json_file } from './restore-from-json-file'
2+
import { WorkspaceProvider } from '../../context/providers/workspace/workspace-provider'
3+
import { select_context_source } from '@/features/context-restoration'
4+
import { restore_from_workspace_state } from './actions/restore-from-workspace-state'
5+
import { restore_from_json_file } from './actions/restore-from-json-file'
66
import { t } from '@/i18n'
77

88
export const restore_file_selection_command = (params: {

apps/editor/src/commands/context-restoration/save/save-to-json-file.ts renamed to apps/editor/src/commands/save-file-selection-command/actions/save-to-json-file.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs'
44
import { WorkspaceProvider } from '../../../context/providers/workspace/workspace-provider'
5-
import { load_and_merge_file_contexts } from '../utils/file-contexts'
65
import {
6+
load_and_merge_file_contexts,
77
get_contexts_file_path,
88
load_contexts_from_file,
99
save_contexts_to_file,
10-
resolve_unique_context_name
11-
} from '../utils/context-file-utils'
12-
import { group_files_by_workspace, condense_paths } from '../utils/path-utils'
13-
import { ask_for_new_context_name } from '../utils/ask-for-new-context-name'
10+
resolve_unique_context_name,
11+
group_files_by_workspace,
12+
condense_paths,
13+
ask_for_new_context_name,
14+
create_context_description
15+
} from '@/features/context-restoration'
1416
import { SavedContext } from '@/types/context'
1517
import { t } from '@/i18n'
1618
import { dictionary } from '@shared/constants/dictionary'
17-
import { create_context_description } from '../utils/create-context-description'
1819

1920
export const save_to_json_file = async (params: {
2021
workspace_provider: WorkspaceProvider

apps/editor/src/commands/context-restoration/save/save-to-workspace-state.ts renamed to apps/editor/src/commands/save-file-selection-command/actions/save-to-workspace-state.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { WorkspaceProvider } from '../../../context/providers/workspace/workspac
33
import {
44
load_and_merge_global_contexts,
55
save_contexts_for_workspace,
6-
load_contexts_for_workspace
7-
} from '../utils/global-storage-utils'
8-
import { group_files_by_workspace, condense_paths } from '../utils/path-utils'
9-
import { ask_for_new_context_name } from '../utils/ask-for-new-context-name'
10-
import { resolve_unique_context_name } from '../utils/context-file-utils'
6+
load_contexts_for_workspace,
7+
group_files_by_workspace,
8+
condense_paths,
9+
ask_for_new_context_name,
10+
resolve_unique_context_name,
11+
create_context_description
12+
} from '@/features/context-restoration'
1113
import { t } from '@/i18n'
1214
import { dictionary } from '@shared/constants/dictionary'
13-
import { create_context_description } from '../utils/create-context-description'
1415

1516
export const save_to_workspace_state = async (params: {
1617
workspace_provider: WorkspaceProvider

apps/editor/src/commands/context-restoration/save/index.ts renamed to apps/editor/src/commands/save-file-selection-command/index.ts

File renamed without changes.

apps/editor/src/commands/context-restoration/save/save-file-selection-command.ts renamed to apps/editor/src/commands/save-file-selection-command/save-file-selection-command.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode'
2-
import { WorkspaceProvider } from '../../../context/providers/workspace/workspace-provider'
3-
import { select_context_source } from '../utils/source-selector'
4-
import { save_to_workspace_state } from './save-to-workspace-state'
5-
import { save_to_json_file } from './save-to-json-file'
2+
import { WorkspaceProvider } from '../../context/providers/workspace/workspace-provider'
3+
import { select_context_source } from '@/features/context-restoration'
4+
import { save_to_workspace_state } from './actions/save-to-workspace-state'
5+
import { save_to_json_file } from './actions/save-to-json-file'
66
import { t } from '@/i18n'
77
import { dictionary } from '@shared/constants/dictionary'
88

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export * from './utils/ask-for-new-context-name'
2+
export * from './utils/context-file-utils'
3+
export * from './utils/create-context-description'
4+
export * from './utils/file-contexts'
5+
export * from './utils/global-storage-utils'
6+
export * from './utils/path-utils'
7+
export * from './utils/resolve-context-paths'
8+
export * from './utils/resolve-glob-patterns'
9+
export * from './utils/resolve-paths'
10+
export * from './utils/select-context-paths'
11+
export * from './utils/source-selector'

0 commit comments

Comments
 (0)