mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
agent sessions - allow description during progress (#278765)
This commit is contained in:
@@ -164,15 +164,8 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
|
|||||||
|
|
||||||
private renderDescription(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
private renderDescription(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
||||||
|
|
||||||
// In progress: show duration
|
// Support description as string
|
||||||
if (session.element.status === ChatSessionStatus.InProgress) {
|
if (typeof session.element.description === 'string') {
|
||||||
template.description.textContent = this.getInProgressDescription(session.element);
|
|
||||||
const timer = template.elementDisposable.add(new IntervalTimer());
|
|
||||||
timer.cancelAndSet(() => template.description.textContent = this.getInProgressDescription(session.element), 1000 /* every second */);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise support description as string
|
|
||||||
else if (typeof session.element.description === 'string') {
|
|
||||||
template.description.textContent = session.element.description;
|
template.description.textContent = session.element.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +184,9 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
|
|||||||
|
|
||||||
// Fallback to state label
|
// Fallback to state label
|
||||||
else {
|
else {
|
||||||
if (
|
if (session.element.status === ChatSessionStatus.InProgress) {
|
||||||
|
template.description.textContent = localize('chat.session.status.inProgress', "Working...");
|
||||||
|
} else if (
|
||||||
session.element.timing.finishedOrFailedTime &&
|
session.element.timing.finishedOrFailedTime &&
|
||||||
session.element.timing.inProgressTime &&
|
session.element.timing.inProgressTime &&
|
||||||
session.element.timing.finishedOrFailedTime > session.element.timing.inProgressTime
|
session.element.timing.finishedOrFailedTime > session.element.timing.inProgressTime
|
||||||
@@ -209,17 +204,6 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getInProgressDescription(session: IAgentSessionViewModel): string {
|
|
||||||
if (session.timing.inProgressTime) {
|
|
||||||
const inProgressDuration = this.toDuration(session.timing.inProgressTime, Date.now());
|
|
||||||
if (inProgressDuration) {
|
|
||||||
return localize('chat.session.status.inProgressWithDuration', "Working... ({0})", inProgressDuration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return localize('chat.session.status.inProgress', "Working...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private toDuration(startTime: number, endTime: number): string | undefined {
|
private toDuration(startTime: number, endTime: number): string | undefined {
|
||||||
const elapsed = Math.round((endTime - startTime) / 1000) * 1000;
|
const elapsed = Math.round((endTime - startTime) / 1000) * 1000;
|
||||||
if (elapsed < 1000) {
|
if (elapsed < 1000) {
|
||||||
@@ -230,11 +214,22 @@ export class AgentSessionRenderer implements ICompressibleTreeRenderer<IAgentSes
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderStatus(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
private renderStatus(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
||||||
const getStatus = (session: IAgentSessionViewModel) => `${session.providerLabel} • ${fromNow(session.timing.endTime || session.timing.startTime)}`;
|
|
||||||
|
const getStatus = (session: IAgentSessionViewModel) => {
|
||||||
|
let timeLabel: string | undefined;
|
||||||
|
if (session.status === ChatSessionStatus.InProgress && session.timing.inProgressTime) {
|
||||||
|
timeLabel = this.toDuration(session.timing.inProgressTime, Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!timeLabel) {
|
||||||
|
timeLabel = fromNow(session.timing.endTime || session.timing.startTime, true);
|
||||||
|
}
|
||||||
|
return `${session.providerLabel} • ${timeLabel}`;
|
||||||
|
};
|
||||||
|
|
||||||
template.status.textContent = getStatus(session.element);
|
template.status.textContent = getStatus(session.element);
|
||||||
const timer = template.elementDisposable.add(new IntervalTimer());
|
const timer = template.elementDisposable.add(new IntervalTimer());
|
||||||
timer.cancelAndSet(() => template.status.textContent = getStatus(session.element), 60 * 1000 /* every minute */);
|
timer.cancelAndSet(() => template.status.textContent = getStatus(session.element), session.element.status === ChatSessionStatus.InProgress ? 1000 /* every second */ : 60 * 1000 /* every minute */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderHover(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
private renderHover(session: ITreeNode<IAgentSessionViewModel, FuzzyScore>, template: IAgentSessionItemTemplate): void {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 0 4px; /* to make space for hover effect */
|
padding: 0 4px; /* to make space for hover effect */
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-session-diff-files {
|
.agent-session-diff-files {
|
||||||
|
|||||||
@@ -90,6 +90,7 @@
|
|||||||
|
|
||||||
.agent-session-status {
|
.agent-session-status {
|
||||||
padding: 0 4px 0 0; /* to align with diff area above */
|
padding: 0 4px 0 0; /* to align with diff area above */
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user