Skip to content

Commit 0548ee4

Browse files
committed
Refactor ApiToolHeader to ApiTool component and migrate commit message setting key
1 parent 107a6ad commit 0548ee4

17 files changed

Lines changed: 241 additions & 62 deletions

File tree

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
<br/>
1212
👉 Generate meaningful commit messages
1313
</h4>
14-
15-
<a href="https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder"><img src="https://img.shields.io/badge/Download-VS_Code_Marketplace-blue" alt="Download from Visual Studio Code Marketplace"></a>
16-
<a href="https://x.com/CodeWebChat"><img src="https://img.shields.io/badge/Follow-@CodeWebChat-black?logo=x" alt="X"></a>
17-
<a href="https://www.reddit.com/r/CodeWebChat"><img src="https://img.shields.io/badge/Join_subreddit-r%2FCodeWebChat-orange?logo=reddit&logoColor=white" alt="Join subreddit r/CodeWebChat on Reddit"></a>
18-
<br/>
19-
14+
<a href="https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder"><img src="https://img.shields.io/badge/Download-VS_Code_Marketplace-blue" alt="Download from Visual Studio Code Marketplace"></a>
15+
<a href="https://x.com/CodeWebChat"><img src="https://img.shields.io/badge/Follow-@CodeWebChat-black?logo=x" alt="X"></a>
16+
<a href="https://www.reddit.com/r/CodeWebChat"><img src="https://img.shields.io/badge/Join_subreddit-r%2FCodeWebChat-orange?logo=reddit&logoColor=white" alt="Join subreddit r/CodeWebChat on Reddit"></a>
17+
<br/>
2018
</div>
2119

2220
<a href="https://codeweb.chat/">Documentation</a>

packages/ui/src/components/editor/ApiToolHeader/ApiToolHeader.module.scss renamed to packages/ui/src/components/editor/ApiTool/ApiTool.module.scss

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
.header {
1+
.container {
22
display: flex;
33
flex-direction: column;
44
overflow: hidden;
5+
gap: var(--padding-6px);
6+
}
7+
8+
.header {
9+
display: flex;
10+
flex-direction: column;
11+
gap: var(--padding-2px);
512

613
&__top {
714
display: flex;
@@ -32,13 +39,37 @@
3239
&__bottom {
3340
font-size: 16px;
3441
font-weight: bold;
35-
padding: 2px 0 6px 0;
3642
text-align: center;
3743
color: var(--vscode-editor-foreground);
3844
}
45+
}
3946

40-
&__description {
41-
font-size: 12px;
42-
color: var(--vscode-editor-foreground);
47+
.description {
48+
font-size: var(--font-size-12px);
49+
color: var(--vscode-editor-foreground);
50+
51+
&__toggle {
52+
color: var(--vscode-textLink-foreground);
53+
padding-left: 4px;
54+
font-size: var(--font-size-12px);
55+
56+
&:hover {
57+
color: var(--vscode-textLink-activeForeground);
58+
}
59+
}
60+
}
61+
62+
.checkmarks {
63+
display: flex;
64+
flex-direction: column;
65+
gap: var(--padding-2px);
66+
67+
&__item {
68+
display: flex;
69+
gap: var(--padding-5px);
70+
71+
> span {
72+
font-size: var(--font-size-12px) !important;
73+
}
4374
}
4475
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ApiTool } from './ApiTool'
2+
3+
export default {
4+
component: ApiTool
5+
}
6+
7+
export const Default = () => (
8+
<ApiTool
9+
top_line="API TOOL"
10+
bottom_line="Code Completions"
11+
description="Use any model for accurate code completions. The tool attaches selected context in each request."
12+
checkmarks={[
13+
'Uses selected context',
14+
'Supports any model',
15+
'Accurate completions'
16+
]}
17+
/>
18+
)
19+
20+
export const LongDescription = () => (
21+
<ApiTool
22+
top_line="API TOOL"
23+
bottom_line="Advanced Code Analysis"
24+
description="This is a very long description that exceeds 100 characters and should be truncated with a Read more/Read less toggle functionality to improve the user experience and prevent overwhelming the interface with too much text at once."
25+
checkmarks={[
26+
'Advanced analysis capabilities',
27+
'Multi-language support',
28+
'Real-time feedback'
29+
]}
30+
/>
31+
)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React, { useState } from 'react'
2+
import styles from './ApiTool.module.scss'
3+
4+
type Props = {
5+
top_line: string
6+
bottom_line: string
7+
description: string
8+
checkmarks?: string[]
9+
}
10+
11+
const MAX_INIT_LENGTH = 120
12+
13+
export const ApiTool: React.FC<Props> = (props) => {
14+
const [is_expanded, set_is_expanded] = useState(false)
15+
const should_truncate = props.description.length > MAX_INIT_LENGTH
16+
17+
const displayDescription =
18+
should_truncate && !is_expanded
19+
? `${props.description.slice(0, MAX_INIT_LENGTH)}...`
20+
: props.description
21+
22+
return (
23+
<div className={styles.container}>
24+
<div className={styles.header}>
25+
<div className={styles.header__top}>
26+
<span>{props.top_line}</span>
27+
</div>
28+
<div className={styles.header__bottom}>{props.bottom_line}</div>
29+
</div>
30+
31+
<div className={styles.description}>
32+
{displayDescription}
33+
{should_truncate && (
34+
<button
35+
className={styles.description__toggle}
36+
onClick={() => set_is_expanded(!is_expanded)}
37+
>
38+
{is_expanded ? 'Read less' : 'Read more'}
39+
</button>
40+
)}
41+
</div>
42+
43+
{props.checkmarks && (
44+
<div className={styles.checkmarks}>
45+
{props.checkmarks.map((checkmark, index) => (
46+
<div key={index} className={styles.checkmarks__item}>
47+
<span className="codicon codicon-check" />
48+
<span>{checkmark}</span>
49+
</div>
50+
))}
51+
</div>
52+
)}
53+
</div>
54+
)
55+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ApiTool'

packages/ui/src/components/editor/ApiToolHeader/ApiToolHeader.stories.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/ui/src/components/editor/ApiToolHeader/ApiToolHeader.tsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/ui/src/components/editor/ApiToolHeader/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,10 @@
608608
"type": "object",
609609
"title": "Code Web Chat Settings",
610610
"properties": {
611-
"codeWebChat.commitMessagePrompt": {
611+
"codeWebChat.commitMessageInstructions": {
612612
"type": "string",
613613
"scope": "resource",
614-
"description": "The prompt text used when generating commit messages.",
614+
"description": "The instructions used when generating a commit message.",
615615
"default": "Write a brief and precise summary for the following diff, limited to a single sentence if possible and nothing else. Use an imperative tone to ensure clarity and focus on the primary change or purpose."
616616
},
617617
"codeWebChat.ignoredExtensions": {

packages/vscode/src/commands/generate-commit-message-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function generate_commit_message_command(
6161
}
6262

6363
const config = vscode.workspace.getConfiguration('codeWebChat')
64-
const commit_message_prompt = config.get<string>('commitMessagePrompt')
64+
const commit_message_prompt = config.get<string>('commitMessageInstructions')
6565
const config_ignored_extensions = new Set(
6666
config
6767
.get<string[]>('ignoredExtensions', [])

0 commit comments

Comments
 (0)