Skip to content

Commit 329152f

Browse files
authored
Merge branch 'main' into copyMyFix
2 parents 5f144e6 + 92476dd commit 329152f

27 files changed

+791
-540
lines changed

.github/workflows/commit.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ jobs:
1717
- name: Checkout the code
1818
uses: actions/checkout@v3
1919

20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20'
2024
- name: Get the latest commit hash
21-
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
22-
25+
run: |
26+
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
27+
echo "CURRENT_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
28+
2329
- name: Update commit file
2430
run: |
25-
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
31+
echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
2632
2733
- name: Commit and push the update
2834
run: |

.github/workflows/update-stable.yml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,7 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
update-commit:
13-
if: contains(github.event.head_commit.message, '#release')
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Checkout the code
18-
uses: actions/checkout@v3
19-
20-
- name: Get the latest commit hash
21-
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
22-
23-
- name: Update commit file
24-
run: |
25-
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
26-
27-
- name: Commit and push the update
28-
run: |
29-
git config --global user.name "github-actions[bot]"
30-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
31-
git add app/commit.json
32-
git commit -m "chore: update commit hash to $COMMIT_HASH"
33-
git push
3412
prepare-release:
35-
needs: update-commit
3613
if: contains(github.event.head_commit.message, '#release')
3714
runs-on: ubuntu-latest
3815

@@ -181,10 +158,16 @@ jobs:
181158
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
182159
echo "EOF" >> $GITHUB_OUTPUT
183160
161+
- name: Get the latest commit hash and version tag
162+
run: |
163+
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
164+
echo "CURRENT_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
165+
184166
- name: Commit and Tag Release
185167
run: |
186168
git pull
187-
git add package.json pnpm-lock.yaml changelog.md
169+
echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
170+
git add package.json pnpm-lock.yaml changelog.md app/commit.json
188171
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
189172
git tag "v${{ steps.bump_version.outputs.new_version }}"
190173
git push

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ https://thinktank.ottomator.ai
4343
- ✅ Mobile friendly (@qwikode)
4444
- ✅ Better prompt enhancing (@SujalXplores)
4545
- ✅ Attach images to prompts (@atrokhym)
46+
- ✅ Added Git Clone button (@thecodacus)
47+
- ✅ Git Import from url (@thecodacus)
48+
- ✅ PromptLibrary to have different variations of prompts for different use cases (@thecodacus)
4649
- ✅ Detect package.json and commands to auto install & run preview for folder and git import (@wonderwhy-er)
4750
- ✅ Selection tool to target changes visually (@emcconnell)
4851
-**HIGH PRIORITY** - Prevent bolt from rewriting files as often (file locking and diffs)

app/components/chat/AssistantMessage.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
import { memo } from 'react';
22
import { Markdown } from './Markdown';
3+
import type { JSONValue } from 'ai';
34

45
interface AssistantMessageProps {
56
content: string;
7+
annotations?: JSONValue[];
68
}
79

8-
export const AssistantMessage = memo(({ content }: AssistantMessageProps) => {
10+
export const AssistantMessage = memo(({ content, annotations }: AssistantMessageProps) => {
11+
const filteredAnnotations = (annotations?.filter(
12+
(annotation: JSONValue) => annotation && typeof annotation === 'object' && Object.keys(annotation).includes('type'),
13+
) || []) as { type: string; value: any }[];
14+
15+
const usage: {
16+
completionTokens: number;
17+
promptTokens: number;
18+
totalTokens: number;
19+
} = filteredAnnotations.find((annotation) => annotation.type === 'usage')?.value;
20+
921
return (
1022
<div className="overflow-hidden w-full">
23+
{usage && (
24+
<div className="text-sm text-bolt-elements-textSecondary mb-2">
25+
Tokens: {usage.totalTokens} (prompt: {usage.promptTokens}, completion: {usage.completionTokens})
26+
</div>
27+
)}
1128
<Markdown html>{content}</Markdown>
1229
</div>
1330
);

app/components/chat/BaseChat.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
7777
input = '',
7878
enhancingPrompt,
7979
handleInputChange,
80-
promptEnhanced,
80+
81+
// promptEnhanced,
8182
enhancePrompt,
8283
sendMessage,
8384
handleStop,
@@ -490,10 +491,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
490491
<IconButton
491492
title="Enhance prompt"
492493
disabled={input.length === 0 || enhancingPrompt}
493-
className={classNames(
494-
'transition-all',
495-
enhancingPrompt ? 'opacity-100' : '',
496-
)}
494+
className={classNames('transition-all', enhancingPrompt ? 'opacity-100' : '')}
497495
onClick={() => {
498496
enhancePrompt?.();
499497
toast.success('Prompt enhanced!');

app/components/chat/Chat.client.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const ChatImpl = memo(
9393
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]); // Move here
9494
const [imageDataList, setImageDataList] = useState<string[]>([]); // Move here
9595
const files = useStore(workbenchStore.files);
96-
const { activeProviders } = useSettings();
96+
const { activeProviders, promptId } = useSettings();
9797

9898
const [model, setModel] = useState(() => {
9999
const savedModel = Cookies.get('selectedModel');
@@ -115,14 +115,24 @@ export const ChatImpl = memo(
115115
body: {
116116
apiKeys,
117117
files,
118+
promptId,
118119
},
120+
sendExtraMessageFields: true,
119121
onError: (error) => {
120122
logger.error('Request failed\n\n', error);
121123
toast.error(
122124
'There was an error processing your request: ' + (error.message ? error.message : 'No details were returned'),
123125
);
124126
},
125-
onFinish: () => {
127+
onFinish: (message, response) => {
128+
const usage = response.usage;
129+
130+
if (usage) {
131+
console.log('Token usage:', usage);
132+
133+
// You can now use the usage data as needed
134+
}
135+
126136
logger.debug('Finished streaming');
127137
},
128138
initialMessages,

app/components/chat/Messages.client.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
6565
</div>
6666
)}
6767
<div className="grid grid-col-1 w-full">
68-
{isUserMessage ? <UserMessage content={content} /> : <AssistantMessage content={content} />}
68+
{isUserMessage ? (
69+
<UserMessage content={content} />
70+
) : (
71+
<AssistantMessage content={content} annotations={message.annotations} />
72+
)}
6973
</div>
7074
{!isUserMessage && (
7175
<div className="flex gap-2 flex-col lg:flex-row">
72-
<WithTooltip tooltip="Revert to this message">
73-
{messageId && (
76+
{messageId && (
77+
<WithTooltip tooltip="Revert to this message">
7478
<button
7579
onClick={() => handleRewind(messageId)}
7680
key="i-ph:arrow-u-up-left"
@@ -79,8 +83,8 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
7983
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
8084
)}
8185
/>
82-
)}
83-
</WithTooltip>
86+
</WithTooltip>
87+
)}
8488

8589
<WithTooltip tooltip="Fork chat from this message">
8690
<button

app/components/chat/UserMessage.tsx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,36 @@ interface UserMessageProps {
1212
export function UserMessage({ content }: UserMessageProps) {
1313
if (Array.isArray(content)) {
1414
const textItem = content.find((item) => item.type === 'text');
15-
const textContent = sanitizeUserMessage(textItem?.text || '');
15+
const textContent = stripMetadata(textItem?.text || '');
1616
const images = content.filter((item) => item.type === 'image' && item.image);
1717

1818
return (
1919
<div className="overflow-hidden pt-[4px]">
20-
<div className="flex items-start gap-4">
21-
<div className="flex-1">
22-
<Markdown limitedMarkdown>{textContent}</Markdown>
23-
</div>
24-
{images.length > 0 && (
25-
<div className="flex-shrink-0 w-[160px]">
26-
{images.map((item, index) => (
27-
<div key={index} className="relative">
28-
<img
29-
src={item.image}
30-
alt={`Uploaded image ${index + 1}`}
31-
className="w-full h-[160px] rounded-lg object-cover border border-bolt-elements-borderColor"
32-
/>
33-
</div>
34-
))}
35-
</div>
36-
)}
20+
<div className="flex flex-col gap-4">
21+
{textContent && <Markdown html>{textContent}</Markdown>}
22+
{images.map((item, index) => (
23+
<img
24+
key={index}
25+
src={item.image}
26+
alt={`Image ${index + 1}`}
27+
className="max-w-full h-auto rounded-lg"
28+
style={{ maxHeight: '512px', objectFit: 'contain' }}
29+
/>
30+
))}
3731
</div>
3832
</div>
3933
);
4034
}
4135

42-
const textContent = sanitizeUserMessage(content);
36+
const textContent = stripMetadata(content);
4337

4438
return (
4539
<div className="overflow-hidden pt-[4px]">
46-
<Markdown limitedMarkdown>{textContent}</Markdown>
40+
<Markdown html>{textContent}</Markdown>
4741
</div>
4842
);
4943
}
5044

51-
function sanitizeUserMessage(content: string) {
45+
function stripMetadata(content: string) {
5246
return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '');
5347
}

app/components/settings/chat-history/ChatHistoryTab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export default function ChatHistoryTab() {
2222
};
2323

2424
const handleDeleteAllChats = async () => {
25-
const confirmDelete = window.confirm("Are you sure you want to delete all chats? This action cannot be undone.");
25+
const confirmDelete = window.confirm('Are you sure you want to delete all chats? This action cannot be undone.');
26+
2627
if (!confirmDelete) {
2728
return; // Exit if the user cancels
2829
}
@@ -31,11 +32,13 @@ export default function ChatHistoryTab() {
3132
const error = new Error('Database is not available');
3233
logStore.logError('Failed to delete chats - DB unavailable', error);
3334
toast.error('Database is not available');
35+
3436
return;
3537
}
3638

3739
try {
3840
setIsDeleting(true);
41+
3942
const allChats = await getAll(db);
4043
await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
4144
logStore.logSystem('All chats deleted successfully', { count: allChats.length });
@@ -55,6 +58,7 @@ export default function ChatHistoryTab() {
5558
const error = new Error('Database is not available');
5659
logStore.logError('Failed to export chats - DB unavailable', error);
5760
toast.error('Database is not available');
61+
5862
return;
5963
}
6064

0 commit comments

Comments
 (0)