Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/desktop/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/labstack/echo/v4 v4.16.1 h1:h05NuF1GvNu6jSAZxOv++AdjD/NJK+mZdGy0thiiuns=
github.com/labstack/echo/v4 v4.16.1/go.mod h1:V/EQaTVHYJH92QhbQe7kFQ4mjgcjxLQQUQtAN87zZdw=
github.com/labstack/echo/v4 v4.16.3 h1:wAzM49wiBxHpZJQ621lminvdxbwfd1Cn6KwRThKV6nA=
github.com/labstack/echo/v4 v4.16.3/go.mod h1:V/EQaTVHYJH92QhbQe7kFQ4mjgcjxLQQUQtAN87zZdw=
github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c=
Expand Down
41 changes: 27 additions & 14 deletions apps/web/src/components/Rail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from "../lib/updates";
import { subscribe } from "../lib/events";
import { deriveKey, initials } from "../lib/text";
import { useNav } from "../stores/nav";
import { useNarrow, useNav } from "../stores/nav";
import {
setProjectOrder,
setProjectSort,
Expand Down Expand Up @@ -120,7 +120,7 @@ function ProjectRow(props: {
aria-label={expanded() ? "Hide channels" : "Show channels"}
aria-expanded={expanded()}
onClick={() => setManual(!expanded())}
class="hidden shrink-0 rounded p-0.5 text-faint transition-colors hover:text-fg sm:block"
class="shrink-0 rounded p-0.5 text-faint transition-colors hover:text-fg"
>
<ChevronDownIcon
class={`h-3 w-3 transition-transform ${expanded() ? "" : "-rotate-90"}`}
Expand Down Expand Up @@ -739,7 +739,11 @@ function CollapsedRail(props: { onExpand: () => void }) {
export function Rail() {
const session = useSession();
const projects = useProjects();
const { navOpen, closeNav } = useNav();
const { navOpen, openNav, closeNav } = useNav();
const narrow = useNarrow();
// On a phone the aside is either the icon rail or the overlay drawer.
// Desktop keeps the resizable column. The drawer sits above thread panels.
const drawer = () => narrow() && navOpen();
const [creating, setCreating] = createSignal(false);
onMount(refreshUnread);
const unsub = subscribe((e) => {
Expand Down Expand Up @@ -842,27 +846,32 @@ export function Rail() {

return (
<>
<Show when={navOpen()}>
<Show when={drawer()}>
<button
type="button"
aria-label="Close navigation"
onClick={closeNav}
class="fixed inset-0 z-30 bg-black/40 md:hidden"
class="fixed inset-0 z-[65] bg-black/50"
/>
{/* Keep the icon-rail slot so the chat does not jump under the drawer. */}
<div class="w-14 shrink-0" />
</Show>
<aside
class={`relative flex shrink-0 flex-col border-r border-border bg-rail ${
navOpen()
? "fixed inset-y-0 left-0 z-40 w-64 shadow-2xl"
: "hidden md:flex"
drawer()
? "fixed inset-y-0 left-0 z-[70] w-64 shadow-2xl"
: ""
}`}
style={
navOpen()
drawer()
? undefined
: { width: collapsed() ? "3.5rem" : `${railW()}px` }
: {
width:
narrow() || collapsed() ? "3.5rem" : `${railW()}px`,
}
}
>
<Show when={!collapsed() && !navOpen()}>
<Show when={!narrow() && !collapsed() && !navOpen()}>
<div
class="absolute inset-y-0 right-0 z-10 w-1.5 cursor-col-resize transition-colors hover:bg-accent/40"
onPointerDown={startDrag}
Expand All @@ -871,7 +880,7 @@ export function Rail() {
aria-label="Resize sidebar"
/>
</Show>
<Show when={!collapsed() && !navOpen()}>
<Show when={!narrow() && !collapsed() && !navOpen()}>
<div class="absolute right-2 top-2.5 z-10">
<Tip text="Collapse sidebar" hint="Shrink to icons — badges stay visible">
<button
Expand All @@ -886,8 +895,12 @@ export function Rail() {
</div>
</Show>
<Show
when={!collapsed() || navOpen()}
fallback={<CollapsedRail onExpand={toggleCollapsed} />}
when={drawer() || (!narrow() && !collapsed())}
fallback={
<CollapsedRail
onExpand={() => (narrow() ? openNav() : toggleCollapsed())}
/>
}
>
<WorkspaceSwitcher />

Expand Down
112 changes: 94 additions & 18 deletions apps/web/src/features/conversations/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import { loadNameColors, nameColorFor } from "../../lib/namecolors";
import { attachmentMarker, stripMarkerText } from "../../lib/markers";
import { tagChip } from "../../lib/tagcolor";
import { mediaURL, net } from "../../lib/net";
import { horizontalSwipe } from "../../lib/swipe";
import { useNarrow } from "../../stores/nav";
import {
isQueuedError,
queuedMessages,
Expand Down Expand Up @@ -1903,9 +1905,8 @@ function MessageRow(props: {
// Touch devices have no hover: tapping the row toggles the toolbar.
const [tapped, setTapped] = createSignal(false);

// Swipe-right on a message replies to it (Discord mobile parity). The
// gesture only engages once horizontal intent is clear, so vertical
// scrolling is untouched; past 56px on release fires the reply.
// Swipe right replies. Swipe left opens the thread, or the create
// dialog when the message has none. Vertical scrolling stays a scroll.
const [swipeX, setSwipeX] = createSignal(0);
let touchStart: { x: number; y: number } | null = null;
let swipeActive = false;
Expand All @@ -1922,16 +1923,27 @@ function MessageRow(props: {
const dx = t.clientX - touchStart.x;
const dy = t.clientY - touchStart.y;
if (!swipeActive) {
if (dx > 10 && Math.abs(dy) < dx * 0.6) swipeActive = true;
else if (Math.abs(dy) > 10) touchStart = null;
if (Math.abs(dx) > 10 && Math.abs(dy) < Math.abs(dx) * 0.6) {
swipeActive = true;
} else if (Math.abs(dy) > 10) touchStart = null;
else return;
}
if (swipeActive) setSwipeX(Math.min(dx, 72));
if (swipeActive) setSwipeX(Math.max(-72, Math.min(dx, 72)));
};
const onTouchEnd = () => {
if (swipeActive && swipeX() > 56) {
props.onReply(m());
didSwipe = true;
if (touchStart) {
const dx = swipeX();
const intent = horizontalSwipe(dx, 0);
if (swipeActive && intent === "right") {
props.onReply(m());
didSwipe = true;
} else if (swipeActive && intent === "left") {
const thread = m().thread;
if (thread && props.onOpenThread) props.onOpenThread(thread);
else setThreadOpen(true);
didSwipe = true;
navigator.vibrate?.(8);
}
}
setSwipeX(0);
touchStart = null;
Expand Down Expand Up @@ -1968,19 +1980,38 @@ function MessageRow(props: {
}

return (
<div class="relative">
<div
aria-hidden="true"
class="pointer-events-none absolute inset-y-0 left-3 z-0 flex items-center text-accent-ink"
style={{ opacity: swipeX() > 12 ? "1" : "0" }}
>
<ReplyIcon class="h-4 w-4" />
</div>
<div
aria-hidden="true"
class="pointer-events-none absolute inset-y-0 right-3 z-0 flex items-center text-accent-ink"
style={{ opacity: swipeX() < -12 ? "1" : "0" }}
>
<ThreadIcon class="h-4 w-4" />
</div>
<div
id={`msg-${m().id}`}
class={
(bubbles()
? `group relative flex px-4 ${
? `group relative flex bg-bg px-4 ${
mine() ? "justify-end" : "justify-start"
} ${props.grouped ? "py-[1px]" : "mt-2 py-[1px]"}`
: `group relative flex gap-3 px-4 hover:bg-hover/60 ${
: `group relative flex gap-3 bg-bg px-4 hover:bg-hover/60 ${
props.grouped ? "py-[2px]" : "mt-3 py-1"
}`) +
(props.highlighted ? " rounded-xl bg-hover transition-colors" : " transition-colors")
}
style={swipeX() > 0 ? { transform: `translateX(${swipeX()}px)` } : undefined}
style={
swipeX() !== 0
? { transform: `translateX(${swipeX()}px)` }
: undefined
}
onTouchStart={onTouchStart}
onTouchMove={onTouchMove}
onTouchEnd={onTouchEnd}
Expand Down Expand Up @@ -2534,6 +2565,7 @@ function MessageRow(props: {
)}
</Show>
</div>
</div>
);
}

Expand Down Expand Up @@ -4806,6 +4838,9 @@ function ConversationThread(props: {
</button>
</div>
</div>
<p class="mt-1.5 px-1 text-[11px] text-faint sm:hidden">
Swipe right to reply · swipe left for the thread
</p>
<input
ref={(el) => {
fileEl = el;
Expand Down Expand Up @@ -4987,16 +5022,30 @@ function ThreadPanel(props: {
thread: ThreadSummary;
onClose: () => void;
}) {
const narrow = useNarrow();
const [width, setWidth] = createSignal(threadWidth());
const [full, setFull] = createSignal(false);
const [idCopied, setIdCopied] = createSignal(false);
const [expiryOpen, setExpiryOpen] = createSignal(false);
const [expiresAt, setExpiresAt] = createSignal<string | null | undefined>(
undefined,
);
// reply_count arrives as a snapshot in ThreadSummary; the panel is open
// while replies land, so it tracks thread.updated frames itself.
const [replyCount, setReplyCount] = createSignal(props.thread.reply_count);
let expiryWrapEl: HTMLDivElement | undefined;
let dragging = false;

onMount(() =>
onCleanup(
subscribe((e) => {
if (e.type !== "thread.updated" && e.type !== "thread.created") return;
const t = e.data?.thread as Thread | undefined;
if (t?.id === props.thread.id) setReplyCount(t.reply_count);
}),
),
);

createEffect(() => {
if (!expiryOpen()) return;
// read current expiry once per open — the index endpoint already lists it
Expand Down Expand Up @@ -5063,14 +5112,42 @@ function ThreadPanel(props: {
onMount(() => window.addEventListener("keydown", onKey));
onCleanup(() => window.removeEventListener("keydown", onKey));

// Swipe right closes the thread. The gesture ignores fields so a
// composer drag does not dismiss the panel.
let swipeStart: { x: number; y: number } | null = null;
const onSwipeStart = (e: TouchEvent) => {
const t = e.touches[0];
const el = e.target as HTMLElement | null;
if (!t || el?.closest("textarea, input, button, a")) {
swipeStart = null;
return;
}
swipeStart = { x: t.clientX, y: t.clientY };
};
const onSwipeEnd = (e: TouchEvent) => {
const start = swipeStart;
swipeStart = null;
const t = e.changedTouches[0];
if (!start || !t) return;
if (horizontalSwipe(t.clientX - start.x, t.clientY - start.y, 72) === "right") {
props.onClose();
}
};

// Cover the conversation column, never the app rail or the top bar.
// Fullscreen and phones overlay the chat; sm+ sits beside it.
const overlay = () => full() || narrow();

return (
<div
class={
full()
? "fixed inset-0 z-50 flex flex-col bg-surface"
: "thread-rail fixed inset-0 z-40 flex flex-col bg-surface sm:relative sm:z-auto sm:shrink-0 sm:border-l sm:border-border"
overlay()
? "absolute inset-0 z-20 flex flex-col bg-surface"
: "thread-rail relative z-auto shrink-0 border-l border-border bg-surface"
}
style={{ "--thread-w": `${width()}px` }}
onTouchStart={onSwipeStart}
onTouchEnd={onSwipeEnd}
>
<div
role="separator"
Expand All @@ -5091,8 +5168,7 @@ function ThreadPanel(props: {
{props.thread.title || "Thread"}
</p>
<p class="text-[10.5px] text-faint">
{props.thread.reply_count}{" "}
{props.thread.reply_count === 1 ? "reply" : "replies"}
{replyCount()} {replyCount() === 1 ? "reply" : "replies"}
</p>
</div>
<div class="relative" ref={(el) => (expiryWrapEl = el)}>
Expand Down Expand Up @@ -5245,7 +5321,7 @@ export function Conversation(props: {
}
>
{(c) => (
<div class="flex min-h-0 min-w-0 flex-1">
<div class="relative flex min-h-0 min-w-0 flex-1">
<ConversationThread
conversationId={c.id}
projectId={props.projectId}
Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/features/projects/ChannelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { confirmDestructive } from "../../components/Confirm";
import { Spinner, Tip } from "../../components/ui";
import {
CheckIcon,
ChevronLeftIcon,
InboxIcon,
LinkIcon,
LockIcon,
Expand Down Expand Up @@ -103,6 +104,14 @@ export default function ChannelPage() {
return (
<div class="flex h-full min-h-0 flex-col">
<header class="flex h-14 shrink-0 items-center gap-2 border-b border-border px-3 sm:px-4">
<button
type="button"
aria-label="Back to project"
onClick={() => navigate(`/app/p/${params.projectId}`)}
class="flex h-8 w-8 items-center justify-center rounded-md text-muted transition-colors hover:bg-hover hover:text-fg md:hidden"
>
<ChevronLeftIcon class="h-4 w-4" />
</button>
<span class="text-[15px] text-faint">#</span>
<Show
when={!renaming()}
Expand Down
19 changes: 19 additions & 0 deletions apps/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,22 @@ html {
}
}

/* Phones in light mode were a sheet of near-white. Keep the type dark and
pull the canvas and rail down so chat, nav and composer separate.
Desktop light mode is unchanged. */
@media (max-width: 767.98px) {
:root:not(.dark) {
--bg: #d5d0c6;
--rail: #c8c2b6;
--surface: #f3f0e8;
--surface-2: #e6e1d6;
--fg: #14161a;
--muted: #3c4350;
--faint: #5e6672;
--border: #b5aea2;
--border-hi: #9e978b;
--hover: rgb(16 19 24 / 0.08);
--code-bg: #e4dfd4;
}
}

Loading