Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
Open chat images the size of the window, with zoom (#58)
Rayanne B. Lima72fc9aa58eb9
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex 6931f77..b8f1253 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -3,6 +3,7 @@ import { L } from '../../shared/lang'import { getState, navigate, openDialog, setNav, useStore } from './store'import { Sidebar } from './components/Sidebar'import { ConversationView } from './components/Conversation'+import { Lightbox } from './components/Lightbox'import { AgentPage, ApprovalsPage, ConnectorsPage, SettingsPage } from './components/Pages'import { UsagePage } from './components/Usage'import { MemoryPage } from './components/Memory'@@ -91,6 +92,7 @@ export function App(): ReactNode {{view.kind === 'settings' && <SettingsPage />}</main><Dialogs />+ <Lightbox /></div>)}diff --git a/src/renderer/src/components/Lightbox.tsx b/src/renderer/src/components/Lightbox.tsxnew file mode 100644index 0000000..56e7e35--- /dev/null+++ b/src/renderer/src/components/Lightbox.tsx@@ -0,0 +1,126 @@+// An image the size of the window: the wheel zooms where the pointer is, dragging moves it+// and the arrows go through the others.+import { useEffect, useRef, useState, type ReactNode } from 'react'+import { L } from '../../../shared/lang'+import { closeLightbox, moveLightbox, useStore } from '../store'+import { Icon } from './ui'++const MAX = 8+type View = { scale: number; x: number; y: number }+const FIT: View = { scale: 1, x: 0, y: 0 }++export function Lightbox(): ReactNode {+ const box = useStore((s) => s.lightbox)+ const item = box?.items[box.index]+ const [view, setView] = useState<View>(FIT)+ const stage = useRef<HTMLDivElement>(null)+ const drag = useRef<{ x: number; y: number; moved: boolean } | null>(null)+ const dragged = useRef(false)++ useEffect(() => setView(FIT), [item?.url])+ const zoomBy = (factor: number, at?: { x: number; y: number }): void =>+ setView((v) => {+ const scale = Math.min(MAX, Math.max(1, v.scale * factor))+ if (scale === 1) return FIT+ // The point under the pointer stays under it.+ const rect = stage.current!.getBoundingClientRect()+ const px = (at?.x ?? rect.left + rect.width / 2) - rect.left - rect.width / 2+ const py = (at?.y ?? rect.top + rect.height / 2) - rect.top - rect.height / 2+ const k = scale / v.scale+ return { scale, x: px - (px - v.x) * k, y: py - (py - v.y) * k }+ })++ useEffect(() => {+ if (!box) return+ const onKey = (e: KeyboardEvent): void => {+ const keys: Record<string, () => void> = {+ Escape: closeLightbox,+ ArrowLeft: () => moveLightbox(-1),+ ArrowRight: () => moveLightbox(1),+ '+': () => zoomBy(1.4),+ '=': () => zoomBy(1.4),+ '-': () => zoomBy(1 / 1.4),+ '0': () => setView(FIT)+ }+ const act = keys[e.key]+ if (!act) return+ e.preventDefault()+ e.stopPropagation() // Esc here is for this, not for what's behind it+ act()+ }+ window.addEventListener('keydown', onKey, true)+ return () => window.removeEventListener('keydown', onKey, true)+ }, [!box])++ // React's wheel handler is passive, and this one has to stop the page from scrolling.+ useEffect(() => {+ const el = stage.current+ if (!el) return+ const onWheel = (e: WheelEvent): void => {+ e.preventDefault()+ zoomBy(Math.exp(-e.deltaY * 0.002), { x: e.clientX, y: e.clientY })+ }+ el.addEventListener('wheel', onWheel, { passive: false })+ return () => el.removeEventListener('wheel', onWheel)+ }, [!box])++ if (!box || !item) return null+ const many = box.items.length > 1+ return (+ <div className="lightbox" role="dialog" aria-modal="true" aria-label={item.title}>+ <header className="lightbox__bar">+ <strong className="lightbox__title">{item.title}</strong>+ {many && <span className="small">{box.index + 1} / {box.items.length}</span>}+ <span className="grow" />+ <button className="icon-btn" title={L('Afastar (−)', 'Zoom out (−)')} aria-label={L('Afastar', 'Zoom out')} onClick={() => zoomBy(1 / 1.4)}>−</button>+ <span className="small lightbox__zoom">{Math.round(view.scale * 100)}%</span>+ <button className="icon-btn" title={L('Aproximar (+)', 'Zoom in (+)')} aria-label={L('Aproximar', 'Zoom in')} onClick={() => zoomBy(1.4)}>+</button>+ <button className="icon-btn" title={L('Fechar (Esc)', 'Close (Esc)')} aria-label={L('Fechar', 'Close')} onClick={closeLightbox}>+ <Icon name="x" size={16} />+ </button>+ </header>+ <div+ className={`lightbox__stage ${view.scale > 1 ? 'is-zoomed' : ''}`}+ ref={stage}+ onClick={(e) => {+ if (e.target === e.currentTarget && !dragged.current) closeLightbox()+ dragged.current = false+ }}+ onPointerDown={(e) => {+ if (view.scale === 1) return+ drag.current = { x: e.clientX - view.x, y: e.clientY - view.y, moved: false }+ }}+ onPointerMove={(e) => {+ const d = drag.current+ if (!d) return+ // Captured only now: from the press, a click on the image would count as a click on the stage.+ if (!d.moved) e.currentTarget.setPointerCapture(e.pointerId)+ d.moved = true+ setView((v) => ({ ...v, x: e.clientX - d.x, y: e.clientY - d.y }))+ }}+ onPointerUp={() => {+ dragged.current = !!drag.current?.moved+ drag.current = null+ }}+ >+ <img+ src={item.url}+ alt={item.title}+ draggable={false}+ style={{ transform: `translate(${view.x}px, ${view.y}px) scale(${view.scale})` }}+ onDoubleClick={(e) => {+ if (view.scale > 1) return setView(FIT)+ const img = e.currentTarget+ zoomBy(Math.max(1.5, img.naturalWidth / img.clientWidth), { x: e.clientX, y: e.clientY })+ }}+ />+ </div>+ {many && (+ <>+ <button className="lightbox__nav lightbox__nav--prev" aria-label={L('Anterior', 'Previous')} onClick={() => moveLightbox(-1)}>‹</button>+ <button className="lightbox__nav lightbox__nav--next" aria-label={L('Próxima', 'Next')} onClick={() => moveLightbox(1)}>›</button>+ </>+ )}+ </div>+ )+}diff --git a/src/renderer/src/components/Panel.tsx b/src/renderer/src/components/Panel.tsxindex f07a926..00805e6 100644--- a/src/renderer/src/components/Panel.tsx+++ b/src/renderer/src/components/Panel.tsx@@ -4,7 +4,7 @@ import { L, locale } from '../../../shared/lang'import { useEffect, useState, type ReactNode } from 'react'import Markdown from 'react-markdown'import remarkGfm from 'remark-gfm'-import { agentById, artifactUrl, browserAction, browserInput, browserOf, reachable, windowless, computerOf, openExternal, openPanel, stopService, useStore, type Artifact } from '../store'+import { agentById, getState, openLightbox, artifactUrl, browserAction, browserInput, browserOf, reachable, windowless, computerOf, openExternal, openPanel, stopService, useStore, type Artifact } from '../store'import { call } from '../rpc'import { Icon, type IconName } from './ui'@@ -21,13 +21,19 @@ const KIND_LABEL = (): Record<Artifact['kind'], string> => ({export const bytes = (n: number): string => (n < 1024 ? `${n} B` : n < 1024 ** 2 ? `${(n / 1024).toFixed(0)} KB` : `${(n / 1024 ** 2).toFixed(1)} MB`)+// The window's size, with the conversation's other images a key away.+function showImages(a: Artifact): void {+ const images = getState().artifacts.filter((x) => x.kind === 'image' && x.conversationId === a.conversationId)+ openLightbox(images.map((x) => ({ url: artifactUrl(x), title: x.title })), Math.max(0, images.findIndex((x) => x.id === a.id)))+}+export function ArtifactCard({ id }: { id: string }): ReactNode {const a = useStore((s) => s.artifacts.find((x) => x.id === id))const open = useStore((s) => s.panel?.kind === 'artifact' && s.panel.id === id)if (!a) return nullif (a.kind === 'image')return (- <button className={`artifact-image ${open ? 'is-open' : ''}`} onClick={() => openPanel({ kind: 'artifact', id })} title={a.title}>+ <button className="artifact-image" onClick={() => showImages(a)} title={a.title}><img src={artifactUrl(a)} alt={a.title} /><span className="artifact-image__caption">{a.title}</span></button>diff --git a/src/renderer/src/store.ts b/src/renderer/src/store.tsindex 715d30f..36d6836 100644--- a/src/renderer/src/store.ts+++ b/src/renderer/src/store.ts@@ -66,6 +66,7 @@ export interface State {models: Model[]agents: Agent[]connectors: Connector[]+ lightbox: { items: { url: string; title: string }[]; index: number } | nullconversations: Conversation[]messages: Message[]approvals: Approval[]@@ -115,6 +116,7 @@ let state: State = {models: MODELS,agents: [],connectors: [],+ lightbox: null,conversations: [],messages: [],approvals: [],@@ -443,6 +445,10 @@ export function patchAgent(agentId: string, patch: Partial<Agent>): void {}export const openPanel = (panel: Panel | null): void => set((s) => ({ ...s, panel }))+export const openLightbox = (items: { url: string; title: string }[], index: number): void => set((s) => ({ ...s, lightbox: { items, index } }))+export const closeLightbox = (): void => set((s) => ({ ...s, lightbox: null }))+export const moveLightbox = (by: number): void =>+ set((s) => (s.lightbox ? { ...s, lightbox: { ...s.lightbox, index: (s.lightbox.index + by + s.lightbox.items.length) % s.lightbox.items.length } } : s))export const openDialog = (dialog: Dialog | null): void => set((s) => ({ ...s, dialog, navOpen: dialog ? false : s.navOpen }))export const setTab = (page: string, tab: string): void => set((s) => ({ ...s, tabs: { ...s.tabs, [page]: tab } }))export const computerAction = (agentId: string, action: 'start' | 'restart' | 'erase' | 'open_folder' | 'refresh'): void =>diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.cssindex b4a1817..acfb5d7 100644--- a/src/renderer/src/styles.css+++ b/src/renderer/src/styles.css@@ -6518,3 +6518,83 @@ kbd {.app-picker .app-picker__head input:focus { border: 0; box-shadow: none; outline: none; background: transparent; padding: 4px 0; }.apps-setup__how { display: block; margin-top: 4px; color: var(--text-2); font-size: 12px; }++/* An image the size of the window */+.lightbox {+ position: fixed;+ inset: 0;+ z-index: 200;+ display: flex;+ flex-direction: column;+ background: rgba(12, 11, 10, 0.94);+ color: #f3efe8;+}+.lightbox__bar {+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 10px 14px;+ padding-top: max(10px, env(safe-area-inset-top));+ -webkit-app-region: no-drag;+}+.lightbox__bar .icon-btn {+ color: inherit;+}+.lightbox__title {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.lightbox__zoom {+ min-width: 44px;+ text-align: center;+}+.lightbox__stage {+ flex: 1;+ min-height: 0;+ display: flex;+ align-items: center;+ justify-content: center;+ overflow: hidden;+ touch-action: none;+}+.lightbox__stage.is-zoomed {+ cursor: grab;+}+.lightbox__stage.is-zoomed:active {+ cursor: grabbing;+}+.lightbox__stage img {+ max-width: 100%;+ max-height: 100%;+ object-fit: contain;+ user-select: none;+}+.lightbox__nav {+ position: absolute;+ top: 50%;+ width: 44px;+ height: 64px;+ padding: 0;+ transform: translateY(-50%);+ text-align: center;+ border: 0;+ border-radius: 8px;+ background: rgba(255, 255, 255, 0.08);+ color: inherit;+ font-size: 28px;+ cursor: pointer;+}+.lightbox__nav:hover {+ background: rgba(255, 255, 255, 0.18);+}+.lightbox__nav--prev {+ left: 12px;+}+.lightbox__nav--next {+ right: 12px;+}+[data-os='mac'] .lightbox__bar {+ padding-left: 84px; /* the window's buttons are here */+}