Skip to content

Commit

Permalink
rename steps to processes
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed Dec 27, 2024
1 parent bb48526 commit 0bc8e4f
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class SerializedChatMessage(
val intent: IntentEnum? = null, // Oneof: search, chat, edit, insert
val manuallySelectedIntent: ManuallySelectedIntentEnum? = null, // Oneof: search, chat, edit, insert
val search: Any? = null,
val steps: List<>? = null,
val processes: List<>? = null,
) {

enum class SpeakerEnum {
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/src/chat/transcript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export function serializeChatMessage(chatMessage: ChatMessage): SerializedChatMe
intent: chatMessage.intent,
manuallySelectedIntent: chatMessage.manuallySelectedIntent,
search: chatMessage.search,
steps: chatMessage.steps,
processes: chatMessage.processes,
}
}
4 changes: 2 additions & 2 deletions lib/shared/src/chat/transcript/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface ChatMessage extends Message {
intent?: 'search' | 'chat' | 'edit' | 'insert' | undefined | null
manuallySelectedIntent?: 'search' | 'chat' | 'edit' | 'insert' | undefined | null
search?: ChatMessageSearch | undefined | null
steps?: ProcessingStep[] | undefined | null
processes?: ProcessingStep[] | undefined | null
}

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ export interface SerializedChatMessage {
intent?: ChatMessage['intent']
manuallySelectedIntent?: ChatMessage['manuallySelectedIntent']
search?: ChatMessage['search']
steps?: ChatMessage['steps']
processes?: ChatMessage['processes']
}

