Skip to content

Commit 720c904

Browse files
authored
Merge pull request #7 from trypear/nang-pear-ui
Added session state
2 parents e49013d + 2285f32 commit 720c904

File tree

5 files changed

+94
-51
lines changed

5 files changed

+94
-51
lines changed

assets/icons/pearai-agent-splash.svg

Lines changed: 17 additions & 0 deletions
Loading

webview-ui/src/App.tsx

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { ExtensionMessage } from "../../src/shared/ExtensionMessage"
44
import ChatView from "./components/chat/ChatView"
55
import HistoryView from "./components/history/HistoryView"
66
import SettingsView from "./components/settings/SettingsView"
7-
import WelcomeView from "./components/welcome/WelcomeView"
87
import { ExtensionStateContextProvider, useExtensionState } from "./context/ExtensionStateContext"
98
import { vscode } from "./utils/vscode"
109
import McpView from "./components/mcp/McpView"
@@ -73,30 +72,26 @@ const AppContent = () => {
7372

7473
return (
7574
<>
76-
{showWelcome ? (
77-
<WelcomeView />
78-
) : (
79-
<>
80-
{showSettings && <SettingsView onDone={() => setShowSettings(false)} />}
81-
{showHistory && <HistoryView onDone={() => setShowHistory(false)} />}
82-
{showMcp && <McpView onDone={() => setShowMcp(false)} />}
83-
{showPrompts && <PromptsView onDone={() => setShowPrompts(false)} />}
84-
{/* Do not conditionally load ChatView, it's expensive and there's state we don't want to lose (user input, disableInput, askResponse promise, etc.) */}
85-
<ChatView
86-
showHistoryView={() => {
87-
setShowSettings(false)
88-
setShowMcp(false)
89-
setShowPrompts(false)
90-
setShowHistory(true)
91-
}}
92-
isHidden={showSettings || showHistory || showMcp || showPrompts}
93-
showAnnouncement={showAnnouncement}
94-
hideAnnouncement={() => {
95-
setShowAnnouncement(false)
96-
}}
97-
/>
98-
</>
99-
)}
75+
<>
76+
{showSettings && <SettingsView onDone={() => setShowSettings(false)} />}
77+
{showHistory && <HistoryView onDone={() => setShowHistory(false)} />}
78+
{showMcp && <McpView onDone={() => setShowMcp(false)} />}
79+
{showPrompts && <PromptsView onDone={() => setShowPrompts(false)} />}
80+
{/* Do not conditionally load ChatView, it's expensive and there's state we don't want to lose (user input, disableInput, askResponse promise, etc.) */}
81+
<ChatView
82+
showHistoryView={() => {
83+
setShowSettings(false)
84+
setShowMcp(false)
85+
setShowPrompts(false)
86+
setShowHistory(true)
87+
}}
88+
isHidden={showSettings || showHistory || showMcp || showPrompts}
89+
showAnnouncement={false}
90+
hideAnnouncement={() => {
91+
true
92+
}}
93+
/>
94+
</>
10095
</>
10196
)
10297
}

webview-ui/src/components/chat/AutoApproveMenu.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,51 +42,51 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => {
4242
id: "readFiles",
4343
label: "Read files and directories",
4444
shortName: "Read",
45-
enabled: alwaysAllowReadOnly ?? false,
45+
enabled: alwaysAllowReadOnly ?? true,
4646
description: "Allows access to read any file on your computer.",
4747
},
4848
{
4949
id: "editFiles",
5050
label: "Edit files",
5151
shortName: "Edit",
52-
enabled: alwaysAllowWrite ?? false,
52+
enabled: alwaysAllowWrite ?? true,
5353
description: "Allows modification of any files on your computer.",
5454
},
5555
{
5656
id: "executeCommands",
5757
label: "Execute approved commands",
5858
shortName: "Commands",
59-
enabled: alwaysAllowExecute ?? false,
59+
enabled: alwaysAllowExecute ?? true,
6060
description:
6161
"Allows execution of approved terminal commands. You can configure this in the settings panel.",
6262
},
6363
{
6464
id: "useBrowser",
6565
label: "Use the browser",
6666
shortName: "Browser",
67-
enabled: alwaysAllowBrowser ?? false,
67+
enabled: alwaysAllowBrowser ?? true,
6868
description: "Allows ability to launch and interact with any website in a headless browser.",
6969
},
7070
{
7171
id: "useMcp",
7272
label: "Use MCP servers",
7373
shortName: "MCP",
74-
enabled: alwaysAllowMcp ?? false,
74+
enabled: alwaysAllowMcp ?? true,
7575
description: "Allows use of configured MCP servers which may modify filesystem or interact with APIs.",
7676
},
7777
{
7878
id: "switchModes",
7979
label: "Switch modes & create tasks",
8080
shortName: "Modes",
81-
enabled: alwaysAllowModeSwitch ?? false,
81+
enabled: alwaysAllowModeSwitch ?? true,
8282
description:
8383
"Allows automatic switching between different AI modes and creating new tasks without requiring approval.",
8484
},
8585
{
8686
id: "retryRequests",
8787
label: "Retry failed requests",
8888
shortName: "Retries",
89-
enabled: alwaysApproveResubmit ?? false,
89+
enabled: alwaysApproveResubmit ?? true,
9090
description: "Automatically retry failed API requests when the provider returns an error response.",
9191
},
9292
]

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
vscInputBorder,
4040
vscSidebarBorder,
4141
} from "../ui"
42+
import splashIcon from "../../../../assets/icons/pearai-agent-splash.svg"
4243

