Skip to content

Commit 66d3fd8

Browse files
committed
actually working editable query!!
1 parent 7cbd93a commit 66d3fd8

File tree

14 files changed

+1332
-158
lines changed

14 files changed

+1332
-158
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>AI Shell Plugin</title>
7-
<style id="injected-style"></style>
7+
<style id="app-theme"></style>
88
</head>
99
<body>
1010
<div id="app"></div>

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@
2020
"@ai-sdk/google": "^2.0.18",
2121
"@ai-sdk/openai": "^2.0.46",
2222
"@ai-sdk/openai-compatible": "^1.0.20",
23-
"@ai-sdk/vue": "^2.0.62",
23+
"@ai-sdk/vue": "^2.0.106",
2424
"@beekeeperstudio/plugin": "^1.4.0",
25+
"@beekeeperstudio/ui-kit": "link:/home/azmy60/dev/beekeeper-studio/apps/ui-kit",
2526
"@langchain/core": "^0.3.61",
2627
"@material-symbols/font-400": "^0.31.2",
27-
"ai": "^5.0.101",
2828
"@pdanpdan/vue-keyboard-trap": "^1.2.0",
29+
"ai": "^5.0.101",
2930
"highlight.js": "^11.11.1",
3031
"langchain": "^0.3.19",
3132
"lodash": "^4.17.21",
3233
"marked": "^15.0.12",
3334
"marked-highlight": "^2.2.1",
35+
"mitt": "^3.0.1",
3436
"ollama-ai-provider-v2": "^1.3.1",
3537
"pinia": "^3.0.2",
3638
"pluralize": "^8.0.0",
@@ -49,6 +51,7 @@
4951
"happy-dom": "^18.0.1",
5052
"sass": "^1.87.0",
5153
"vite": "^6.2.3",
54+
"vite-plugin-vue-devtools": "^8.0.5",
5255
"vitest": "^3.2.4",
5356
"vitest-browser-vue": "^1.1.0"
5457
}

src/App.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<h1>AI Shell</h1>
55
<div class="progress-bar"></div>
66
</div>
7-
<ChatInterface v-if="page === 'chat-interface'" :initialMessages="messages" :openaiApiKey="openaiApiKey"
8-
:anthropicApiKey="anthropicApiKey" :googleApiKey="googleApiKey" @manage-models="handleManageModels"
7+
<ChatInterface v-if="page === 'chat-interface'" :initialMessages="messages" @manage-models="handleManageModels"
98
@open-configuration="handleOpenConfiguration" />
109
<Configuration v-model:visible="showConfiguration" :reactivePage="configurationPage" @close="closeConfiguration" />
1110
<div class="onboarding-screen-popover-container" v-if="showOnboarding">
1211
<div class="onboarding-screen-popover" v-kbd-trap="true">
1312
<button class="btn close-btn" @click="closeOnboardingScreen">
1413
<span class="material-symbols-outlined">close</span>
1514
</button>
16-
<OnboardingScreen @submit="closeOnboardingScreen" @open-provider-config="closeOnboardingScreenAndOpenProviderConfig" />
15+
<OnboardingScreen @submit="closeOnboardingScreen"
16+
@open-provider-config="closeOnboardingScreenAndOpenProviderConfig" />
1717
</div>
1818
</div>
1919
</div>

src/assets/styles/components/_message.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115