export interface ChatError {
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/chat/agentic/CodyChatAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export abstract class CodyChatAgent {

// Create a steps manager to handle state updates efficiently
const stepsManager = new ProcessManager(steps => {
this.chatBuilder.setLastMessageSteps(steps)
this.chatBuilder.setLastMessageProcesses(steps)
this.postMessageCallback?.(model)
})

Expand Down
18 changes: 9 additions & 9 deletions vscode/src/chat/agentic/ProcessManager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type ProcessingStep, errorToChatError } from '@sourcegraph/cody-shared'

export class ProcessManager {
private steps: ProcessingStep[] = []
private processes: ProcessingStep[] = []

constructor(private readonly onChange: (steps: ProcessingStep[]) => void) {}
constructor(private readonly onChange: (processes: ProcessingStep[]) => void) {}

public initializeStep(): void {
this.steps = [
this.processes = [
{
content: '',
id: '',
Expand All @@ -18,10 +18,10 @@ export class ProcessManager {
}

public addStep(toolName: string, content: string): void {
this.steps.push({
this.processes.push({
content,
id: toolName,
step: this.steps.length,
step: this.processes.length,
status: 'pending',
})
this.notifyChange()
Expand All @@ -30,7 +30,7 @@ export class ProcessManager {
public completeStep(toolName?: string, error?: Error): void {
if (toolName) {
// Update specific tool
this.steps = this.steps.map(step =>
this.processes = this.processes.map(step =>
step.id === toolName
? {
...step,
Expand All @@ -40,8 +40,8 @@ export class ProcessManager {
: step
)
} else {
// Complete all pending steps
this.steps = this.steps.map(step => ({
// Complete all pending processes
this.processes = this.processes.map(step => ({
...step,
status: step.status === 'error' ? step.status : 'success',
}))
Expand All @@ -50,6 +50,6 @@ export class ProcessManager {
}

private notifyChange(): void {
this.onChange(this.steps)
this.onChange(this.processes)
}
}
17 changes: 3 additions & 14 deletions vscode/src/chat/chat-view/ChatBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,15 @@ export class ChatBuilder {
this.changeNotifications.next()
}

public getLastMessageSteps(): ProcessingStep[] | undefined {
public setLastMessageProcesses(processes: ProcessingStep[]): void {
const lastMessage = this.messages.at(-1)
if (!lastMessage) {
throw new Error('no last message')
}
if (lastMessage.speaker !== 'human') {
throw new Error('Cannot set steps for bot message')
throw new Error('Cannot set processes for bot message')
}
return lastMessage.steps || undefined
}

public setLastMessageSteps(steps: ProcessingStep[]): void {
const lastMessage = this.messages.at(-1)
if (!lastMessage) {
throw new Error('no last message')
}
if (lastMessage.speaker !== 'human') {
throw new Error('Cannot set steps for bot message')
}
lastMessage.steps = steps
lastMessage.processes = processes
this.changeNotifications.next()
}

Expand Down
28 changes: 14 additions & 14 deletions vscode/src/chat/chat-view/ChatController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('ChatController', () => {
error: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -159,7 +159,7 @@ describe('ChatController', () => {
editorState: undefined,
text: undefined,
contextFiles: undefined,
steps: undefined,
processes: undefined,
},
],
})
Expand All @@ -184,7 +184,7 @@ describe('ChatController', () => {
search: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -196,7 +196,7 @@ describe('ChatController', () => {
text: 'Test reply 1',
search: undefined,
contextFiles: undefined,
steps: undefined,
processes: undefined,
},
],
})
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('ChatController', () => {
search: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -249,7 +249,7 @@ describe('ChatController', () => {
text: 'Test reply 1',
search: undefined,
contextFiles: undefined,
steps: undefined,
processes: undefined,
},
{
speaker: 'human',
Expand All @@ -261,7 +261,7 @@ describe('ChatController', () => {
error: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -273,7 +273,7 @@ describe('ChatController', () => {
text: 'Test reply 2',
contextFiles: undefined,
search: undefined,
steps: undefined,
processes: undefined,
},
],
})
Expand Down Expand Up @@ -313,7 +313,7 @@ describe('ChatController', () => {
search: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -325,7 +325,7 @@ describe('ChatController', () => {
text: 'Test reply 1',
search: undefined,
contextFiles: undefined,
steps: undefined,
processes: undefined,
},
{
speaker: 'human',
Expand All @@ -337,7 +337,7 @@ describe('ChatController', () => {
error: undefined,
editorState: null,
contextFiles: [],
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -349,7 +349,7 @@ describe('ChatController', () => {
editorState: undefined,
text: 'Test reply 3',
contextFiles: undefined,
steps: undefined,
processes: undefined,
},
],
})
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('ChatController', () => {
intent: 'chat',
manuallySelectedIntent: undefined,
search: undefined,
steps: undefined,
processes: undefined,
},
{
speaker: 'assistant',
Expand All @@ -410,7 +410,7 @@ describe('ChatController', () => {
text: undefined,
contextFiles: undefined,
search: undefined,
steps: undefined,
processes: undefined,
},
],
})
Expand Down
2 changes: 1 addition & 1 deletion vscode/webviews/chat/Transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ const TranscriptInteraction: FC<TranscriptInteractionProps> = memo(props => {
assistantMessage?.model?.includes('deep-cody') &&
humanMessage.index < 3
} // Open the context cell for the first 2 human messages when Deep Cody is run.
steps={humanMessage?.steps ?? undefined}
processes={humanMessage?.processes ?? undefined}
/>
)}
{assistantMessage && !isContextLoading && (
Expand Down
4 changes: 2 additions & 2 deletions vscode/webviews/chat/cells/contextCell/ContextCell.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const WithSteps: Story = {
contextItems: [{ type: 'file', uri: URI.file('/foo/bar.go') }],
isForFirstMessage: true,
model: 'deep-cody',
steps: [
processes: [
{
id: 'Code Search',
status: 'success',
Expand All @@ -201,7 +201,7 @@ export const LoadingWithSteps: Story = {
contextItems: [{ type: 'file', uri: URI.file('/foo/bar.go') }],
isForFirstMessage: true,
model: 'deep-cody',
steps: [
processes: [
{
id: 'Code Search',
status: 'success',
Expand Down
Loading

0 comments on commit 0bc8e4f

Please sign in to comment.