feat(heads): nightly auto-retrain + inline Retrain button in Explore
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 19s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m26s

Two cadences for keeping heads in sync with your tagging:
- PASSIVE: a nightly `scheduled_train_heads` beat (skips if a run is already
  in flight; creates+commits the run row before dispatching train_heads so the
  ml worker always finds it). Folds the day's accepts/rejects + newly-eligible
  concepts into the heads without anyone clicking.
- ACTIVE: a "Retrain heads" button in the Explore trail bar — bank the +/-
  feedback you just gave while walking content, without a trip to Settings.

Shared logic in a new useHeadTraining composable (trigger + poll + start/finish
toasts), used by the Explore button; reflects an already-running run (incl. the
nightly one) on mount.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
This commit is contained in:
2026-06-28 22:15:27 -04:00
parent 353b5d8087
commit 77baee49fd
4 changed files with 136 additions and 8 deletions
+35 -8
View File
@@ -30,11 +30,22 @@
>
<img :src="c.thumbnail_url" alt="" loading="lazy" />
</button>
<v-btn
class="fc-ex__reseed" size="small" variant="text" color="accent"
prepend-icon="mdi-shuffle-variant" :loading="seeding"
@click="reseed"
>Random image</v-btn>
<div class="fc-ex__trail-actions">
<!-- Active retrain right where you tag: fold the +/- you just gave
into the heads without a trip to Settings (the nightly beat is the
passive cadence). -->
<v-btn
size="small" variant="text" color="accent"
prepend-icon="mdi-brain" :loading="headsBusy || headsRunning"
title="Retrain the concept heads on your latest tags"
@click="trainHeads"
>{{ headsRunning ? 'Training…' : 'Retrain heads' }}</v-btn>
<v-btn
size="small" variant="text" color="accent"
prepend-icon="mdi-shuffle-variant" :loading="seeding"
@click="reseed"
>Random image</v-btn>
</div>
</nav>
<v-alert v-if="store.error" type="error" variant="tonal" class="ma-3">
@@ -115,6 +126,7 @@ import { useRoute, useRouter } from 'vue-router'
import { useApi } from '../composables/useApi.js'
import { useExploreStore } from '../stores/explore.js'
import { useModalStore } from '../stores/modal.js'
import { useHeadTraining } from '../composables/useHeadTraining.js'
import { isTextEntry } from '../utils/textEntry.js'
import ImageCanvas from '../components/modal/ImageCanvas.vue'
import ImageMetaBar from '../components/modal/ImageMetaBar.vue'
@@ -132,6 +144,13 @@ const seeding = ref(false)
const seedError = ref(null)
const tagPanelRef = ref(null)
// Inline head-retrain (shared with the Settings card) so banking your latest
// +/- feedback is one click while you walk content.
const {
running: headsRunning, busy: headsBusy, train: trainHeads,
start: startHeads, stop: stopHeads,
} = useHeadTraining()
// Auto-focus the tag input after any action so tagging needs no extra click —
// the whole point of the workspace (operator-asked 2026-06-26). nextTick waits
// for the post-navigation re-render, then rAF lands the focus AFTER paint so a
@@ -216,8 +235,14 @@ function onKeyDown (ev) {
const id = ev.key === 'ArrowLeft' ? store.backTarget() : store.forwardTarget()
if (id != null) { ev.preventDefault(); goTo(id) }
}
onMounted(() => document.addEventListener('keydown', onKeyDown))
onUnmounted(() => document.removeEventListener('keydown', onKeyDown))
onMounted(() => {
document.addEventListener('keydown', onKeyDown)
startHeads() // reflect a run already in flight (e.g. the nightly one)
})
onUnmounted(() => {
document.removeEventListener('keydown', onKeyDown)
stopHeads()
})
</script>
<style scoped>
@@ -250,7 +275,9 @@ onUnmounted(() => document.removeEventListener('keydown', onKeyDown))
.fc-ex__crumb img { width: 100%; height: 100%; object-fit: cover; }
.fc-ex__crumb--current { border-color: rgb(var(--v-theme-accent)); }
.fc-ex__crumb:focus-visible { outline: 2px solid rgb(var(--v-theme-accent)); outline-offset: 1px; }
.fc-ex__reseed { margin-left: auto; }
.fc-ex__trail-actions {
margin-left: auto; display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
}
/* The three panes fill the remaining height; each scrolls on its own.
grid-template-rows: minmax(0, 1fr) BOUNDS the single row to the container