116116
.tool {
117117
.tool-error {
118-
margin-top: 0.5rem;
119118
color: var(--brand-danger);
120119
}
121120

@@ -145,7 +144,7 @@
145144
flex-direction: column;
146145

147146
.tool-name {
148-
margin-bottom: 0.25rem;
147+
margin-bottom: 0.5rem;
149148
}
150149

151150
.no-rows {

src/assets/styles/main.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@use "sass:color";
66
@use "primevue";
77

8+
@import "@beekeeperstudio/ui-kit/style.css" layer(ui-kit);
9+
810
#app {
911
height: 100%;
1012
display: flex;

src/assets/styles/pages/_chat-interface.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
padding: 0.5rem;
164164
width: 100%;
165165
line-height: 1.07rem;
166-
font-size: 0.765rem;
166+
font-size: 0.865rem;
167167

168168
code {
169169

@@ -407,17 +407,19 @@
407407
.tool-permission-buttons {
408408
display: flex;
409409
gap: 0.5rem;
410-
margin-top: 0.2rem;
410+
margin-top: 0.5rem;
411411

412412
button {
413413
border: none;
414-
background-color: transparent;
415414
cursor: pointer;
416415
display: flex;
417416
align-items: center;
418417
justify-content: center;
419-
color: currentColor;
420-
padding: 0;
418+
min-width: 0;
419+
420+
.accept-icon, .reject-icon {
421+
font-size: 1.2em;
422+
}
421423

422424
&:hover {
423425
.accept-icon {

src/components/ChatInterface.vue

Lines changed: 29 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<template>
2-
<div
3-
class="chat-container"
4-
:class="{ 'empty-chat': messages.length === 0 }"
5-
:data-status="status"
6-
>
2+
<div class="chat-container" :class="{ 'empty-chat': messages.length === 0 }" :data-status="status">
73
<div class="scroll-container" ref="scrollContainerRef">
84
<div class="header">
95
<button class="btn btn-flat-2 settings-btn" @click="$emit('open-configuration')">
@@ -13,31 +9,20 @@
139
</div>
1410
<h1 class="plugin-title">AI Shell</h1>
1511
<div class="chat-messages">
16-
<message
17-
v-for="(message, index) in messages"
18-
:key="message.id"
19-
:message="message"
12+
<message v-for="(message, index) in messages" :key="message.id" :message="message"
2013
:pending-tool-call-ids="pendingToolCallIds"
2114
:status="index === messages.length - 1 ? (status === 'ready' || status === 'error' ? 'ready' : 'processing') : 'ready'"
22-
@accept-permission="acceptPermission"
23-
@reject-permission="rejectPermission"
24-
/>
25-
<div
26-
class="message error"
27-
v-if="isUnexpectedError"
28-
>
15+
@accept-permission="acceptPermission" @reject-permission="handleRejectPermission" />
16+
<div class="message error" v-if="isUnexpectedError">
2917
<div class="message-content">
3018
Something went wrong.
3119
<div v-if="isOllamaToolError" class="error-hint">
32-
💡 <strong>Hint:</strong> This might be because your Ollama model doesn't support tools. Try using a different model, or switch to a different provider.
20+
💡 <strong>Hint:</strong> This might be because your Ollama model doesn't support tools. Try using a
21+
different model, or switch to a different provider.
3322
</div>
3423
<pre v-if="!isErrorTruncated || showFullError" v-text="error" />
3524
<pre v-else v-text="truncatedError" />
36-
<button
37-
v-if="isErrorTruncated"
38-
@click="showFullError = !showFullError"
39-
class="btn show-more-btn"
40-
>
25+
<button v-if="isErrorTruncated" @click="showFullError = !showFullError" class="btn show-more-btn">
4126
{{ showFullError ? "Show less" : "Show more" }}
4227
</button>
4328
<button class="btn" @click="() => reload()">
@@ -46,31 +31,21 @@
4631
</button>
4732
</div>
4833
</div>
49-
<div
50-
class="message error"
51-
v-if="noModelError"
52-
>
34+
<div class="message error" v-if="noModelError">
5335
<div class="message-content">No model selected</div>
5436
</div>
55-
<div
56-
class="spinner-container"
57-
:style="{ visibility: showSpinner ? 'visible' : 'hidden' }"
58-
>
37+
<div class="spinner-container" :style="{ visibility: showSpinner ? 'visible' : 'hidden' }">
5938
<span class="spinner" />
6039
</div>
6140
</div>
62-
<button
63-
v-if="!isAtBottom"
64-
@click="scrollToBottom({ smooth: true })"
65-
class="btn scroll-down-btn"
66-
title="Scroll to bottom"
67-
>
41+
<button v-if="!isAtBottom" @click="scrollToBottom({ smooth: true })" class="btn scroll-down-btn"
42+
title="Scroll to bottom">
6843
<span class="material-symbols-outlined">keyboard_arrow_down</span>
6944
</button>
7045
</div>
7146
<div class="chat-input-container-container">
7247
<PromptInput ref="promptInput" storage-key="inputHistory" :processing="processing" :selected-model="model"
73-
@select-model="selectModel" @manage-models="$emit('manage-models')" @submit="submit" @stop="stop" />
48+
@select-model="selectModel" @manage-models="$emit('manage-models')" @submit="submit" @stop="stop" />
7449
</div>
7550
</div>
7651
</template>
@@ -81,9 +56,9 @@ import { useChatStore, Model } from "@/stores/chat";
8156
import _ from "lodash";
8257
import Markdown from "@/components/messages/Markdown.vue";
8358
import Message from "@/components/messages/Message.vue";
84-
import { Message as MessageType } from "ai";
59+
import type { UIMessage } from "ai";
8560
import { PropType } from "vue";
86-
import { mapActions, mapGetters, mapState, mapWritableState } from "pinia";
61+
import { mapActions, mapGetters, mapWritableState } from "pinia";
8762
import { RootBinding } from "@/plugins/appEvent";
8863
import { useInternalDataStore } from "@/stores/internalData";
8964
import BaseInput from "@/components/common/BaseInput.vue";
@@ -103,12 +78,9 @@ export default {
10378
10479
props: {
10580
initialMessages: {
106-
type: Array as PropType<MessageType[]>,
81+
type: Array as PropType<UIMessage[]>,
10782
required: true,
10883
},
109-
anthropicApiKey: String,
110-
openaiApiKey: String,
111-
googleApiKey: String,
11284
},
11385
11486
setup(props) {
@@ -137,7 +109,7 @@ export default {
137109
},
138110
139111
computed: {
140-
...mapGetters(useChatStore, ["systemPrompt"]),
112+
...mapGetters(useChatStore, ["systemPrompt", "sendOptions"]),
141113
...mapWritableState(useChatStore, ["model"]),
142114
processing() {
143115
if (this.askingPermission) return false;
@@ -219,8 +191,8 @@ export default {
219191
// Calculate if we're near bottom (within 50px of bottom)
220192
const isNearBottom =
221193
scrollContainer.scrollHeight -
222-
scrollContainer.scrollTop -
223-
scrollContainer.clientHeight <
194+
scrollContainer.scrollTop -
195+
scrollContainer.clientHeight <
224196
50;
225197
226198
this.isAtBottom = isNearBottom;
@@ -246,11 +218,11 @@ export default {
246218
this.rejectPermission();
247219
}
248220
249-
this.send(input, this.getSendOptions());
221+
this.send(input, this.sendOptions);
250222
},
251223
252224
async reload() {
253-
await this.retry(this.getSendOptions());
225+
await this.retry(this.sendOptions);
254226
},
255227
256228
stop() {
@@ -281,17 +253,15 @@ export default {
281253
this.model = model;
282254
},
283255
284-
getSendOptions() {
285-
if (!this.model) {
286-
throw new Error("No model selected");
287-
}
288-
289-
return {
290-
modelId: this.model.id,
291-
providerId: this.model.provider,
292-
systemPrompt: this.systemPrompt,
293-
}
294-
}
256+
handleRejectPermission(options: {
257+
toolCallId: string;
258+
userEdittedCode?: string;
259+
}) {
260+
this.rejectPermission({
261+
...options,
262+
sendOptions: this.sendOptions,
263+
});
264+
},
295265
},
296266
};
297267
</script>

src/components/messages/Message.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
:toolCall="part"
1313
:askingPermission="pendingToolCallIds.includes(part.toolCallId)"
1414
@accept="$emit('accept-permission', part.toolCallId)"
15-
@reject="$emit('reject-permission', part.toolCallId)"
15+
@reject="$emit('reject-permission', {
16+
toolCallId: part.toolCallId,
17+
...$event,
18+
})"
1619
/>
1720
</template>
1821
<span v-if="isEmpty">

0 commit comments

Comments
 (0)