diff --git a/packages/plugin-ext/src/common/plugin-api-rpc-model.ts b/packages/plugin-ext/src/common/plugin-api-rpc-model.ts index 658c34d950551..efd8f740ac913 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc-model.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc-model.ts @@ -660,6 +660,8 @@ export interface Comment { readonly contextValue?: string; readonly label?: string; readonly mode?: CommentMode; + /** Timestamp serialized as ISO date string via Date.prototype.toISOString */ + readonly timeStamp?: string; } export enum CommentThreadCollapsibleState { diff --git a/packages/plugin-ext/src/main/browser/comments/comment-thread-widget.tsx b/packages/plugin-ext/src/main/browser/comments/comment-thread-widget.tsx index c8e205dd4283a..212ca1a44cf48 100644 --- a/packages/plugin-ext/src/main/browser/comments/comment-thread-widget.tsx +++ b/packages/plugin-ext/src/main/browser/comments/comment-thread-widget.tsx @@ -479,6 +479,7 @@ export class ReviewComment

{comment.userName} + {this.localeDate(comment.timeStamp)} {comment.label}
@@ -498,6 +499,16 @@ export class ReviewComment

; } + localeDate(stamp: string | undefined): string { + if (stamp === undefined) { + return ''; + } + const date = Date.parse(stamp); + if (date && !Number.isNaN(date)) { + return new Date(date).toLocaleString(); + } + return ''; + } } namespace CommentBody { diff --git a/packages/plugin-ext/src/main/browser/style/comments.css b/packages/plugin-ext/src/main/browser/style/comments.css index a167d08f2960b..265243a1fb6e9 100644 --- a/packages/plugin-ext/src/main/browser/style/comments.css +++ b/packages/plugin-ext/src/main/browser/style/comments.css @@ -149,6 +149,12 @@ line-height: var(--theia-content-line-height); } +.monaco-editor .review-widget .body .review-comment .review-comment-contents .timestamp { + line-height: var(--theia-content-line-height); + margin: 0 5px 0 5px; + padding: 0 2px 0 2px; +} + .monaco-editor .review-widget .body .review-comment .review-comment-contents .isPending { margin: 0 5px 0 5px; padding: 0 2px 0 2px; diff --git a/packages/plugin-ext/src/plugin/comments.ts b/packages/plugin-ext/src/plugin/comments.ts index efa1e1da3245f..4f4c1f3220802 100644 --- a/packages/plugin-ext/src/plugin/comments.ts +++ b/packages/plugin-ext/src/plugin/comments.ts @@ -491,6 +491,7 @@ function convertToModeComment(thread: ExtHostCommentThread, commentController: C } const iconPath = theiaComment.author && theiaComment.author.iconPath ? theiaComment.author.iconPath.toString() : undefined; + const date = theiaComment.timeStamp ? theiaComment.timeStamp.toISOString() : undefined; return { mode: theiaComment.mode, @@ -500,6 +501,7 @@ function convertToModeComment(thread: ExtHostCommentThread, commentController: C userName: theiaComment.author.name, userIconPath: iconPath, label: theiaComment.label, + timeStamp: date, }; } diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 869976cc8b36e..4141da0f5a67f 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -12084,6 +12084,11 @@ export module '@theia/plugin' { * Label will be rendered next to authorName if exists. */ label?: string; + + /** + * Optional timestamp. + */ + timeStamp?: Date; } /**