Skip to content

Commit 51308f2

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Render computer-use state in chat function responses
PiperOrigin-RevId: 856215304
1 parent c31c6d6 commit 51308f2

File tree

5 files changed

+351
-178
lines changed

5 files changed

+351
-178
lines changed

src/app/components/chat-panel/chat-panel.component.html

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,24 @@
234234
{{ message.functionCall.name }}
235235
</button>
236236
} @if (message.functionResponse) {
237-
<button
238-
mat-stroked-button
239-
[ngClass]="{'function-event-button-highlight': shouldMessageHighlighted(i)}"
240-
class="function-event-button"
241-
(click)="clickEvent.emit(i)"
242-
>
243-
<mat-icon>check</mat-icon>
244-
{{ message.functionResponse.name }}
245-
</button>
237+
@if (isComputerUseResponse(message)) {
238+
<div class="computer-use-container" (click)="clickEvent.emit(i)">
239+
<div class="computer-use-header">
240+
<span class="computer-use-tool-name">{{ message.functionResponse.name }}</span>
241+
</div>
242+
<img [src]="getComputerUseScreenshot(message)" class="computer-use-screenshot" alt="Computer Use Screenshot" />
243+
<div class="computer-use-footprint">
244+
<mat-icon class="computer-icon">computer</mat-icon>
245+
<span class="url-text">{{ getComputerUseUrl(message) }}</span>
246+
</div>
247+
</div>
248+
} @else {
249+
<button mat-stroked-button [ngClass]="{'function-event-button-highlight': shouldMessageHighlighted(i)}"
250+
class="function-event-button" (click)="clickEvent.emit(i)">
251+
<mat-icon>check</mat-icon>
252+
{{ message.functionResponse.name }}
253+
</button>
254+
}
246255
}
247256
<div
248257
[ngClass]="{

src/app/components/chat-panel/chat-panel.component.scss

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,52 @@ button.video-rec-btn {
441441
margin-top: 1em;
442442
margin-bottom: 1em;
443443
}
444+
445+
.computer-use-container {
446+
display: flex;
447+
flex-direction: column;
448+
max-width: 400px;
449+
border-radius: 12px;
450+
border: 1px solid var(--chat-panel-input-field-mat-mdc-text-field-wrapper-border-color);
451+
overflow: hidden;
452+
cursor: pointer;
453+
margin: 5px 5px 10px;
454+
background-color: var(--chat-panel-bot-message-message-card-background-color);
455+
transition: opacity 0.2s;
456+
457+
&:hover {
458+
opacity: 0.9;
459+
}
460+
}
461+
462+
.computer-use-screenshot {
463+
width: 100%;
464+
height: auto;
465+
display: block;
466+
border-bottom: 1px solid var(--chat-panel-input-field-mat-mdc-text-field-wrapper-border-color);
467+
}
468+
469+
.computer-use-footprint {
470+
display: flex;
471+
align-items: center;
472+
padding: 8px 12px;
473+
gap: 8px;
474+
background-color: var(--chat-panel-thought-chip-background-color);
475+
}
476+
477+
.computer-icon {
478+
font-size: 18px;
479+
width: 18px;
480+
height: 18px;
481+
color: var(--chat-panel-header-expected-color);
482+
}
483+
484+
.url-text {
485+
font-size: 11px;
486+
font-family: monospace;
487+
white-space: nowrap;
488+
overflow: hidden;
489+
text-overflow: ellipsis;
490+
color: var(--chat-panel-input-field-textarea-color);
491+
opacity: 0.8;
492+
}

0 commit comments

Comments
 (0)