Skip to content

Commit bc00cac

Browse files
committed
Rename chat history state keys and message types to improve consistency with prompt terminology
- rename 'edit context' to 'edit files' in message/command names - in 'chat history' rename 'edit context' to 'edit files' - rename 'history ask' to 'history ask about files', 'history edit' to 'history edit files', 'history no context' to 'history without files'
1 parent d197dc8 commit bc00cac

5 files changed

Lines changed: 45 additions & 44 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export const INSTRUCTIONS_FIND_RELEVANT_FILES_STATE_KEY =
4848
export const ARE_TASKS_COLLAPSED_STATE_KEY = 'are-tasks-collapsed'
4949
export const ARE_CHECKPOINTS_COLLAPSED_STATE_KEY = 'are-checkpoints-collapsed'
5050

51-
export const HISTORY_ASK_STATE_KEY = 'history-ask'
52-
export const HISTORY_EDIT_STATE_KEY = 'history-edit'
51+
export const HISTORY_ASK_ABOUT_FILES_STATE_KEY = 'history-ask-about-files'
52+
export const HISTORY_EDIT_FILES_STATE_KEY = 'history-edit-files'
5353
export const HISTORY_CODE_AT_CURSOR_STATE_KEY = 'history-code-at-cursor'
5454
export const HISTORY_FIND_RELEVANT_FILES_STATE_KEY =
5555
'history-find-relevant-files'
56-
export const HISTORY_NO_CONTEXT_STATE_KEY = 'history-no-context'
56+
export const HISTORY_WITHOUT_FILES_STATE_KEY = 'history-without-files'
5757
export const FIND_RELEVANT_FILES_SHRINK_SOURCE_CODE_STATE_KEY =
5858
'find-relevant-files-shrink-source-code'
5959

‎apps/editor/src/views/panel/backend/message-handlers/handle-get-history.ts‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
import {
2-
HISTORY_ASK_STATE_KEY,
2+
HISTORY_ASK_ABOUT_FILES_STATE_KEY,
33
HISTORY_CODE_AT_CURSOR_STATE_KEY,
4-
HISTORY_EDIT_STATE_KEY,
5-
HISTORY_NO_CONTEXT_STATE_KEY,
4+
HISTORY_EDIT_FILES_STATE_KEY,
5+
HISTORY_WITHOUT_FILES_STATE_KEY,
66
HISTORY_FIND_RELEVANT_FILES_STATE_KEY,
77
HistoryEntry
88
} from '@/constants/state-keys'
99
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1010

