Skip to content

Show LabelBOT popup despite no suggestions#1478

Open
gkourie wants to merge 3 commits into
masterfrom
1337-improve-case-with-empty-labelbot-suggestions
Open

Show LabelBOT popup despite no suggestions#1478
gkourie wants to merge 3 commits into
masterfrom
1337-improve-case-with-empty-labelbot-suggestions

Conversation

@gkourie

@gkourie gkourie commented May 29, 2026

Copy link
Copy Markdown
Contributor

When LabelBOT returns no suggestions, an empty array will be sent to the front end. The LabelBOT popup will show a message to type a label in the typeahead. For now the temp annotation will be saved in the database without a label and it will have the editing style in the front end until it's confirmed with a label, if not then it will be deleted.

@gkourie gkourie linked an issue May 29, 2026 that may be closed by this pull request
@gkourie gkourie requested review from Copilot and mzur May 29, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes LabelBOT’s empty-result behavior so annotations can still be created when no suggestions are found, then prompts the user to manually choose a label or dismiss the temporary annotation.

Changes:

  • Backend LabelBOT now returns an empty label list instead of throwing a 404.
  • Image/video annotation creation can save annotations without immediately attaching a label.
  • LabelBOT popup now displays an empty-suggestions message and supports manual label selection/deletion flow.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/Services/LabelBot/LabelBotService.php Returns an empty suggestion array when no similar labels are found.
app/Http/Controllers/Api/ImageAnnotationController.php Skips label authorization/attachment when no label is available.
app/Http/Controllers/Api/VideoAnnotationController.php Mirrors the image annotation empty-label persistence behavior.
resources/assets/js/annotations/components/labelbotPopup.vue Adds no-suggestions UI and temporary annotation deletion behavior.
resources/assets/js/annotations/annotatorContainer.vue Refreshes annotations after manually attaching a label when no previous label existed.
resources/assets/sass/annotations/components/_labelbot-popup.scss Adds styling for the no-suggestions popup message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 199 to 201
if (!this.selectedLabel || this.selectedLabel.id !== label.id) {
this.dismissLabelbotAnnotation = false;
this.$emit('update', {label: label, annotation: this.annotation});
Comment on lines +456 to +457
if (this.noLabels && this.dismissLabelbotAnnotation) {
this.deleteLabelAnnotation();

if (empty($topNLabels)) {
throw new NotFoundHttpException("LabelBOT could not find similar annotations.");
return [];

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

$response->assertSuccessful();

// We expect an empty array
$response->assertJsonFragment([]);
Comment on lines +207 to +209
this.emitClose();
Events.emit('labelbot.chose_label_1');
if (this.noLabels) {
this.deleteLabelAnnotation();
Comment on lines +456 to +457
if (this.noLabels && this.deletePendingLabelbotAnnotation) {
this.deleteLabelAnnotation();
Comment on lines +250 to +256
if ($label) {
VideoAnnotationLabel::create([
'label_id' => $label->id,
'user_id' => $request->user()->id,
'annotation_id' => $annotation->id,
]);
}
@mzur mzur removed their request for review June 1, 2026 09:23
@mzur

mzur commented Jun 1, 2026

Copy link
Copy Markdown
Member

Please request my review again once you are through with the AI.

@gkourie

gkourie commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@mzur While trying to implement this for videos, I found some other issues:

  1. When LabelBOT returns no results, the video disappears (this should be fixed with empty LabelBOT popup):
Screencast.from.2026-06-02.13-58-18.webm
  1. If LabelBOT popup is shown and the video is seeked, then the popup and its line feature are shown on the next frames without the annotation:
Screencast.from.2026-06-02.14-04-56.webm

Or was that intentional for 2 ? Otherwise, I could try to fix it here.

@gkourie gkourie requested a review from mzur June 2, 2026 13:34

@mzur mzur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you fixed issue 1. Regarding issue 2 I feel that we thought about this when LabelBOT was implemented for videos but I might be wrong (or there was a regression). Please fix that too.

Comments below:

</div>
<ul class="labelbot-labels">
<li
<li v-if="noLabels" class="labelbot-popup__message">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li v-if="noLabels" class="labelbot-popup__message">
<li v-if="noLabels" class="labelbot-popup__message text-muted">

<li
<li v-if="noLabels" class="labelbot-popup__message">
<p>
LabelBOT could not find similar annotations. Enter a label manually below, or close this popup to delete the annotation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LabelBOT could not find similar annotations. Enter a label manually below, or close this popup to delete the annotation.
LabelBOT could not find similar annotations. Enter a label below, or close this popup to delete the annotation.

Comment on lines +89 to +95
// Delete saved unlabeled LabelBOT annotations
// Such annotations are only created when LabelBOT returns no results
// and the user refreshes/closes the BIIGLE session without interacting with the empty LabelBOT popup.
if ($annotation->labels->isEmpty()) {
$annotation->delete();
continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do it like this. The index endpoint must not delete anything. We have to update the behavior of the store endpoint instead.

Comment on lines 251 to 259
$annotation->save();
$annotationLabel = new ImageAnnotationLabel;
$annotationLabel->label_id = $label->id;
$annotationLabel->user_id = $request->user()->id;
$annotationLabel->confidence = $request->input('confidence');
$annotation->labels()->save($annotationLabel);
if ($label) {
$annotationLabel = new ImageAnnotationLabel;
$annotationLabel->label_id = $label->id;
$annotationLabel->user_id = $request->user()->id;
$annotationLabel->confidence = $request->input('confidence');
$annotation->labels()->save($annotationLabel);
}
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without any label, no annotation should be created here. We could instead respond with a "204 No Content" to signal the UI that no label could be found. The UI can then keep the temporary annotation. If the user tries again with a manually chosen label, the annotation could be saved and the temporary annotation replaced. if the popup is closed then the temporary annotation is just discarded in the UI.

Comment on lines +244 to +256
if ($label) {
$this->authorize('attach-label', [$annotation, $label]);
}

$annotation = DB::transaction(function () use ($annotation, $request, $label) {
$annotation->save();
VideoAnnotationLabel::create([
'label_id' => $label->id,
'user_id' => $request->user()->id,
'annotation_id' => $annotation->id,
]);
if ($label) {
VideoAnnotationLabel::create([
'label_id' => $label->id,
'user_id' => $request->user()->id,
'annotation_id' => $annotation->id,
]);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. If no label is found, don't create an annotation and respond with a 204. Then handle the rest in the UI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also update the test class.

@gkourie gkourie force-pushed the 1337-improve-case-with-empty-labelbot-suggestions branch from 207345e to ac0a62a Compare June 18, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve case with empty LabelBOT suggestions

3 participants