feat: Modular aquatic background system and shared CodeBlock component
Add aquaticBackground/ module with OceanScene (unified gradient, light rays, sea floor, corals, seaweed, decorations), plus independent overlay layers (BubbleStream, FishSchool, JellyfishDrift, EventOverlay, EdgeFade). Includes event scheduling engine with 4 frequency tiers (minutes/hours/days/months) and 20 random events with localStorage persistence. Add shared CodeBlock component with copy-to-clipboard button, terminal-matched monospace font (Consolas), and proper line-height/letter-spacing. Refactor EditCard, WriteCard, TaskCard, and ToolResultBlock to use CodeBlock. Fix markdown code block alignment to match terminal rendering.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
||||
import { useTranscriptDebug } from '@/composables/transcript-debug'
|
||||
import { ChatContainer, BackgroundPixelArt } from '@/components/transcript-debug'
|
||||
import { ChatContainer, AquaticBackground } from '@/components/transcript-debug'
|
||||
import type { AgentName } from '@/types/transcript-debug'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -44,6 +44,7 @@ const agents: { id: AgentName; label: string }[] = [
|
||||
]
|
||||
|
||||
const showSelector = ref(false)
|
||||
const chatRef = ref<InstanceType<typeof ChatContainer> | null>(null)
|
||||
let initialized = false
|
||||
|
||||
// ============================================================================
|
||||
@@ -72,6 +73,9 @@ const dragOffset = ref({ x: 0, y: 0 })
|
||||
const isResizing = ref(false)
|
||||
const size = ref({ w: 480, h: 600 })
|
||||
|
||||
// Zoom level for content scaling
|
||||
const zoom = ref(1)
|
||||
|
||||
// Size mode: pin (small, anchored to FAB), medium (default), large
|
||||
type SizeMode = 'pin' | 'medium' | 'large'
|
||||
const sizeMode = ref<SizeMode>('medium')
|
||||
@@ -139,7 +143,7 @@ function stopSheetDrag() {
|
||||
|
||||
function startDrag(e: MouseEvent | TouchEvent) {
|
||||
if ((e.target as HTMLElement).closest('.window-controls')) return
|
||||
if ((e.target as HTMLElement).closest('.selector-overlay')) return
|
||||
if ((e.target as HTMLElement).closest('.header-selector')) return
|
||||
|
||||
if (isMobile.value) {
|
||||
if (e instanceof TouchEvent) startSheetDrag(e)
|
||||
@@ -301,6 +305,45 @@ function close() {
|
||||
showSelector.value = false
|
||||
}
|
||||
|
||||
function openAtCursor(x: number, y: number) {
|
||||
if (isMobile.value) {
|
||||
isOpen.value = !isOpen.value
|
||||
return
|
||||
}
|
||||
if (isOpen.value) {
|
||||
isOpen.value = false
|
||||
return
|
||||
}
|
||||
const preset = sizeModePresets[sizeMode.value]
|
||||
const w = sizeMode.value === 'medium' ? size.value.w : preset.w
|
||||
const h = sizeMode.value === 'medium' ? size.value.h : preset.h
|
||||
const pad = 8
|
||||
const vw = window.innerWidth
|
||||
const vh = window.innerHeight
|
||||
// Respect app header bar (~40px + safe-area)
|
||||
const headerEl = document.querySelector('.app-header') as HTMLElement | null
|
||||
const topBarrier = headerEl ? headerEl.getBoundingClientRect().bottom + pad : pad + 40
|
||||
|
||||
// Cursor at bottom-center of window: window extends upward from cursor
|
||||
let left = x - w / 2
|
||||
let top = y - h
|
||||
|
||||
// Clamp horizontally
|
||||
left = Math.max(pad, Math.min(left, vw - w - pad))
|
||||
|
||||
// Clamp vertically: never above header, never below viewport
|
||||
top = Math.max(topBarrier, Math.min(top, vh - h - pad))
|
||||
|
||||
position.value = { x: left, y: top }
|
||||
hasCustomPosition.value = true
|
||||
isOpen.value = true
|
||||
nextTick(() => {
|
||||
windowRef.value?.querySelector<HTMLTextAreaElement>('.input-field')?.focus()
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ openAtCursor })
|
||||
|
||||
function handleAgentSwitch(agent: AgentName) {
|
||||
switchAgent(agent)
|
||||
}
|
||||
@@ -326,6 +369,21 @@ watch(isOpen, async (open) => {
|
||||
}
|
||||
})
|
||||
|
||||
// ============================================================================
|
||||
// ZOOM KEYBOARD HANDLER
|
||||
// ============================================================================
|
||||
|
||||
function handleZoomKey(e: KeyboardEvent) {
|
||||
if (!isOpen.value || !e.ctrlKey) return
|
||||
if (e.key === '+' || e.key === '=') {
|
||||
e.preventDefault()
|
||||
zoom.value = Math.min(2, +(zoom.value + 0.1).toFixed(1))
|
||||
} else if (e.key === '-') {
|
||||
e.preventDefault()
|
||||
zoom.value = Math.max(0.5, +(zoom.value - 0.1).toFixed(1))
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// LIFECYCLE
|
||||
// ============================================================================
|
||||
@@ -333,10 +391,12 @@ watch(isOpen, async (open) => {
|
||||
onMounted(() => {
|
||||
checkMobile()
|
||||
window.addEventListener('resize', checkMobile)
|
||||
document.addEventListener('keydown', handleZoomKey)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
disconnectRealtime()
|
||||
document.removeEventListener('keydown', handleZoomKey)
|
||||
document.removeEventListener('mousemove', onDrag)
|
||||
document.removeEventListener('mouseup', stopDrag)
|
||||
document.removeEventListener('touchmove', onDrag)
|
||||
@@ -359,7 +419,8 @@ onBeforeUnmount(() => {
|
||||
resizing: isResizing,
|
||||
mobile: isMobile,
|
||||
'sheet-dragging': isDraggingSheet,
|
||||
'chrome-visible': showChrome
|
||||
'chrome-visible': showChrome,
|
||||
'selector-open': showSelector
|
||||
}"
|
||||
:style="windowStyle"
|
||||
@mouseenter="isHovered = true"
|
||||
@@ -367,7 +428,7 @@ onBeforeUnmount(() => {
|
||||
@focusin="isFocusWithin = true"
|
||||
@focusout="isFocusWithin = false"
|
||||
>
|
||||
<div class="glass">
|
||||
<div class="glass" :style="{ zoom: zoom !== 1 ? zoom : undefined }">
|
||||
<!-- Mobile drag handle -->
|
||||
<div
|
||||
v-if="isMobile"
|
||||
@@ -412,6 +473,17 @@ onBeforeUnmount(() => {
|
||||
<rect x="1" y="1" width="8" height="8" fill="currentColor"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button @click.stop="chatRef?.toggleSelectMode()" :class="{ active: chatRef?.selectMode }" title="Select messages">
|
||||
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline v-if="chatRef?.selectMode" points="20 6 9 17 4 12"/>
|
||||
<template v-else>
|
||||
<rect x="3" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="3" width="7" height="7" rx="1"/>
|
||||
<rect x="3" y="14" width="7" height="7" rx="1"/>
|
||||
<rect x="14" y="14" width="7" height="7" rx="1"/>
|
||||
</template>
|
||||
</svg>
|
||||
</button>
|
||||
<button @click.stop="showSelector = !showSelector" :class="{ active: showSelector }" title="Agent/Session">
|
||||
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="3"/>
|
||||
@@ -427,54 +499,27 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Agent/Session Selector Overlay -->
|
||||
<Transition name="selector-slide">
|
||||
<div v-if="showSelector" class="selector-overlay" @click.self="showSelector = false">
|
||||
<div class="selector-panel">
|
||||
<div class="selector-section">
|
||||
<label class="selector-label">Agent</label>
|
||||
<div class="agent-selector">
|
||||
<button
|
||||
v-for="a in agents"
|
||||
:key="a.id"
|
||||
:class="['agent-btn', { active: selectedAgent === a.id }]"
|
||||
@click="handleAgentSwitch(a.id)"
|
||||
>
|
||||
{{ a.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="selector-section">
|
||||
<label class="selector-label">Session</label>
|
||||
<select
|
||||
class="session-select"
|
||||
:value="selectedSessionId || ''"
|
||||
@change="handleSessionSelect(($event.target as HTMLSelectElement).value)"
|
||||
:disabled="loading"
|
||||
>
|
||||
<option value="" disabled>Select session...</option>
|
||||
<option v-for="s in sessions" :key="s.id" :value="s.id">
|
||||
{{ s.firstUserMessage ? (s.firstUserMessage.length > 50 ? s.firstUserMessage.slice(0, 50) + '...' : s.firstUserMessage) : s.id.slice(0, 8) + '...' }}
|
||||
</option>
|
||||
</select>
|
||||
<span v-if="loading" class="spinner-sm"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- Error -->
|
||||
<div v-if="error" class="error-bar">{{ error }}</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="content">
|
||||
<BackgroundPixelArt />
|
||||
<AquaticBackground />
|
||||
<div class="readability-overlay" />
|
||||
<ChatContainer
|
||||
ref="chatRef"
|
||||
v-if="conversation"
|
||||
:conversation="conversation"
|
||||
:processing="processing"
|
||||
:show-selector="showSelector"
|
||||
:agents="agents"
|
||||
:selected-agent="selectedAgent"
|
||||
:sessions="sessions"
|
||||
:selected-session-id="selectedSessionId"
|
||||
:sessions-loading="loading"
|
||||
@send="handleSend"
|
||||
@switch-agent="handleAgentSwitch"
|
||||
@select-session="handleSessionSelect"
|
||||
/>
|
||||
<div v-else class="empty-state">
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
@@ -502,6 +547,38 @@ onBeforeUnmount(() => {
|
||||
transition: width 0.3s ease, height 0.3s ease, top 0.3s ease, left 0.3s ease, bottom 0.3s ease;
|
||||
}
|
||||
|
||||
/* ── Dynamic glow from ocean background ── */
|
||||
.aero-win::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -12px;
|
||||
z-index: -1;
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 12, 35, 0.35) 0%,
|
||||
rgba(0, 30, 65, 0.30) 25%,
|
||||
rgba(4, 52, 78, 0.35) 50%,
|
||||
rgba(6, 58, 72, 0.30) 70%,
|
||||
rgba(18, 50, 45, 0.35) 100%
|
||||
);
|
||||
filter: blur(18px);
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.5s ease, filter 0.5s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.aero-win:hover::before,
|
||||
.aero-win.chrome-visible::before {
|
||||
opacity: 1;
|
||||
filter: blur(22px);
|
||||
}
|
||||
|
||||
.aero-win.dragging::before,
|
||||
.aero-win.resizing::before {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.aero-win.dragging,
|
||||
.aero-win.resizing {
|
||||
transition: none;
|
||||
@@ -534,7 +611,6 @@ onBeforeUnmount(() => {
|
||||
/* Transition all chrome elements smoothly */
|
||||
.titlebar,
|
||||
.error-bar,
|
||||
.selector-overlay,
|
||||
.resize-handle {
|
||||
transition: opacity 0.35s ease, max-height 0.35s ease, padding 0.35s ease;
|
||||
}
|
||||
@@ -561,14 +637,8 @@ onBeforeUnmount(() => {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Idle: hide selector overlay */
|
||||
.aero-win:not(.chrome-visible) .selector-overlay {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Idle: slide chat-header up past titlebar and fade out */
|
||||
.aero-win:not(.chrome-visible) .content :deep(.chat-header) {
|
||||
/* Chat-header: only visible when settings/selector is open */
|
||||
.aero-win:not(.selector-open) .content :deep(.chat-header) {
|
||||
opacity: 0 !important;
|
||||
transform: translateY(-150%) !important;
|
||||
pointer-events: none !important;
|
||||
@@ -588,13 +658,27 @@ onBeforeUnmount(() => {
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
/* Idle: hide status bar */
|
||||
.aero-win:not(.chrome-visible) .content :deep(.status-bar) {
|
||||
opacity: 0 !important;
|
||||
transform: translateY(100%) !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
/* Keep status-bar visible when input has text */
|
||||
.aero-win:not(.chrome-visible) .content :deep(.status-bar:has(~ .user-input .input-field:not(:placeholder-shown))) {
|
||||
opacity: 1 !important;
|
||||
transform: none !important;
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
/* Idle: also hide selection bar */
|
||||
.aero-win:not(.chrome-visible) .content :deep(.selection-bar) {
|
||||
opacity: 0 !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
/* Idle: softer glass border */
|
||||
/* Idle: softer glass border + dimmed glow */
|
||||
.aero-win:not(.chrome-visible) .glass {
|
||||
border-color: rgba(255,255,255,0.02);
|
||||
box-shadow:
|
||||
@@ -602,6 +686,11 @@ onBeforeUnmount(() => {
|
||||
0 8px 32px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.aero-win:not(.chrome-visible)::before {
|
||||
opacity: 0.4;
|
||||
filter: blur(14px);
|
||||
}
|
||||
|
||||
/* Smooth transitions for chrome show/hide */
|
||||
.content :deep(.chat-header) {
|
||||
transition: opacity 0.35s ease, transform 0.35s ease !important;
|
||||
@@ -611,6 +700,10 @@ onBeforeUnmount(() => {
|
||||
transition: opacity 0.35s ease, transform 0.35s ease !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar) {
|
||||
transition: opacity 0.35s ease, transform 0.35s ease !important;
|
||||
}
|
||||
|
||||
/* ── Titlebar: absolute overlay at top of .glass ── */
|
||||
.titlebar {
|
||||
position: absolute;
|
||||
@@ -733,108 +826,6 @@ onBeforeUnmount(() => {
|
||||
color: #fca5a5;
|
||||
}
|
||||
|
||||
/* ── Selector Overlay ── */
|
||||
.selector-overlay {
|
||||
position: absolute;
|
||||
top: 28px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
background: rgba(8, 8, 12, 0.92);
|
||||
backdrop-filter: blur(12px);
|
||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.selector-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.selector-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.selector-label {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
font-family: 'Courier New', monospace;
|
||||
color: rgba(255,255,255,0.4);
|
||||
min-width: 48px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.agent-selector {
|
||||
display: flex;
|
||||
background: rgba(255,255,255,0.04);
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
border-radius: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.agent-btn {
|
||||
padding: 4px 10px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: rgba(255,255,255,0.4);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
font-family: 'Courier New', monospace;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.agent-btn:not(:last-child) {
|
||||
border-right: 1px solid rgba(255,255,255,0.06);
|
||||
}
|
||||
|
||||
.agent-btn:hover {
|
||||
background: rgba(255,255,255,0.06);
|
||||
color: rgba(255,255,255,0.7);
|
||||
}
|
||||
|
||||
.agent-btn.active {
|
||||
background: rgba(99, 102, 241, 0.35);
|
||||
color: #c7d2fe;
|
||||
}
|
||||
|
||||
.session-select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 4px 8px;
|
||||
background: rgba(255,255,255,0.04);
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
border-radius: 0;
|
||||
color: rgba(255,255,255,0.8);
|
||||
font-size: 10px;
|
||||
font-family: 'Courier New', monospace;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.session-select:focus {
|
||||
outline: none;
|
||||
border-color: rgba(99, 102, 241, 0.4);
|
||||
}
|
||||
|
||||
.session-select option {
|
||||
background: #0a0a10;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.spinner-sm {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 2px solid rgba(255,255,255,0.1);
|
||||
border-top-color: #6366f1;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Error Bar ── */
|
||||
.error-bar {
|
||||
padding: 4px 10px;
|
||||
@@ -853,7 +844,7 @@ onBeforeUnmount(() => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
/* Background handled by BackgroundPixelArt component */
|
||||
/* Background handled by AquaticBackground component */
|
||||
}
|
||||
|
||||
/* Dark readability overlay: between ocean bg (z-index:0) and chat (z-index:1) */
|
||||
@@ -900,20 +891,11 @@ onBeforeUnmount(() => {
|
||||
.content :deep(.messages-scroll) {
|
||||
background: transparent !important;
|
||||
padding-top: 5rem !important;
|
||||
padding-bottom: 3.5rem !important;
|
||||
padding-bottom: 5rem !important;
|
||||
flex: 1 !important;
|
||||
scrollbar-gutter: stable !important;
|
||||
}
|
||||
|
||||
.content :deep(.chat-title-row) {
|
||||
color: rgba(255,255,255,0.6);
|
||||
}
|
||||
|
||||
.content :deep(.session-id) {
|
||||
color: rgba(255,255,255,0.4);
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.content :deep(.meta-badge) {
|
||||
background: rgba(255,255,255,0.04);
|
||||
color: rgba(255,255,255,0.4);
|
||||
@@ -991,12 +973,59 @@ onBeforeUnmount(() => {
|
||||
border-color: rgba(14, 165, 233, 0.3);
|
||||
}
|
||||
|
||||
/* UserInput: absolute overlay at bottom, floats over messages */
|
||||
.content :deep(.user-input) {
|
||||
/* Status bar: absolute overlay at very bottom */
|
||||
.content :deep(.status-bar) {
|
||||
position: absolute !important;
|
||||
bottom: 0 !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
z-index: 4 !important;
|
||||
background: rgba(0, 6, 18, 0.6) !important;
|
||||
backdrop-filter: blur(8px) !important;
|
||||
-webkit-backdrop-filter: blur(8px) !important;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
|
||||
border-bottom: none !important;
|
||||
padding: 0.15rem 0.5rem !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-id) {
|
||||
color: rgba(255,255,255,0.35) !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .copy-id-btn) {
|
||||
color: rgba(255,255,255,0.25) !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .copy-id-btn:hover) {
|
||||
color: rgba(255,255,255,0.6) !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .meta-badge) {
|
||||
border-radius: 0 !important;
|
||||
font-family: 'Courier New', monospace !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .meta-badge.model) {
|
||||
background: rgba(99, 102, 241, 0.1) !important;
|
||||
color: #a5b4fc !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .meta-badge.version) {
|
||||
background: rgba(255,255,255,0.04) !important;
|
||||
color: rgba(255,255,255,0.3) !important;
|
||||
}
|
||||
|
||||
.content :deep(.status-bar .meta-count),
|
||||
.content :deep(.status-bar .meta-duration) {
|
||||
color: rgba(255,255,255,0.2) !important;
|
||||
}
|
||||
|
||||
/* UserInput: absolute overlay above status bar */
|
||||
.content :deep(.user-input) {
|
||||
position: absolute !important;
|
||||
bottom: 20px !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
z-index: 3 !important;
|
||||
background: rgba(0, 6, 18, 0.5) !important;
|
||||
backdrop-filter: blur(8px) !important;
|
||||
@@ -1139,16 +1168,6 @@ onBeforeUnmount(() => {
|
||||
transform: translateY(16px) scale(0.98);
|
||||
}
|
||||
|
||||
.selector-slide-enter-active,
|
||||
.selector-slide-leave-active {
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.selector-slide-enter-from,
|
||||
.selector-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
|
||||
Reference in New Issue
Block a user