Skip to content

Commit

Permalink
ui: added some change for vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMcIntosh committed Jan 17, 2024
1 parent 910c465 commit 686922f
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 22 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
[x] hard code @commands for now but it the future they will be fetched
[x] combobox for the @commands
[x] add combobox to chat form and maybe pass text-area as a child component
[ ] remove test commands
[x] remove test commands

[ ] rag commands come from the caps url.

[ ] ensure vscode api is called only once

### EVENTS TODO FOR IDEs

[ ] add missing events
Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1"
/>
<title>Refact.ai Chat</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatContent/ChatContent.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.content {
max-width: calc(100% - 12px);
/* max-width: calc(100% - 12px); */
}
2 changes: 1 addition & 1 deletion src/components/ChatContent/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const ChatContent: React.FC<{

return (
<ScrollArea scrollbars="vertical">
<Flex grow="1" direction="column" className={styles.content}>
<Flex grow="1" p="3" pt="0" direction="column" className={styles.content}>
{messages.length === 0 && <PlaceHolderText />}
{messages.map((message, index) => {
if (isChatContextFileMessage(message)) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatForm/ChatForm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
.chatForm {
box-shadow: inset 0 0 0 1px var(--gray-a7);
border: 1px solid var(--gray-a7);
padding: 10px;
/* padding: 10px; */
border-radius: 6px;
position: relative;
flex-shrink: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatForm/ChatForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const testCommands = [
"@web",
"@database",
"@?",
"@longlonglonglong",
"@longlonglonglonglonglonglonglonglonglong",
"@refactor",
"@test",
"@Apple",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatForm/ChatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const ChatForm: React.FC<{
value={value}
onChange={setValue}
onSubmit={handleEnter}
placeholder="Type @ for commands"
placeholder={commands.length > 0 ? "Type @ for commands" : ""}
render={(props) => <TextArea disabled={isStreaming} {...props} />}
/>
<Flex gap="2" className={styles.buttonGroup}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const Popover: React.FC<
)}
>
<ComboboxPopover unmountOnHide fitViewport {...props}>
<ScrollArea scrollbars="vertical" className={styles.popover__scroll}>
<Box p="1" style={{ overflowY: "hidden" }}>
<ScrollArea scrollbars="both" className={styles.popover__scroll}>
<Box p="1" style={{ overflowY: "hidden", overflowX: "hidden" }}>
{children}
</Box>
</ScrollArea>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Select: React.FC<SelectProps> = ({
...props
}) => {
return (
<RadixSelect.Root {...props} onValueChange={onChange}>
<RadixSelect.Root {...props} onValueChange={onChange} size="1">
<RadixSelect.Trigger title={title} />
<RadixSelect.Content>
{options.map((option) => {
Expand Down
12 changes: 10 additions & 2 deletions src/components/Theme/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import {
Theme as RadixTheme,
IconButton,
Expand Down Expand Up @@ -38,9 +38,17 @@ export const Theme: React.FC<React.ComponentProps<typeof RadixTheme>> = (
props,
) => {
const config = useConfig();
const [isDarkMode, setDarkMode] = React.useState(false);

useEffect(() => {
const maybeDark = document.body.classList.contains("vscode-dark");
setDarkMode(() => maybeDark);
}, []);

if (config.host === "web") {
return <ThemeWithDarkMode {...props} />;
}
// todo make this a hook

return <RadixTheme {...props} />;
return <RadixTheme {...props} appearance={isDarkMode ? "dark" : "inherit"} />;
};
2 changes: 1 addition & 1 deletion src/contexts/config-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, createContext } from "react";

export type Config = {
rag?: boolean; // TODO: remove this
host: "web" | "ide"; // | "vscode" | "jetbrains"
host: "web" | "ide" | "vscode" | "jetbrains";
tabbed?: boolean;
lspUrl?: string;
};
Expand Down
23 changes: 14 additions & 9 deletions src/features/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { useEventBusForChat } from "../hooks/useEventBusForChat";
import { ChatContent } from "../components/ChatContent";
import { Flex, Responsive } from "@radix-ui/themes";
import { isChatContextFileMessage } from "../services/refact";
import { useConfig } from "../contexts/config-context";

export const Chat: React.FC<{ style?: React.CSSProperties }> = (props) => {
const { host } = useConfig();

const {
state,
askQuestion,
Expand All @@ -17,17 +20,19 @@ export const Chat: React.FC<{ style?: React.CSSProperties }> = (props) => {
hasContextFile,
} = useEventBusForChat();

// TODO: ide's won't need this to be as big because the light dark button won't be there
const LeftRightPadding: Responsive<
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
> = {
initial: "8",
// xs: "5",
// sm: "6",
// md: "7",
// lg: "8",
xl: "9",
};
> =
host === "web"
? { initial: "8", xl: "9" }
: {
initial: "2",
xs: "2",
sm: "4",
md: "8",
lg: "8",
xl: "9",
};

const TopBottomPadding: Responsive<
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Expand Down

0 comments on commit 686922f

Please sign in to comment.