Skip to content

Commit 47405d5

Browse files
committed
Move feedback invitation to the top of the page
1 parent 3262625 commit 47405d5

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/commands/explainBase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export abstract class ExplainCommandBase extends GlCommandBase {
5656
}
5757

5858
protected openDocument(result: AISummarizeResult, path: string, metadata: MarkdownContentMetadata): void {
59-
const content = `${getMarkdownHeaderContent(metadata)}\n\n${result.parsed.summary}\n\n${result.parsed.body}`;
59+
const headerContent = getMarkdownHeaderContent(metadata, this.container.telemetry.enabled);
60+
const content = `${headerContent}\n\n${result.parsed.summary}\n\n${result.parsed.body}`;
6061

6162
const documentUri = this.container.markdown.openDocument(content, path, metadata.header.title, metadata);
6263

src/commands/generateRebase.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,10 @@ export async function generateRebase(
361361
usage: result.usage,
362362
outputLength: result.content?.length,
363363
};
364+
const telemetryEnabled = container.telemetry.enabled;
364365

365366
// Generate the markdown content that shows each commit and its diffs
366-
const { content, metadata } = generateRebaseMarkdown(
367-
result,
368-
title,
369-
feedbackContext,
370-
container.telemetry.enabled,
371-
);
367+
const { content, metadata } = generateRebaseMarkdown(result, title, telemetryEnabled, feedbackContext);
372368

373369
let generateType: 'commits' | 'rebase' = 'rebase';
374370
let headRefSlug = head.ref;
@@ -540,8 +536,8 @@ export function extractRebaseDiffInfo(
540536
function generateRebaseMarkdown(
541537
result: AIRebaseResult,
542538
title = 'Rebase Commits',
539+
telemetryEnabled: boolean,
543540
feedbackContext?: AIFeedbackContext,
544-
telemetryEnabled?: boolean,
545541
): { content: string; metadata: MarkdownContentMetadata } {
546542
const metadata: MarkdownContentMetadata = {
547543
header: {
@@ -560,7 +556,10 @@ function generateRebaseMarkdown(
560556
if (result.commits.length === 0) {
561557
markdown = 'No Commits Generated';
562558

563-
return { content: `${getMarkdownHeaderContent(metadata)}\n\n${markdown}`, metadata: metadata };
559+
return {
560+
content: `${getMarkdownHeaderContent(metadata, telemetryEnabled)}\n\n${markdown}`,
561+
metadata: metadata,
562+
};
564563
}
565564
const { commits, diff: originalDiff, hunkMap } = result;
566565

@@ -624,17 +623,10 @@ function generateRebaseMarkdown(
624623
markdown += explanations;
625624
markdown += changes;
626625

627-
// Add feedback note if context is provided and telemetry is enabled
628-
if (feedbackContext && telemetryEnabled) {
629-
markdown += '\n\n---\n\n## Feedback\n\n';
630-
markdown += 'Use the 👍 and 👎 buttons in the editor toolbar to provide feedback on this AI response.\n\n';
631-
markdown += '*Your feedback helps us improve our AI features.*';
632-
}
633-
634626
// markdown += `\n\n----\n\n## Raw commits\n\n\`\`\`${escapeMarkdownCodeBlocks(JSON.stringify(commits))}\`\`\``;
635627
// markdown += `\n\n----\n\n## Original Diff\n\n\`\`\`${escapeMarkdownCodeBlocks(originalDiff)}\`\`\`\n`;
636628

637-
return { content: `${getMarkdownHeaderContent(metadata)}\n\n${markdown}`, metadata: metadata };
629+
return { content: `${getMarkdownHeaderContent(metadata, telemetryEnabled)}\n\n${markdown}`, metadata: metadata };
638630
}
639631

640632
/**

src/container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class Container {
222222
this._disposables.push((this._vsls = new VslsController(this)));
223223
this._disposables.push((this._eventBus = new EventBus()));
224224
this._disposables.push((this._launchpadProvider = new LaunchpadProvider(this)));
225-
this._disposables.push((this._markdownProvider = new MarkdownContentProvider()));
225+
this._disposables.push((this._markdownProvider = new MarkdownContentProvider(this)));
226226

227227
this._disposables.push((this._fileAnnotationController = new FileAnnotationController(this)));
228228
this._disposables.push((this._lineAnnotationController = new LineAnnotationController(this)));

src/documents/markdown.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Disposable, Event, TextDocumentContentProvider } from 'vscode';
22
import { EventEmitter, Uri, workspace } from 'vscode';
33
import { Schemes } from '../constants';
44
import type { GlCommands } from '../constants.commands';
5+
import type { Container } from '../container';
56
import { decodeGitLensRevisionUriAuthority, encodeGitLensRevisionUriAuthority } from '../git/gitUri.authority';
67

78
// gitlens-markdown:{explain}/{entity}/{entityID}/{model}[{/friendlyName}].md
@@ -29,7 +30,7 @@ export class MarkdownContentProvider implements TextDocumentContentProvider {
2930
return this._onDidChange.event;
3031
}
3132

32-
constructor() {
33+
constructor(private container: Container) {
3334
this.registration = workspace.registerTextDocumentContentProvider(Schemes.GitLensMarkdown, this);
3435

3536
workspace.onDidCloseTextDocument(document => {
@@ -43,7 +44,7 @@ export class MarkdownContentProvider implements TextDocumentContentProvider {
4344
let contents = this.contents.get(uri.toString());
4445
if (contents != null) return contents;
4546

46-
contents = getContentFromMarkdownUri(uri);
47+
contents = getContentFromMarkdownUri(uri, this.container.telemetry.enabled);
4748
if (contents != null) return contents;
4849

4950
return `# ${uri.path}\n\nNo content available.`;
@@ -87,7 +88,7 @@ export class MarkdownContentProvider implements TextDocumentContentProvider {
8788
}
8889
}
8990

90-
function getContentFromMarkdownUri(uri: Uri): string | undefined {
91+
function getContentFromMarkdownUri(uri: Uri, telemetryEnabled: boolean): string | undefined {
9192
if (!uri.path.startsWith('/explain')) return undefined;
9293

9394
const authority = uri.authority;
@@ -97,7 +98,7 @@ function getContentFromMarkdownUri(uri: Uri): string | undefined {
9798

9899
if (metadata.header == null) return undefined;
99100

100-
const headerContent = getMarkdownHeaderContent(metadata);
101+
const headerContent = getMarkdownHeaderContent(metadata, telemetryEnabled);
101102

102103
if (metadata.command == null) return `${headerContent}\n\nNo content available.`;
103104

@@ -106,11 +107,19 @@ function getContentFromMarkdownUri(uri: Uri): string | undefined {
106107
return `${headerContent}\n\n${commandContent}`;
107108
}
108109

109-
export function getMarkdownHeaderContent(metadata: MarkdownContentMetadata): string {
110+
export function getMarkdownHeaderContent(metadata: MarkdownContentMetadata, telemetryEnabled: boolean): string {
110111
let headerContent = `# ${metadata.header.title}`;
111112
if (metadata.header.aiModel != null) {
112113
headerContent += `\n\n> Generated by ${metadata.header.aiModel}`;
113114
}
115+
116+
// Add feedback note if context is provided and telemetry is enabled
117+
if (metadata.feedbackContext != null && telemetryEnabled) {
118+
headerContent += '\n\n';
119+
headerContent += 'Use the 👍 and 👎 buttons in the editor toolbar to provide feedback on this AI response. ';
120+
headerContent += '*Your feedback helps us improve our AI features.*';
121+
}
122+
114123
if (metadata.header.subtitle != null) {
115124
headerContent += `\n\n## ${metadata.header.subtitle}`;
116125
}

0 commit comments

Comments
 (0)