1111
export const handle_get_history = (panel_provider: PanelProvider) => {
12-
const ask_history = panel_provider.context.workspaceState.get<HistoryEntry[]>(
13-
HISTORY_ASK_STATE_KEY,
14-
[]
15-
)
16-
const edit_history = panel_provider.context.workspaceState.get<
12+
const edit_files_history = panel_provider.context.workspaceState.get<
1713
HistoryEntry[]
18-
>(HISTORY_EDIT_STATE_KEY, [])
14+
>(HISTORY_EDIT_FILES_STATE_KEY, [])
15+
const ask_about_files_history = panel_provider.context.workspaceState.get<
16+
HistoryEntry[]
17+
>(HISTORY_ASK_ABOUT_FILES_STATE_KEY, [])
1918
const code_completions_history = panel_provider.context.workspaceState.get<
2019
HistoryEntry[]
2120
>(HISTORY_CODE_AT_CURSOR_STATE_KEY, [])
22-
const no_context_history = panel_provider.context.workspaceState.get<
21+
const without_files_history = panel_provider.context.workspaceState.get<
2322
HistoryEntry[]
24-
>(HISTORY_NO_CONTEXT_STATE_KEY, [])
23+
>(HISTORY_WITHOUT_FILES_STATE_KEY, [])
2524
const find_relevant_files_history = panel_provider.context.workspaceState.get<
2625
HistoryEntry[]
2726
>(HISTORY_FIND_RELEVANT_FILES_STATE_KEY, [])
2827

2928
panel_provider.send_message({
3029
command: 'CHAT_HISTORY',
31-
ask_about_context: ask_history.map((h) => h.text),
32-
edit_context: edit_history.map((h) => h.text),
33-
no_context: no_context_history.map((h) => h.text),
30+
ask_about_files: ask_about_files_history.map((h) => h.text),
31+
edit_files: edit_files_history.map((h) => h.text),
32+
without_files: without_files_history.map((h) => h.text),
3433
code_at_cursor: code_completions_history.map((h) => h.text),
3534
find_relevant_files: find_relevant_files_history.map((h) => h.text)
3635
})

‎apps/editor/src/views/panel/backend/message-handlers/handle-save-history.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2-
HISTORY_ASK_STATE_KEY,
2+
HISTORY_ASK_ABOUT_FILES_STATE_KEY,
33
HISTORY_CODE_AT_CURSOR_STATE_KEY,
4-
HISTORY_EDIT_STATE_KEY,
5-
HISTORY_NO_CONTEXT_STATE_KEY,
4+
HISTORY_EDIT_FILES_STATE_KEY,
5+
HISTORY_WITHOUT_FILES_STATE_KEY,
66
HistoryEntry,
77
HISTORY_FIND_RELEVANT_FILES_STATE_KEY
88
} from '@/constants/state-keys'
@@ -17,13 +17,13 @@ export const handle_save_history = async (
1717

1818
switch (message.prompt_type) {
1919
case 'ask-about-files':
20-
key = HISTORY_ASK_STATE_KEY
20+
key = HISTORY_ASK_ABOUT_FILES_STATE_KEY
2121
break
2222
case 'edit-files':
23-
key = HISTORY_EDIT_STATE_KEY
23+
key = HISTORY_EDIT_FILES_STATE_KEY
2424
break
2525
case 'without-files':
26-
key = HISTORY_NO_CONTEXT_STATE_KEY
26+
key = HISTORY_WITHOUT_FILES_STATE_KEY
2727
break
2828
case 'code-at-cursor':
2929
key = HISTORY_CODE_AT_CURSOR_STATE_KEY

‎apps/editor/src/views/panel/frontend/Main/Main.tsx‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ export const Main: React.FC<Props> = (props) => {
9898
selected_api_configuration_id_by_prompt_type,
9999
set_selected_api_configuration_id_by_prompt_type
100100
] = useState<{ [T in ApiPromptType]?: string }>()
101-
const [ask_history, set_ask_history] = useState<string[]>()
102-
const [edit_history, set_edit_history] = useState<string[]>()
103-
const [no_context_history, set_no_context_history] = useState<string[]>()
101+
const [ask_about_files_history, set_ask_about_files_history] =
102+
useState<string[]>()
103+
const [edit_files_history, set_edit_files_history] = useState<string[]>()
104+
const [without_files_history, set_without_files_history] =
105+
useState<string[]>()
104106
const [code_completions_history, set_code_completions_history] =
105107
useState<string[]>()
106108
const [find_relevant_files_history, set_find_relevant_files_history] =
@@ -138,9 +140,9 @@ export const Main: React.FC<Props> = (props) => {
138140
)
139141
break
140142
case 'CHAT_HISTORY':
141-
set_ask_history(message.ask_about_context || [])
142-
set_edit_history(message.edit_context || [])
143-
set_no_context_history(message.no_context || [])
143+
set_ask_about_files_history(message.ask_about_files || [])
144+
set_edit_files_history(message.edit_files || [])
145+
set_without_files_history(message.without_files || [])
144146
set_code_completions_history(message.code_at_cursor || [])
145147
set_find_relevant_files_history(message.find_relevant_files || [])
146148
break
@@ -198,14 +200,14 @@ export const Main: React.FC<Props> = (props) => {
198200
let set_history: React.Dispatch<React.SetStateAction<string[] | undefined>>
199201

200202
if (current_prompt_type == 'ask-about-files') {
201-
history = ask_history
202-
set_history = set_ask_history
203+
history = ask_about_files_history
204+
set_history = set_ask_about_files_history
203205
} else if (current_prompt_type == 'edit-files') {
204-
history = edit_history
205-
set_history = set_edit_history
206+
history = edit_files_history
207+
set_history = set_edit_files_history
206208
} else if (current_prompt_type == 'without-files') {
207-
history = no_context_history
208-
set_history = set_no_context_history
209+
history = without_files_history
210+
set_history = set_without_files_history
209211
} else if (current_prompt_type == 'code-at-cursor') {
210212
history = code_completions_history
211213
set_history = set_code_completions_history
@@ -586,11 +588,11 @@ export const Main: React.FC<Props> = (props) => {
586588

587589
let current_history: string[] | undefined
588590
if (current_prompt_type == 'ask-about-files') {
589-
current_history = ask_history
591+
current_history = ask_about_files_history
590592
} else if (current_prompt_type == 'edit-files') {
591-
current_history = edit_history
593+
current_history = edit_files_history
592594
} else if (current_prompt_type == 'without-files') {
593-
current_history = no_context_history
595+
current_history = without_files_history
594596
} else if (current_prompt_type == 'code-at-cursor') {
595597
current_history = code_completions_history
596598
} else if (current_prompt_type == 'find-relevant-files') {
@@ -600,9 +602,9 @@ export const Main: React.FC<Props> = (props) => {
600602
if (
601603
all_web_configurations === undefined ||
602604
all_api_configurations === undefined ||
603-
ask_history === undefined ||
604-
edit_history === undefined ||
605-
no_context_history === undefined ||
605+
ask_about_files_history === undefined ||
606+
edit_files_history === undefined ||
607+
without_files_history === undefined ||
606608
code_completions_history === undefined ||
607609
find_relevant_files_history === undefined ||
608610
is_in_code_completions_mode === undefined ||

‎apps/editor/src/views/panel/types/messages.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,9 @@ export interface EditorSelectionChangedMessage extends BaseMessage {
758758

759759
export interface ChatHistoryMessage extends BaseMessage {
760760
command: 'CHAT_HISTORY'
761-
ask_about_context: string[]
762-
edit_context: string[]
763-
no_context: string[]
761+
ask_about_files: string[]
762+
edit_files: string[]
763+
without_files: string[]
764764
code_at_cursor: string[]
765765
find_relevant_files: string[]
766766
}

0 commit comments

Comments
 (0)