Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(issues): sticky setting for the issue comment bar (MUL-4435) (#5293)
Jiayuan Zhang80e54094a87f
diff --git a/packages/core/issues/stores/comment-composer-store.test.ts b/packages/core/issues/stores/comment-composer-store.test.tsnew file mode 100644index 0000000000..26e3e41fe2--- /dev/null+++ b/packages/core/issues/stores/comment-composer-store.test.ts@@ -0,0 +1,40 @@+// @vitest-environment jsdom+import { beforeAll, beforeEach, describe, expect, it } from "vitest";+import { useCommentComposerStore } from "./comment-composer-store";++// Node 25 ships a partial `localStorage` shim under jsdom that's missing+// `clear`/`removeItem`; replace it with a real in-memory Storage so persist+// can round-trip values.+beforeAll(() => {+ if (typeof globalThis.localStorage?.setItem !== "function") {+ const values = new Map<string, string>();+ const storage: Storage = {+ get length() { return values.size; },+ clear: () => values.clear(),+ getItem: (k) => values.get(k) ?? null,+ key: (i) => Array.from(values.keys())[i] ?? null,+ removeItem: (k) => { values.delete(k); },+ setItem: (k, v) => { values.set(k, v); },+ };+ Object.defineProperty(globalThis, "localStorage", { configurable: true, value: storage });+ Object.defineProperty(window, "localStorage", { configurable: true, value: storage });+ }+});++describe("comment composer store", () => {+ beforeEach(() => {+ useCommentComposerStore.setState({ sticky: true });+ });++ it("defaults to sticky", () => {+ expect(useCommentComposerStore.getState().sticky).toBe(true);+ });++ it("toggleSticky flips the preference", () => {+ useCommentComposerStore.getState().toggleSticky();+ expect(useCommentComposerStore.getState().sticky).toBe(false);++ useCommentComposerStore.getState().toggleSticky();+ expect(useCommentComposerStore.getState().sticky).toBe(true);+ });+});diff --git a/packages/core/issues/stores/comment-composer-store.ts b/packages/core/issues/stores/comment-composer-store.tsnew file mode 100644index 0000000000..b93a1eef18--- /dev/null+++ b/packages/core/issues/stores/comment-composer-store.ts@@ -0,0 +1,29 @@+import { create } from "zustand";+import { createJSONStorage, persist } from "zustand/middleware";+import { defaultStorage } from "../../platform/storage";++/**+ * Display preferences for the issue-detail comment composer.+ *+ * `sticky` pins the bottom comment bar to the scroll viewport so it stays+ * reachable while reading a long timeline. It's a personal reading-ergonomics+ * preference (like theme), so it persists globally via `defaultStorage`+ * rather than per-workspace storage.+ */+interface CommentComposerStore {+ sticky: boolean;+ toggleSticky: () => void;+}++export const useCommentComposerStore = create<CommentComposerStore>()(+ persist(+ (set) => ({+ sticky: true,+ toggleSticky: () => set((s) => ({ sticky: !s.sticky })),+ }),+ {+ name: "multica_comment_composer",+ storage: createJSONStorage(() => defaultStorage),+ },+ ),+);diff --git a/packages/core/issues/stores/index.ts b/packages/core/issues/stores/index.tsindex 27a7306050..cdae4ae81c 100644--- a/packages/core/issues/stores/index.ts+++ b/packages/core/issues/stores/index.ts@@ -17,6 +17,7 @@ export {} from "./view-store-context";export { useIssuesScopeStore, type IssuesScope } from "./issues-scope-store";export { useCommentCollapseStore } from "./comment-collapse-store";+export { useCommentComposerStore } from "./comment-composer-store";export { useCommentDraftStore, type CommentDraftKey } from "./comment-draft-store";export {myIssuesViewStore,diff --git a/packages/views/issues/components/comment-composers.test.tsx b/packages/views/issues/components/comment-composers.test.tsxindex ba4e301bae..9c344c17f1 100644--- a/packages/views/issues/components/comment-composers.test.tsx+++ b/packages/views/issues/components/comment-composers.test.tsx@@ -3,6 +3,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { describe, it, expect, vi, beforeEach } from "vitest";import { fireEvent, screen, waitFor } from "@testing-library/react";import type { UploadResult } from "@multica/core/hooks/use-file-upload";+import { useCommentComposerStore } from "@multica/core/issues/stores";import { renderWithI18n } from "../../test/i18n";import { CommentInput } from "./comment-input";import { ReplyInput } from "./reply-input";@@ -114,7 +115,9 @@ function renderReplyInput({}function getSubmitButton(container: HTMLElement): HTMLButtonElement {- const button = container.querySelectorAll("button")[1];+ // Submit is always the last button in a composer's action cluster.+ const buttons = container.querySelectorAll("button");+ const button = buttons[buttons.length - 1];if (!button) throw new Error("Expected submit button to render");return button;}@@ -122,6 +125,7 @@ function getSubmitButton(container: HTMLElement): HTMLButtonElement {beforeEach(() => {uploadWithToast.mockReset();localStorage.clear();+ useCommentComposerStore.setState({ sticky: true });});describe("comment composers", () => {@@ -223,3 +227,19 @@ describe("comment composers", () => {await waitFor(() => expect(getSubmitButton(container)).not.toBeDisabled());});});++describe("sticky composer preference", () => {+ it("caps the editor height while the sticky preference is on (default)", () => {+ renderCommentInput();++ // The height cap lives on the editor wrapper, not the card shell.+ expect(screen.getByTestId("editor").parentElement?.className).toContain("max-h-[40vh]");+ });++ it("lets the editor grow when the preference is off", () => {+ useCommentComposerStore.setState({ sticky: false });+ renderCommentInput();++ expect(screen.getByTestId("editor").parentElement?.className).not.toContain("max-h-[40vh]");+ });+});diff --git a/packages/views/issues/components/comment-input.tsx b/packages/views/issues/components/comment-input.tsxindex aa6bb0a117..f80f84fa5a 100644--- a/packages/views/issues/components/comment-input.tsx+++ b/packages/views/issues/components/comment-input.tsx@@ -10,7 +10,7 @@ import { api } from "@multica/core/api";import type { Attachment } from "@multica/core/types";import { contentReferencesAttachment } from "@multica/core/types";import { formatShortcut, useShortcut } from "@multica/core/shortcuts";-import { useCommentDraftStore } from "@multica/core/issues/stores";+import { useCommentComposerStore, useCommentDraftStore } from "@multica/core/issues/stores";import { useT } from "../../i18n";import { CommentTriggerChips } from "./comment-trigger-chips";import { useCommentTriggerPreview } from "../hooks/use-comment-trigger-preview";@@ -47,6 +47,9 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {const { isDragOver, dropZoneProps } = useFileDropZone({onDrop: (files) => files.forEach((f) => editorRef.current?.uploadFile(f)),});+ // Sticky preference (Settings → Preferences): issue-detail pins this+ // composer to the bottom of the scroll viewport when enabled.+ const sticky = useCommentComposerStore((s) => s.sticky);// Draft persistence. Hydrate from store on mount via `defaultValue` above// (ContentEditorRef has no setContent, so this is the only injection point).@@ -147,6 +150,10 @@ function CommentInput({ issueId, onSubmit }: CommentInputProps) {<divclassName={cn("flex-1 min-h-0 overflow-y-auto px-3 py-2",+ // Pinned to the viewport bottom the composer grows upward; cap it+ // so a long draft can't swallow the whole timeline (the editor+ // area scrolls internally instead).+ sticky && "max-h-[40vh]",submitting && "pointer-events-none opacity-60",)}aria-busy={submitting || undefined}diff --git a/packages/views/issues/components/issue-detail.test.tsx b/packages/views/issues/components/issue-detail.test.tsxindex df78b1d242..57ffae2c66 100644--- a/packages/views/issues/components/issue-detail.test.tsx+++ b/packages/views/issues/components/issue-detail.test.tsx@@ -298,6 +298,15 @@ vi.mock("@multica/core/issues/stores", () => ({}),},),+ useCommentComposerStore: Object.assign(+ (selector?: any) => {+ const state = { sticky: true, toggleSticky: () => {} };+ return selector ? selector(state) : state;+ },+ {+ getState: () => ({ sticky: true, toggleSticky: () => {} }),+ },+ ),}));// Mock react-virtuoso: jsdom has no real layout, so the real Virtuoso woulddiff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 69847f9c19..c41efacf7d 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -75,7 +75,7 @@ import { projectDetailOptions } from "@multica/core/projects/queries";import { ProjectIcon } from "../../projects/components/project-icon";import { issueLabelsOptions } from "@multica/core/labels";import { memberListOptions, agentListOptions } from "@multica/core/workspace/queries";-import { useRecentIssuesStore } from "@multica/core/issues/stores";+import { useCommentComposerStore, useRecentIssuesStore } from "@multica/core/issues/stores";import { useIssueSelectionStore } from "@multica/core/issues/stores/selection-store";import { BatchActionToolbar } from "./batch-action-toolbar";import { useIssueTimeline } from "../hooks/use-issue-timeline";@@ -775,6 +775,8 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr// that: setState triggers the re-render that hands Virtuoso the element.const [scrollContainerEl, setScrollContainerEl] = useState<HTMLDivElement | null>(null);const [highlightedId, setHighlightedId] = useState<string | null>(null);+ // User preference: pin the bottom comment bar to the scroll viewport.+ const stickyComposer = useCommentComposerStore((s) => s.sticky);// Per-session: which resolved threads the user has temporarily expanded.// Not persisted (matches Linear) — reload collapses everything back to bars.@@ -2287,15 +2289,34 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr))}- {/* Bottom comment input — no avatar, full width */}- <div className="mt-4">- {/* key={id}: web's /issues/[id] route doesn't remount on- issueId change, so without an explicit key the editor- keeps the previous issue's in-memory content and the- next keystroke would flush it into the new issue's- draft key. */}- <CommentInput key={id} issueId={id} onSubmit={submitComment} />- </div>+ </div>++ {/* Bottom comment input — no avatar, full width. Direct child of+ the content column (not the Activity section): a sticky box+ can't leave its containing block, and the Activity div only+ spans the timeline — at column level `sticky bottom-0` can pin+ the composer across the whole scroll range.++ Sticky treatment mirrors list-grid's sticky header, bottom+ edge: opaque bg-background under/around the card (its rounded+ corners would otherwise leak scrolled text), a 16px gradient+ fade above (exactly the mt-4 gap, so at rest it sits over the+ page background and is invisible), and pb-4 so the card floats+ off the viewport edge — with -mb-4 giving the padding back to+ the column's py-8 so the at-rest layout doesn't shift. */}+ <div+ className={cn(+ "mt-4",+ stickyComposer &&+ "sticky bottom-0 z-10 -mb-4 bg-background pb-4 before:pointer-events-none before:absolute before:inset-x-0 before:bottom-full before:h-4 before:bg-gradient-to-t before:from-background before:to-transparent",+ )}+ >+ {/* key={id}: web's /issues/[id] route doesn't remount on+ issueId change, so without an explicit key the editor+ keeps the previous issue's in-memory content and the+ next keystroke would flush it into the new issue's+ draft key. */}+ <CommentInput key={id} issueId={id} onSubmit={submitComment} /></div></div></div>diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex 78bfcac805..856372a176 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -26,6 +26,10 @@"browser_suffix": " (browser)","hint": "Used for dashboards, charts, and any 'today' label shown to you. It's a personal preference that applies across all your workspaces.","sync_failed": "Failed to save your timezone preference."+ },+ "sticky_comment_bar": {+ "title": "Sticky comment bar",+ "hint": "Keep the comment bar pinned to the bottom while scrolling an issue page."}},"shortcuts": {diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex b595359ccc..a268fbec5c 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -26,6 +26,10 @@"browser_suffix": " (ブラウザ)","hint": "ダッシュボード、チャート、表示される「今日」ラベルに使用されます。すべてのワークスペースに適用される個人設定です。","sync_failed": "タイムゾーン設定を保存できませんでした。"+ },+ "sticky_comment_bar": {+ "title": "コメントバーを固定",+ "hint": "イシューのページをスクロールしても、コメントバーを常に下部に固定します。"}},"shortcuts": {diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex a7de2a3fb5..9749b37738 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -26,6 +26,10 @@"browser_suffix": " (브라우저)","hint": "대시보드, 차트, 사용자에게 표시되는 '오늘' 레이블에 사용됩니다. 모든 워크스페이스에 적용되는 개인 설정입니다.","sync_failed": "시간대 설정을 저장하지 못했습니다."+ },+ "sticky_comment_bar": {+ "title": "댓글 입력창 고정",+ "hint": "이슈 페이지를 스크롤할 때 댓글 입력창을 항상 하단에 고정합니다."}},"shortcuts": {diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex d6ccc1a7cc..9fa864d497 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -26,6 +26,10 @@"browser_suffix": "(浏览器)","hint": "用于仪表盘、图表和「今天」标签。这是个人偏好,在你的所有工作区中通用。","sync_failed": "保存时区偏好失败。"+ },+ "sticky_comment_bar": {+ "title": "固定评论栏",+ "hint": "滚动 issue 页面时,评论栏始终固定在底部。"}},"shortcuts": {diff --git a/packages/views/settings/components/preferences-tab.test.tsx b/packages/views/settings/components/preferences-tab.test.tsxindex 7f0ff3a3bd..72d2973d25 100644--- a/packages/views/settings/components/preferences-tab.test.tsx+++ b/packages/views/settings/components/preferences-tab.test.tsx@@ -81,6 +81,7 @@ vi.mock("@multica/core/auth", async () => {});import { PreferencesTab } from "./preferences-tab";+import { useCommentComposerStore } from "@multica/core/issues/stores";const TEST_RESOURCES = {en: { common: enCommon, auth: enAuth, settings: enSettings },@@ -311,3 +312,29 @@ describe("PreferencesTab — Timezone section", () => {});});});++describe("PreferencesTab — Sticky comment bar", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ userRef.current = null;+ useCommentComposerStore.setState({ sticky: true });+ });++ afterEach(() => {+ cleanup();+ });++ it("renders on by default and toggles the preference off with a saved toast", async () => {+ const user = userEvent.setup();+ render(<PreferencesTab />, { wrapper: I18nWrapper });++ const toggle = screen.getByRole("switch", { name: "Sticky comment bar" });+ expect(toggle).toHaveAttribute("aria-checked", "true");++ await user.click(toggle);++ expect(useCommentComposerStore.getState().sticky).toBe(false);+ expect(toggle).toHaveAttribute("aria-checked", "false");+ expect(mockToastSuccess).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/views/settings/components/preferences-tab.tsx b/packages/views/settings/components/preferences-tab.tsxindex 70a8506ace..2bc8331616 100644--- a/packages/views/settings/components/preferences-tab.tsx+++ b/packages/views/settings/components/preferences-tab.tsx@@ -9,6 +9,7 @@ import {SelectTrigger,SelectValue,} from "@multica/ui/components/ui/select";+import { Switch } from "@multica/ui/components/ui/switch";import { useTheme } from "@multica/ui/components/common/theme-provider";import {DEFAULT_LOCALE,@@ -17,6 +18,7 @@ import {} from "@multica/core/i18n";import { useLocaleAdapter } from "@multica/core/i18n/react";import { useAuthStore } from "@multica/core/auth";+import { useCommentComposerStore } from "@multica/core/issues/stores";import { api } from "@multica/core/api";import { browserTimezone, timezoneOptions } from "../../common/timezone-select";import { useT } from "../../i18n";@@ -157,12 +159,38 @@ export function PreferencesTab() {</SettingsRow><TimezoneRow />++ <StickyCommentBarRow /></SettingsCard></SettingsSection></SettingsTab>);}+function StickyCommentBarRow() {+ const { t } = useT("settings");+ const sticky = useCommentComposerStore((s) => s.sticky);+ const toggleSticky = useCommentComposerStore((s) => s.toggleSticky);++ return (+ <SettingsRow+ label={t(($) => $.preferences.sticky_comment_bar.title)}+ description={t(($) => $.preferences.sticky_comment_bar.hint)}+ >+ <Switch+ checked={sticky}+ onCheckedChange={() => {+ toggleSticky();+ toast.success(t(($) => $.auto_save.toast_saved), {+ id: "settings-auto-save",+ });+ }}+ aria-label={t(($) => $.preferences.sticky_comment_bar.title)}+ />+ </SettingsRow>+ );+}+// Base UI rejects "" as a SelectItem value, so route the "no preference"// state through this sentinel and translate at the wire boundary.const BROWSER_TZ_VALUE = "__browser__";