mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 05:48:28 +01:00
feat(loki): mobile-first chat redesign — single column + drawers, keyboard-aware
Loki was a 3-column grid with no mobile breakpoint: the fixed 16rem conversation sidebar crushed the chat to <50vw on phones, the composer hid behind the keyboard, controls were hover-only (invisible to touch). Rebuilt mobile-first like modern AI chat (ChatGPT/Claude/Grok): - Single full-width chat column on mobile; the conversation history and project filter move into slide-over Drawers reached from a compact mobile toolbar (Chats / New / Projects). md+ keeps the permanent multi-pane layout. - viewport interactiveWidget=resizes-content so the composer rides above the on-screen keyboard instead of being covered. - Page height accounts for the floating bottom nav + top bar via --mobile-chrome-bottom; subtitle is desktop-only to reclaim vertical space. - Message bubbles responsive (90% mobile / 75% desktop) — dropped the arbitrary max-w-[85%] (4-layer fix). Delete control visible on touch (hover:none). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f0cc29ac1d
commit
2e2ff7e687
4 files changed
+80
-10
No files matched your search
@@ -7,12 +7,18 @@ export const metadata: Metadata = { title: "Loki" };
|
||||
// One composer, a conversation list, a project filter; chat routes to Loki and
|
||||
// commands dispatch into the project's agent session via the shared resolver.
|
||||
export default function LokiPage() {
|
||||
// Fill the visible area exactly so the composer sits at the bottom without
|
||||
// page scroll. On mobile, leave room for the floating bottom nav (the
|
||||
// --mobile-chrome-bottom token) and the top bar; on md+ the sidebar layout
|
||||
// makes the simple inset enough.
|
||||
return (
|
||||
<div className="app-page flex h-[calc(100dvh-2rem)] flex-col gap-4">
|
||||
<div className="app-page flex h-[calc(100svh-var(--mobile-chrome-bottom)-3.25rem)] flex-col gap-2 md:h-[calc(100dvh-2rem)] md:gap-4">
|
||||
{/* Compact header — the subtitle is desktop-only so the chat keeps the
|
||||
vertical space on phones (modern chat surfaces don't title the page). */}
|
||||
<div className="ui-page-header">
|
||||
<div>
|
||||
<h1 className="ui-page-title">Loki</h1>
|
||||
<p className="ui-page-subtitle">
|
||||
<p className="ui-page-subtitle hidden sm:block">
|
||||
Say what you want — Loki figures out which project and whether to chat or dispatch.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+12
-1
@@ -2629,10 +2629,21 @@
|
||||
.ui-loki-convo-delete-armed {
|
||||
@apply opacity-100 text-status-negative bg-status-negative-subtle;
|
||||
}
|
||||
/* Touch devices have no hover, so the delete would be permanently invisible.
|
||||
Show it (dimmed) there; desktop keeps the reveal-on-hover behaviour. */
|
||||
@media (hover: none) {
|
||||
.ui-loki-convo-delete { @apply opacity-60; }
|
||||
}
|
||||
|
||||
/* Message bubbles (center pane). */
|
||||
.ui-loki-bubble {
|
||||
@apply max-w-[85%] rounded-2xl px-4 py-2.5 text-sm leading-relaxed whitespace-pre-wrap break-words;
|
||||
@apply rounded-2xl px-4 py-2.5 text-sm leading-relaxed whitespace-pre-wrap break-words;
|
||||
/* Roomy on phones, tighter on desktop — bubbles read as chat, not full-width
|
||||
blocks. Direct CSS (not an arbitrary Tailwind value) keeps it responsive. */
|
||||
max-width: 90%;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.ui-loki-bubble { max-width: 75%; }
|
||||
}
|
||||
.ui-loki-bubble-user {
|
||||
@apply self-end bg-accent-muted text-text-primary;
|
||||
|
||||
@@ -48,6 +48,10 @@ export const viewport: Viewport = {
|
||||
width: "device-width",
|
||||
initialScale: 1,
|
||||
viewportFit: "cover",
|
||||
// The on-screen keyboard shrinks the visual viewport instead of overlaying
|
||||
// it, so a bottom-anchored composer (Loki, Terminal) stays visible above the
|
||||
// keyboard rather than being covered by it.
|
||||
interactiveWidget: "resizes-content",
|
||||
themeColor: [
|
||||
{ media: "(prefers-color-scheme: light)", color: "#f7f7f7" },
|
||||
{ media: "(prefers-color-scheme: dark)", color: "#0a0a0a" },
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { MessagesSquare, Plus, SlidersHorizontal } from "lucide-react";
|
||||
import { getJson, postJson, deleteJson, throwApiError } from "@/lib/api/fetch";
|
||||
import { Drawer } from "@/components/ui/modal";
|
||||
import { ConversationList } from "./ConversationList";
|
||||
import { Transcript } from "./Transcript";
|
||||
import { Composer } from "./Composer";
|
||||
@@ -25,6 +27,10 @@ export function LokiWorkspace() {
|
||||
const [messages, setMessages] = useState<LokiMessage[]>([]);
|
||||
const [sending, setSending] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
// Mobile-only slide-overs for the history + project panes (desktop shows them
|
||||
// as permanent columns). Keeps the chat full-width on phones.
|
||||
const [historyOpen, setHistoryOpen] = useState(false);
|
||||
const [filterOpen, setFilterOpen] = useState(false);
|
||||
|
||||
// Initial load — conversations + projects.
|
||||
useEffect(() => {
|
||||
@@ -143,9 +149,9 @@ export function LokiWorkspace() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid min-h-0 flex-1 grid-cols-[16rem_1fr] gap-4 lg:grid-cols-[16rem_1fr_16rem]">
|
||||
{/* LEFT — conversation list */}
|
||||
<aside className="ui-panel min-h-0 p-3">
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-3 md:grid md:grid-cols-[16rem_1fr] md:gap-4 lg:grid-cols-[16rem_1fr_16rem]">
|
||||
{/* LEFT — conversation list (permanent column on md+; a drawer on mobile) */}
|
||||
<aside className="ui-panel hidden min-h-0 p-3 md:block">
|
||||
<ConversationList
|
||||
conversations={visibleConversations}
|
||||
activeId={activeId}
|
||||
@@ -156,9 +162,24 @@ export function LokiWorkspace() {
|
||||
/>
|
||||
</aside>
|
||||
|
||||
{/* CENTER — transcript + composer */}
|
||||
<section className="flex min-h-0 flex-col gap-3">
|
||||
<div className="ui-panel flex min-h-0 flex-1 flex-col px-4 py-3">
|
||||
{/* CENTER — the chat itself, always the primary, full-width on mobile */}
|
||||
<section className="flex min-h-0 flex-1 flex-col gap-2 md:gap-3">
|
||||
{/* Mobile-only toolbar: reach the history + project panes without
|
||||
stealing chat width. Hidden on md+ where they're permanent columns. */}
|
||||
<div className="flex items-center gap-2 md:hidden">
|
||||
<button type="button" className="ui-btn-chip" onClick={() => setHistoryOpen(true)}>
|
||||
<MessagesSquare className="h-4 w-4" /> Chats
|
||||
</button>
|
||||
<button type="button" className="ui-btn-chip" onClick={() => void createConversation()}>
|
||||
<Plus className="h-4 w-4" /> New
|
||||
</button>
|
||||
<button type="button" className="ui-btn-chip ml-auto" onClick={() => setFilterOpen(true)}>
|
||||
<SlidersHorizontal className="h-4 w-4" />
|
||||
Projects{selectedProjects.length > 0 ? ` · ${selectedProjects.length}` : ""}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="ui-panel flex min-h-0 flex-1 flex-col px-3 py-2 md:px-4 md:py-3">
|
||||
<Transcript messages={messages} sending={sending} />
|
||||
</div>
|
||||
{error && <p className="ui-error">{error}</p>}
|
||||
@@ -169,7 +190,7 @@ export function LokiWorkspace() {
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* RIGHT — project multi-select (hidden below lg to keep the transcript usable) */}
|
||||
{/* RIGHT — project multi-select (permanent column on lg+; a drawer on mobile) */}
|
||||
<aside className="ui-panel hidden min-h-0 p-3 lg:block">
|
||||
<ProjectFilter
|
||||
projects={projects}
|
||||
@@ -178,6 +199,34 @@ export function LokiWorkspace() {
|
||||
onToggle={toggleProject}
|
||||
/>
|
||||
</aside>
|
||||
|
||||
{/* Mobile slide-overs */}
|
||||
{historyOpen && (
|
||||
<Drawer onClose={() => setHistoryOpen(false)} size="md">
|
||||
<div className="flex min-h-0 flex-1 flex-col p-3">
|
||||
<ConversationList
|
||||
conversations={visibleConversations}
|
||||
activeId={activeId}
|
||||
loading={convosLoading}
|
||||
onSelect={(id) => { setActiveId(id); setHistoryOpen(false); }}
|
||||
onNew={() => { void createConversation(); setHistoryOpen(false); }}
|
||||
onDelete={(id) => void deleteConversation(id)}
|
||||
/>
|
||||
</div>
|
||||
</Drawer>
|
||||
)}
|
||||
{filterOpen && (
|
||||
<Drawer onClose={() => setFilterOpen(false)} size="md">
|
||||
<div className="flex min-h-0 flex-1 flex-col p-3">
|
||||
<ProjectFilter
|
||||
projects={projects}
|
||||
selected={selectedProjects}
|
||||
loading={projectsLoading}
|
||||
onToggle={toggleProject}
|
||||
/>
|
||||
</div>
|
||||
</Drawer>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user