🚧 preview context items
This commit is contained in:
parent
8030c8900f
commit
6fb7ca0d2a
11 changed files with 179 additions and 144 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -137,8 +137,27 @@ export function setupDebugPanel(
|
|||
socket.send(data.message);
|
||||
break;
|
||||
}
|
||||
case "openFile": {
|
||||
openEditorAndRevealRange(data.path, undefined, vscode.ViewColumn.One);
|
||||
case "showFile": {
|
||||
ideProtocolClient.openFile(data.filepath);
|
||||
break;
|
||||
}
|
||||
case "showLines": {
|
||||
ideProtocolClient.highlightCode(
|
||||
{
|
||||
filepath: data.filepath,
|
||||
range: {
|
||||
start: {
|
||||
line: data.start,
|
||||
character: 0,
|
||||
},
|
||||
end: {
|
||||
line: data.end + 1,
|
||||
character: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
"#00ff0022"
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "showVirtualFile": {
|
||||
|
|
|
|||
|
|
@ -1017,7 +1017,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
width="20px"
|
||||
filename={item.description.name}
|
||||
></FileIcon>
|
||||
{item.description.description}
|
||||
{item.description.name}
|
||||
</PreviewMarkdownHeader>
|
||||
<pre className="m-0">
|
||||
<StyledMarkdownPreview
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { getFontSize } from "../util";
|
|||
import HeaderButtonWithText from "./HeaderButtonWithText";
|
||||
import FileIcon from "./FileIcon";
|
||||
import { ContextItem } from "../schema/ContextItem";
|
||||
import { postToIde } from "../vscode";
|
||||
|
||||
const Button = styled.button<{ fontSize?: number }>`
|
||||
border: none;
|
||||
|
|
@ -188,9 +189,27 @@ const PillButton = (props: PillButtonProps) => {
|
|||
}}
|
||||
onClick={(e) => {
|
||||
props.onClick?.(e);
|
||||
client?.previewContextItem(
|
||||
`${props.item.description.id.provider_title}-${props.item.description.id.item_id}`
|
||||
);
|
||||
if (props.item.description.id.provider_title === "file") {
|
||||
console.log("showing file", props.item);
|
||||
postToIde("showFile", {
|
||||
filepath: props.item.description.description,
|
||||
});
|
||||
} else if (props.item.description.id.provider_title === "code") {
|
||||
const lines = props.item.description.name
|
||||
.split("(")[1]
|
||||
.split(")")[0]
|
||||
.split("-");
|
||||
postToIde("showLines", {
|
||||
filepath: props.item.description.description,
|
||||
start: parseInt(lines[0]) - 1,
|
||||
end: parseInt(lines[1]) - 1,
|
||||
});
|
||||
} else {
|
||||
postToIde("showVirtualFile", {
|
||||
name: props.item.description.name,
|
||||
content: props.item.content,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
if (!pillContainerRef.current?.contains(e.relatedTarget as any)) {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,6 @@ abstract class AbstractContinueGUIClientProtocol {
|
|||
abstract deleteContextGroup(id: string): void;
|
||||
|
||||
abstract setCurrentSessionTitle(title: string): void;
|
||||
|
||||
abstract previewContextItem(id: string): void;
|
||||
}
|
||||
|
||||
export default AbstractContinueGUIClientProtocol;
|
||||
|
|
|
|||
|
|
@ -203,10 +203,6 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
|
|||
setCurrentSessionTitle(title: string): void {
|
||||
this.messenger?.send("set_current_session_title", { title });
|
||||
}
|
||||
|
||||
previewContextItem(id: string): void {
|
||||
this.messenger?.send("preview_context_item", { id });
|
||||
}
|
||||
}
|
||||
|
||||
export default ContinueGUIClientProtocol;
|
||||
|
|
|
|||
|
|
@ -73,13 +73,12 @@ export class SocketIOMessenger extends Messenger {
|
|||
}
|
||||
|
||||
async sendAndReceive(messageType: string, data: any): Promise<any> {
|
||||
// NOTE: This probably doesn't work. Not being used anywhere rn.
|
||||
return new Promise((resolve, reject) => {
|
||||
this.socket.emit(
|
||||
"message",
|
||||
{ message_type: messageType, data, message_id: v4() },
|
||||
(response: any) => {
|
||||
if (response.error) {
|
||||
if (response && response.error) {
|
||||
reject(response.error);
|
||||
} else {
|
||||
resolve(response);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ class FileContextProvider(ContextProvider):
|
|||
self.ide.subscribeToFilesDeleted(on_files_deleted)
|
||||
self.ide.subscribeToFilesRenamed(on_files_renamed)
|
||||
|
||||
async def get_item(self, id: ContextItemId, query: str) -> ContextItem:
|
||||
item = await super().get_item(id, query)
|
||||
item.description.description = os.path.join(
|
||||
self.ide.workspace_directory, item.description.description
|
||||
)
|
||||
return item
|
||||
|
||||
def get_id_for_filepath(self, absolute_filepath: str) -> str:
|
||||
return remove_meilisearch_disallowed_chars(absolute_filepath)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ async def message(sid, data):
|
|||
|
||||
try:
|
||||
if gui := window_manager.get_gui(sid):
|
||||
await gui.handle_json(message)
|
||||
resp = await gui.handle_json(message)
|
||||
return resp
|
||||
else:
|
||||
logger.critical(f"GUI websocket not found for sid {sid}")
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class GUIProtocolServer:
|
|||
elif msg.message_type == "stop_session":
|
||||
await self.stop_session()
|
||||
elif msg.message_type == "get_context_item":
|
||||
await self.get_context_item(data["id"], data["query"])
|
||||
return (await self.get_context_item(data["id"], data["query"])).dict()
|
||||
|
||||
elif msg.message_type == "set_current_session_title":
|
||||
self.set_current_session_title(data["title"])
|
||||
|
|
@ -336,8 +336,4 @@ class GUIProtocolServer:
|
|||
async def add_context_item(self, item: ContextItem):
|
||||
await self.messenger.send("add_context_item", item.dict())
|
||||
|
||||
async def get_context_item(self, id: str, query: str):
|
||||
context_item = await self.get_context_item(id, query)
|
||||
await self.messenger.send("get_context_item", context_item.dict())
|
||||
|
||||
# endregion
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue