Skip to content

Commit c0d7bb7

Browse files
committed
Update commit symbol preview handling and formatting
- clicking on #CommitMessage symbol results in [Pasted text] - #CommitMessage symbol should place the message in code block not dividers ├── apps │ └── editor │ └── src │ └── views │ ├── prompt │ │ ├── backend │ │ │ ├── message-handlers │ │ │ │ ├── handle-preview-commit-symbol.ts │ │ │ │ └── index.ts │ │ │ ├── prompt-view-provider.ts │ │ │ └── utils │ │ │ ├── preview-text-in-temp-file.ts │ │ │ └── symbols │ │ │ ├── git │ │ │ │ └── replace-git-symbols.ts │ │ │ └── replace-symbols.ts │ │ ├── frontend │ │ │ ├── Main │ │ │ │ ├── Main.tsx │ │ │ │ └── MainView │ │ │ │ └── MainView.tsx │ │ │ └── hooks │ │ │ └── use-prompt │ │ │ └── use-prompt.ts │ │ └── types │ │ └── messages.ts │ └── shared │ └── utils │ └── hash-sign-quick-pick │ └── symbols │ └── commit-symbol.ts └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.tsx │ └── hooks │ └── use-handlers │ └── handle-input-click.ts └── shared └── symbols └── get-highlighted-text.tsx
1 parent 238b55f commit c0d7bb7

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎apps/editor/src/views/prompt/backend/message-handlers/handle-preview-commit-symbol.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ export const handle_preview_commit_symbol = async (message: {
1313
? ` "${message.commit_message.replace(/"/g, '\\"')}"`
1414
: ''
1515
const instruction = `#${message.type}(${message.repo_name}:${message.commit_hash}${message_escaped})`
16-
const { commit_definitions } = await replace_commit_symbol({
16+
const { commit_definitions, instructions } = await replace_commit_symbol({
1717
instructions: [instruction]
1818
})
1919

20-
if (commit_definitions) {
20+
const preview_content =
21+
message.type === 'CommitMessage'
22+
? instructions[0].trim()
23+
: commit_definitions.trim()
24+
25+
if (preview_content) {
2126
await preview_text_in_temp_file({
2227
prefix: 'cwc-commit',
23-
content: commit_definitions.trim(),
28+
content: preview_content,
2429
extension: '.md'
2530
})
2631
} else {

‎apps/editor/src/views/prompt/backend/utils/symbols/git/replace-git-symbols.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,11 +697,12 @@ export const replace_commit_symbol = async (params: {
697697
diff,
698698
commit_hash,
699699
path_prefix: workspace_folders.length > 1 ? folder_name : undefined,
700-
commit_message: symbol_type === 'CommitDiff' ? undefined : commit_message_body
700+
commit_message:
701+
symbol_type === 'CommitDiff' ? undefined : commit_message_body
701702
})
702703
} else {
703704
if (commit_message_body) {
704-
replacement_text = `---\n\n${commit_message_body}\n\n---\n\n`
705+
replacement_text = `\`\`\`\n${commit_message_body}\n\`\`\`\n\n`
705706
}
706707
}
707708

‎packages/ui/src/components/editor/common/prompts/shared/symbols/prompt-symbols.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
line-height: 1.2;
1212
transform: translateY(1.5px);
1313
max-width: 100%;
14-
padding-bottom: 1px;
1514

1615
&__icon {
1716
display: flex;
@@ -49,6 +48,7 @@
4948
padding-right: 4px;
5049
padding-left: 4px;
5150
margin-left: -4px;
51+
padding-bottom: 1px;
5252
}
5353

5454
&--file &__icon::before {

0 commit comments

Comments
 (0)