🐛 fix onBlur toggle bug
This commit is contained in:
parent
641331f5f5
commit
82dcfdffad
7 changed files with 84 additions and 54 deletions
|
|
@ -140,9 +140,9 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
return this.messenger?.sendAndReceive("get_config", {});
|
||||
}
|
||||
|
||||
onAddContextItem(callback: (item: ContextItem) => void) {
|
||||
this.messenger?.onMessageType("add_context_item", (data: ContextItem) => {
|
||||
callback(data);
|
||||
onAddContextItem(callback: (item: ContextItem, index: number) => void) {
|
||||
this.messenger?.onMessageType("add_context_item_at_index", (data: any) => {
|
||||
callback(data.item, data.index);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -892,6 +892,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
onClick={(e) => {
|
||||
setShowContextToggleOn((prev) => !prev);
|
||||
}}
|
||||
tabIndex={0}
|
||||
id="toggle-context-div"
|
||||
>
|
||||
{showContextToggleOn ? (
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Dispatch } from "@reduxjs/toolkit";
|
||||
import ContinueGUIClientProtocol from "../client/ContinueGUIClientProtocol";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
addContextItem,
|
||||
addContextItemAtIndex,
|
||||
addHighlightedCode,
|
||||
processSessionUpdate,
|
||||
setActive,
|
||||
|
|
@ -69,8 +69,8 @@ function useSetup(
|
|||
dispatch(setIndexingProgress(progress));
|
||||
});
|
||||
|
||||
client.onAddContextItem((item) => {
|
||||
dispatch(addContextItem(item));
|
||||
client.onAddContextItem((item, index) => {
|
||||
dispatch(addContextItemAtIndex({ item, index }));
|
||||
});
|
||||
|
||||
client.onConfigUpdate((config) => {
|
||||
|
|
|
|||
|
|
@ -6,48 +6,6 @@ import { PersistedSessionInfo } from "../../schema/PersistedSessionInfo";
|
|||
import { v4 } from "uuid";
|
||||
import { ContextItemId } from "../../schema/ContextItemId";
|
||||
|
||||
const TEST_TIMELINE = [
|
||||
{
|
||||
description: "Hi, please write bubble sort in python",
|
||||
name: "User Input",
|
||||
},
|
||||
{
|
||||
description: `\`\`\`python
|
||||
def bubble_sort(arr):
|
||||
n = len(arr)
|
||||
for i in range(n):
|
||||
for j in range(0, n - i - 1):
|
||||
if arr[j] > arr[j + 1]:
|
||||
arr[j], arr[j + 1] = arr[j + 1], arr[j]
|
||||
return arr
|
||||
\`\`\``,
|
||||
name: "Bubble Sort in Python",
|
||||
},
|
||||
{
|
||||
description: "Now write it in Rust",
|
||||
name: "User Input",
|
||||
},
|
||||
{
|
||||
description: "Hello! This is a test...\n\n1, 2, 3, testing...",
|
||||
name: "Testing",
|
||||
},
|
||||
{
|
||||
description: `Sure, here's bubble sort written in rust: \n\`\`\`rust
|
||||
fn bubble_sort<T: Ord>(values: &mut[T]) {
|
||||
let len = values.len();
|
||||
for i in 0..len {
|
||||
for j in 0..(len - i - 1) {
|
||||
if values[j] > values[j + 1] {
|
||||
values.swap(j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`\nIs there anything else I can answer?`,
|
||||
name: "Rust Bubble Sort",
|
||||
},
|
||||
];
|
||||
|
||||
const TEST_CONTEXT_ITEMS: ContextItem[] = [
|
||||
{
|
||||
content: "def add(a, b):\n return a + b",
|
||||
|
|
@ -73,6 +31,57 @@ const TEST_CONTEXT_ITEMS: ContextItem[] = [
|
|||
},
|
||||
];
|
||||
|
||||
const TEST_TIMELINE = [
|
||||
{
|
||||
description: "Hi, please write bubble sort in python",
|
||||
name: "User Input",
|
||||
params: { context_items: TEST_CONTEXT_ITEMS },
|
||||
hide: false,
|
||||
depth: 0,
|
||||
},
|
||||
{
|
||||
description: `\`\`\`python
|
||||
def bubble_sort(arr):
|
||||
n = len(arr)
|
||||
for i in range(n):
|
||||
for j in range(0, n - i - 1):
|
||||
if arr[j] > arr[j + 1]:
|
||||
arr[j], arr[j + 1] = arr[j + 1], arr[j]
|
||||
return arr
|
||||
\`\`\``,
|
||||
name: "Bubble Sort in Python",
|
||||
params: {},
|
||||
hide: false,
|
||||
depth: 0,
|
||||
},
|
||||
{
|
||||
description: "Now write it in Rust",
|
||||
name: "User Input",
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
description: "Hello! This is a test...\n\n1, 2, 3, testing...",
|
||||
name: "Testing",
|
||||
hide: false,
|
||||
},
|
||||
{
|
||||
description: `Sure, here's bubble sort written in rust: \n\`\`\`rust
|
||||
fn bubble_sort<T: Ord>(values: &mut[T]) {
|
||||
let len = values.len();
|
||||
for i in 0..len {
|
||||
for j in 0..(len - i - 1) {
|
||||
if values[j] > values[j + 1] {
|
||||
values.swap(j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\`\`\`\nIs there anything else I can answer?`,
|
||||
name: "Rust Bubble Sort",
|
||||
depth: 0,
|
||||
},
|
||||
];
|
||||
|
||||
export interface SessionFullState {
|
||||
history: StepDescription[];
|
||||
context_items: ContextItem[];
|
||||
|
|
|
|||
|
|
@ -207,8 +207,26 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
)
|
||||
|
||||
async def add_context_item(self, item: ContextItem):
|
||||
self.__autopilot.session_state.context_items.append(item)
|
||||
await self.gui.add_context_item(item)
|
||||
index = len(self.__autopilot.session_state.history) - 1
|
||||
while index > 0:
|
||||
if (
|
||||
self.__autopilot.session_state.history[index].step_type
|
||||
== "UserInputStep"
|
||||
):
|
||||
break
|
||||
index -= 1
|
||||
|
||||
await self.add_context_item_at_index(item, index)
|
||||
|
||||
async def add_context_item_at_index(self, item: ContextItem, index: int):
|
||||
context_items = self.__autopilot.session_state.history[index].params.get(
|
||||
"context_items", []
|
||||
)
|
||||
context_items.append(item.dict())
|
||||
self.__autopilot.session_state.history[index].params[
|
||||
"context_items"
|
||||
] = context_items
|
||||
await self.gui.add_context_item_at_index(item, index)
|
||||
|
||||
def set_loading_message(self, message: str):
|
||||
# self.__autopilot.set_loading_message(message)
|
||||
|
|
|
|||
|
|
@ -159,8 +159,10 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
|
|||
{}, SessionState, "get_session_state"
|
||||
)
|
||||
|
||||
async def add_context_item(self, item: ContextItem):
|
||||
await self.messenger.send("add_context_item", item.dict())
|
||||
async def add_context_item_at_index(self, item: ContextItem, index: int):
|
||||
await self.messenger.send(
|
||||
"add_context_item_at_index", {"item": item.dict(), "index": index}
|
||||
)
|
||||
|
||||
async def send_config_update(self):
|
||||
if config := self.get_config():
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ class AbstractGUIProtocolServer(ABC):
|
|||
...
|
||||
|
||||
@abstractmethod
|
||||
async def add_context_item(self, item: ContextItem):
|
||||
async def add_context_item_at_index(self, item: ContextItem, index: int):
|
||||
...
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue