Skip to content

Commit cb0e675

Browse files
authored
refactor: Update styles and improve component structure (#373)
* refactor: Update styles and improve component structure - Adjusted CSS styles for better layout and spacing in chat components. - Refactored ChatUserInput component to streamline rendering of mentionable badges. - Modified MCPManager to ensure subscribers are notified after cache invalidation. - Updated request type definitions to enforce properties in FunctionDescription. - Enhanced response generation to ensure parameters are correctly structured. * feat: Add settings callout for tool usage warnings - Introduced a new callout in the MCP settings section to inform users about potential costs associated with tool responses. - Updated CSS styles for the callout to enhance visibility and layout.
1 parent 88f3e28 commit cb0e675

File tree

6 files changed

+56
-42
lines changed

6 files changed

+56
-42
lines changed

src/components/chat-view/chat-input/ChatUserInput.tsx

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -202,43 +202,41 @@ const ChatUserInput = forwardRef<ChatUserInputRef, ChatUserInputProps>(
202202

203203
return (
204204
<div className="smtcmp-chat-user-input-container" ref={containerRef}>
205-
{mentionables.length > 0 && (
206-
<div className="smtcmp-chat-user-input-files">
207-
<ToolBadge />
208-
{mentionables.map((m) => (
209-
<MentionableBadge
210-
key={getMentionableKey(serializeMentionable(m))}
211-
mentionable={m}
212-
onDelete={() => handleMentionableDelete(m)}
213-
onClick={() => {
214-
const mentionableKey = getMentionableKey(
215-
serializeMentionable(m),
205+
<div className="smtcmp-chat-user-input-files">
206+
<ToolBadge />
207+
{mentionables.map((m) => (
208+
<MentionableBadge
209+
key={getMentionableKey(serializeMentionable(m))}
210+
mentionable={m}
211+
onDelete={() => handleMentionableDelete(m)}
212+
onClick={() => {
213+
const mentionableKey = getMentionableKey(
214+
serializeMentionable(m),
215+
)
216+
if (
217+
(m.type === 'current-file' ||
218+
m.type === 'file' ||
219+
m.type === 'block') &&
220+
m.file &&
221+
mentionableKey === displayedMentionableKey
222+
) {
223+
// open file on click again
224+
openMarkdownFile(
225+
app,
226+
m.file.path,
227+
m.type === 'block' ? m.startLine : undefined,
216228
)
217-
if (
218-
(m.type === 'current-file' ||
219-
m.type === 'file' ||
220-
m.type === 'block') &&
221-
m.file &&
222-
mentionableKey === displayedMentionableKey
223-
) {
224-
// open file on click again
225-
openMarkdownFile(
226-
app,
227-
m.file.path,
228-
m.type === 'block' ? m.startLine : undefined,
229-
)
230-
} else {
231-
setDisplayedMentionableKey(mentionableKey)
232-
}
233-
}}
234-
isFocused={
235-
getMentionableKey(serializeMentionable(m)) ===
236-
displayedMentionableKey
229+
} else {
230+
setDisplayedMentionableKey(mentionableKey)
237231
}
238-
/>
239-
))}
240-
</div>
241-
)}
232+
}}
233+
isFocused={
234+
getMentionableKey(serializeMentionable(m)) ===
235+
displayedMentionableKey
236+
}
237+
/>
238+
))}
239+
</div>
242240

243241
<MentionableContentPreview
244242
displayedMentionableKey={displayedMentionableKey}

src/components/settings/sections/McpSection.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ export function McpSection({ app, plugin }: McpSectionProps) {
5757
<div className="smtcmp-settings-section">
5858
<div className="smtcmp-settings-header">MCP (Model Context Pool)</div>
5959

60+
<div className="smtcmp-settings-desc smtcmp-settings-callout">
61+
<strong>Warning:</strong> When using tools, the tool response is passed
62+
to the language model (LLM). If the tool result contains a large amount
63+
of content, this can significantly increase LLM usage and associated
64+
costs. Please be mindful when enabling or using tools that may return
65+
long outputs.
66+
</div>
67+
6068
{mcpManager?.disabled ? (
6169
<div className="smtcmp-settings-sub-header-container">
6270
<div className="smtcmp-settings-sub-header">

src/core/mcp/mcpManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ export class McpManager {
172172
}
173173

174174
this.servers = nextServers
175-
this.notifySubscribers()
176175
this.availableToolsCache = null // Invalidate available tools cache
176+
this.notifySubscribers() // Should call after invalidating the cache
177177
}
178178

179179
private async connectServer(

src/types/llm/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ type FunctionDescription = {
106106
name: string
107107
parameters: {
108108
type: 'object'
109-
properties?: Record<string, unknown>
109+
properties: Record<string, unknown>
110110
}
111111
}

src/utils/chat/responseGenerator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ export class ResponseGenerator {
154154
function: {
155155
name: tool.name,
156156
description: tool.description,
157-
parameters: tool.inputSchema,
157+
parameters: {
158+
...tool.inputSchema,
159+
properties: tool.inputSchema.properties ?? {},
160+
},
158161
},
159162
}))
160163
: undefined

styles.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
display: flex;
33
justify-content: space-between;
44
align-items: center;
5-
margin-top: calc(var(--size-4-1) * -1);
5+
margin-bottom: var(--size-4-2);
66
}
77

88
.smtcmp-chat-header-title {
@@ -149,8 +149,8 @@ button:not(.clickable-icon).smtcmp-chat-list-dropdown {
149149
display: flex;
150150
flex-direction: column;
151151
gap: var(--size-4-1);
152-
padding: 0 var(--size-4-3) var(--size-4-5) var(--size-4-3);
153-
margin: var(--size-4-2) calc(var(--size-4-3) * -1) 0;
152+
padding: var(--size-4-1);
153+
margin: calc(var(--size-4-1) * -1);
154154

155155
.smtcmp-chat-messages-user {
156156
display: flex;
@@ -1187,6 +1187,12 @@ button.smtcmp-chat-input-model-select {
11871187
margin: var(--size-4-1) 0;
11881188
}
11891189

1190+
.smtcmp-settings-callout {
1191+
padding-inline-start: var(--size-4-2);
1192+
border-inline-start: var(--blockquote-border-thickness) solid
1193+
var(--blockquote-border-color);
1194+
}
1195+
11901196
.smtcmp-settings-required::after {
11911197
color: var(--color-red);
11921198
content: '*';
@@ -1499,7 +1505,6 @@ button.smtcmp-chat-input-model-select {
14991505
flex-direction: column;
15001506
align-items: stretch;
15011507
gap: var(--size-4-1);
1502-
background: var(--background-modifier-form-field);
15031508
padding: var(--size-4-1);
15041509
font-size: var(--font-ui-small);
15051510
}

0 commit comments

Comments
 (0)