Improve query intent handling and preview playback
build-push / docker (push) Successful in 4m52s

This commit is contained in:
AI Assistant
2026-03-16 09:55:14 +09:00
parent 6d9391bc2b
commit 9637b761bd
7 changed files with 142 additions and 12 deletions
+30 -4
View File
@@ -270,6 +270,33 @@ function attachVideoSource(video, src) {
logEvent("preview:attach:file", { src });
}
function startHoverPreview(video, src) {
if (!src) {
return;
}
attachVideoSource(video, src);
video.classList.remove("hidden");
const attemptPlay = () => {
video.play().catch((error) => {
logEvent("preview:hover:play:error", { src, message: String(error) });
});
};
if (video.readyState >= 2) {
attemptPlay();
return;
}
const onReady = () => {
video.removeEventListener("loadeddata", onReady);
video.removeEventListener("canplay", onReady);
attemptPlay();
};
video.addEventListener("loadeddata", onReady, { once: true });
video.addEventListener("canplay", onReady, { once: true });
if (video.load) {
video.load();
}
}
function detachVideoSource(video) {
const existing = hlsInstances.get(video);
if (existing) {
@@ -299,21 +326,20 @@ function renderResults(results) {
node.querySelector(".result-snippet").textContent = item.snippet || item.reason || item.source || "";
node.querySelector(".result-reason").textContent = item.reason ? `AI note: ${item.reason}` : "";
node.querySelector(".source-badge").textContent = item.source;
previewVideo.poster = item.thumbnailUrl || "";
if (item.previewVideoUrl) {
attachVideoSource(previewVideo, item.previewVideoUrl);
previewVideo.poster = item.thumbnailUrl || "";
const mediaArea = node.querySelector(".relative");
mediaArea.addEventListener("mouseenter", () => {
logEvent("preview:hover:start", { title: item.title, source: item.source, previewVideoUrl: item.previewVideoUrl });
overlays.forEach((overlay) => overlay.classList.add("hidden"));
previewVideo.classList.remove("hidden");
previewVideo.play().catch(() => {});
startHoverPreview(previewVideo, item.previewVideoUrl);
});
mediaArea.addEventListener("mouseleave", () => {
logEvent("preview:hover:end", { title: item.title, source: item.source });
previewVideo.pause();
previewVideo.currentTime = 0;
previewVideo.classList.add("hidden");
detachVideoSource(previewVideo);
overlays.forEach((overlay) => overlay.classList.remove("hidden"));
});
}