4344
interface ChatViewProps {
4445
isHidden: boolean
@@ -982,25 +983,45 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
982983
overflow: "hidden",
983984
}}>
984985
{messages.length === 0 && (
985-
<ChatTextArea
986-
ref={textAreaRef}
987-
inputValue={inputValue}
988-
setInputValue={setInputValue}
989-
textAreaDisabled={textAreaDisabled}
990-
placeholderText={placeholderText}
991-
selectedImages={selectedImages}
992-
setSelectedImages={setSelectedImages}
993-
onSend={() => handleSendMessage(inputValue, selectedImages)}
994-
onSelectImages={selectImages}
995-
shouldDisableImages={shouldDisableImages}
996-
onHeightChange={() => {
997-
if (isAtBottom) {
998-
scrollToBottomAuto()
999-
}
1000-
}}
1001-
mode={mode}
1002-
setMode={setMode}
1003-
/>
986+
<>
987+
<div className="max-w-2xl mx-auto w-full h-[calc(100vh-270px)] text-center flex flex-col justify-center">
988+
<div className="w-full text-center flex flex-col items-center justify-center relative gap-5">
989+
<img src={splashIcon} alt="..." />
990+
<div className="w-[300px] flex-col justify-start items-start gap-5 inline-flex">
991+
<div className="flex flex-col text-left">
992+
<div className="text-2xl">PearAI Agent</div>
993+
<div className="h-[18px] opacity-50 text-xs leading-[18px]">
994+
Powered by Roo Code / Cline
995+
</div>
996+
</div>
997+
</div>
998+
<div className="w-[300px] text-left opacity-50 text-xs leading-[18px]">
999+
Autonomous coding agent that has control of your development environment (with your
1000+
permission) for a feedback loop to add features, fix bugs, and more.
1001+
</div>
1002+
</div>
1003+
</div>
1004+
1005+
<ChatTextArea
1006+
ref={textAreaRef}
1007+
inputValue={inputValue}
1008+
setInputValue={setInputValue}
1009+
textAreaDisabled={textAreaDisabled}
1010+
placeholderText={placeholderText}
1011+
selectedImages={selectedImages}
1012+
setSelectedImages={setSelectedImages}
1013+
onSend={() => handleSendMessage(inputValue, selectedImages)}
1014+
onSelectImages={selectImages}
1015+
shouldDisableImages={shouldDisableImages}
1016+
onHeightChange={() => {
1017+
if (isAtBottom) {
1018+
scrollToBottomAuto()
1019+
}
1020+
}}
1021+
mode={mode}
1022+
setMode={setMode}
1023+
/>
1024+
</>
10041025
)}
10051026
{!task && (
10061027
<AutoApproveMenu

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
glamaDefaultModelInfo,
99
openRouterDefaultModelId,
1010
openRouterDefaultModelInfo,
11+
PEARAI_URL,
1112
} from "../../../src/shared/api"
1213
import { vscode } from "../utils/vscode"
1314
import { convertTextMateToHljs } from "../utils/textMateToHljs"
@@ -162,6 +163,15 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
162163
}))
163164
const config = newState.apiConfiguration
164165
const hasKey = checkExistKey(config)
166+
if (!hasKey) {
167+
vscode.postMessage({
168+
type: "apiConfiguration",
169+
apiConfiguration: {
170+
apiProvider: "pearai",
171+
pearaiBaseUrl: PEARAI_URL,
172+
},
173+
})
174+
}
165175
setShowWelcome(!hasKey)
166176
setDidHydrateState(true)
167177
break

0 commit comments

Comments
 (0)