Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat(community): add forum archive tag (#570)
Generae035fc6baf4
diff --git a/src/shared/src/constants/community.ts b/src/shared/src/constants/community.tsindex 28986624b..2422993ec 100644--- a/src/shared/src/constants/community.ts+++ b/src/shared/src/constants/community.ts@@ -17,6 +17,7 @@ export const MAX_PROFILE_ABOUT_LENGTH = 1000// Short by design — this is a status term ("Vibing"), not a bio.export const MAX_STATUS_TEXT_LENGTH = 60export const MAX_MESSAGE_CONTENT_LENGTH = 4000+export const FORUM_ARCHIVE_TAG = "archived"export const MAX_FORUM_TAG_LENGTH = 30export const MAX_FORUM_TAGS_PER_POST = 5diff --git a/src/shared/src/db/queries/community/thread.ts b/src/shared/src/db/queries/community/thread.tsindex f8c656023..fac696c7b 100644--- a/src/shared/src/db/queries/community/thread.ts+++ b/src/shared/src/db/queries/community/thread.ts@@ -1,9 +1,9 @@-import { and, asc, desc, eq, gt, inArray, isNotNull, lt, lte, or, sql } from "drizzle-orm";+import { and, asc, desc, eq, exists, gt, inArray, isNotNull, lt, lte, notExists, or, sql } from "drizzle-orm";import { communityChannel, communityChannelMember, communityMessageTag } from "../../community-schema";import { user } from "../../schema";import type { Database } from "../../index";import { chunk, maxRowsPerInsert, D1_MAX_IN_PARAMS } from "../_chunk";-import { type ParticipantSource } from "../../../constants/community";+import { FORUM_ARCHIVE_TAG, type ParticipantSource } from "../../../constants/community";import { compareAsciiSqliteBinary } from "../../../lib/sqlite-binary";// The NOTIFICATION set for a child thread — relation='notify' rows@@ -308,6 +308,28 @@ export async function listForumThreadsByCreatedAt(eq(communityChannel.archived, 0),isNotNull(communityChannel.parentMessageId),];+ const archiveTagQuery = db+ .select({ messageId: communityMessageTag.messageId })+ .from(communityMessageTag)+ .where(and(+ eq(communityMessageTag.messageId, communityChannel.parentMessageId),+ eq(communityMessageTag.tag, FORUM_ARCHIVE_TAG)+ ));+ if (params.tag === FORUM_ARCHIVE_TAG) {+ conditions.push(exists(archiveTagQuery));+ } else {+ conditions.push(notExists(archiveTagQuery));+ }+ if (params.tag && params.tag !== FORUM_ARCHIVE_TAG) {+ const selectedTagQuery = db+ .select({ messageId: communityMessageTag.messageId })+ .from(communityMessageTag)+ .where(and(+ eq(communityMessageTag.messageId, communityChannel.parentMessageId),+ eq(communityMessageTag.tag, params.tag)+ ));+ conditions.push(exists(selectedTagQuery));+ }if (params.cursor) {conditions.push(or(lt(communityChannel.createdAt, params.cursor.createdAt),@@ -336,22 +358,6 @@ export async function listForumThreadsByCreatedAt(activityAt: activityAt.as("activity_at"),} as const;- if (params.tag) {- return db- .select(select)- .from(communityChannel)- .innerJoin(- communityMessageTag,- and(- eq(communityMessageTag.messageId, communityChannel.parentMessageId),- eq(communityMessageTag.tag, params.tag)- )- )- .where(and(...conditions))- .orderBy(desc(communityChannel.createdAt), desc(communityChannel.id))- .limit(params.limit);- }-return db.select(select).from(communityChannel)diff --git a/src/shared/src/index.ts b/src/shared/src/index.tsindex 43df445bb..3a0e5266d 100644--- a/src/shared/src/index.ts+++ b/src/shared/src/index.ts@@ -139,6 +139,7 @@ export {MAX_PROFILE_ABOUT_LENGTH,MAX_STATUS_TEXT_LENGTH,MAX_MESSAGE_CONTENT_LENGTH,+ FORUM_ARCHIVE_TAG,MAX_FORUM_TAG_LENGTH,MAX_FORUM_TAGS_PER_POST,MAX_EMOJI_BYTES,diff --git a/src/shared/test/queries/community-thread.test.ts b/src/shared/test/queries/community-thread.test.tsindex 89f7c1d3c..415234b29 100644--- a/src/shared/test/queries/community-thread.test.ts+++ b/src/shared/test/queries/community-thread.test.ts@@ -4,6 +4,7 @@ import { drizzle as drizzleProxy } from "drizzle-orm/sqlite-proxy";import { afterEach, beforeEach, describe, it, expect, vi } from "vitest";import * as threadQueries from "../../src/db/queries/community/thread";import { D1_MAX_BIND_PARAMS } from "../../src/db/queries/_chunk";+import { FORUM_ARCHIVE_TAG } from "../../src/constants/community";describe("community/thread exports", () => {it("exports the participant CRUD", () => {@@ -71,6 +72,7 @@ describe("listForumThreadsByCreatedAt against real SQLite", () => {insertChannel.run("t_tie_b", "tie b", "thread", "forum_1", "m_tie_b", 0, "2026-08-08T04:00:00.000Z", "2026-01-02T00:00:00.000Z");insertChannel.run("t_tie_a", "tie a", "thread", "forum_1", "m_tie_a", 0, "2026-08-08T04:00:00.000Z", "2026-01-02T00:00:00.000Z");insertChannel.run("t_created", "created fallback", "thread", "forum_1", "m_created", 0, null, "2026-08-08T02:00:00.000Z");+ insertChannel.run("t_tag_archived", "tag archived", "thread", "forum_1", "m_tag_archived", 0, null, "2026-08-09T02:00:00.000Z");insertChannel.run("t_archived", "archived", "thread", "forum_1", "m_archived", 1, "2026-08-09T00:00:00.000Z", "2026-01-01T00:00:00.000Z");insertChannel.run("t_rootless", "rootless", "thread", "forum_1", null, 0, "2026-08-09T00:00:00.000Z", "2026-01-01T00:00:00.000Z");insertChannel.run("not_thread", "text child", "text", "forum_1", "m_text", 0, "2026-08-09T00:00:00.000Z", "2026-01-01T00:00:00.000Z");@@ -78,6 +80,8 @@ describe("listForumThreadsByCreatedAt against real SQLite", () => {const insertTag = sqlite.prepare("INSERT INTO community_message_tag (id, message_id, tag) VALUES (?, ?, ?)");insertTag.run("tag_tie", "m_tie_a", "bug");insertTag.run("tag_created", "m_created", "bug");+ insertTag.run("tag_archive", "m_tag_archived", FORUM_ARCHIVE_TAG);+ insertTag.run("tag_archive_bug", "m_tag_archived", "bug");insertTag.run("tag_foreign", "m_foreign", "bug");db = drizzle(sqlite);});@@ -110,6 +114,27 @@ describe("listForumThreadsByCreatedAt against real SQLite", () => {expect(rows.map((row) => row.id)).toEqual(["t_created", "t_tie_a"]);});+ it("treats the archive tag as an exclusive feed before pagination", async () => {+ const all = await threadQueries.listForumThreadsByCreatedAt(db as never, {+ parentChannelId: "forum_1",+ limit: 1,+ });+ const ordinary = await threadQueries.listForumThreadsByCreatedAt(db as never, {+ parentChannelId: "forum_1",+ tag: "bug",+ limit: 5,+ });+ const archived = await threadQueries.listForumThreadsByCreatedAt(db as never, {+ parentChannelId: "forum_1",+ tag: FORUM_ARCHIVE_TAG,+ limit: 5,+ });++ expect(all.map((row) => row.id)).toEqual(["t_created"]);+ expect(ordinary.map((row) => row.id)).toEqual(["t_created", "t_tie_a"]);+ expect(archived.map((row) => row.id)).toEqual(["t_tag_archived"]);+ });+it("uses the forum creation index without a temp B-tree for the untagged feed", () => {const plan = sqlite.prepare(`EXPLAIN QUERY PLANdiff --git a/src/web/src/app/api/community/channels/[id]/threads/route.test.ts b/src/web/src/app/api/community/channels/[id]/threads/route.test.tsindex eb10ef3c9..0e445f11f 100644--- a/src/web/src/app/api/community/channels/[id]/threads/route.test.ts+++ b/src/web/src/app/api/community/channels/[id]/threads/route.test.ts@@ -83,6 +83,7 @@ const ctx = { params: { id: "c1" } } as anydescribe("GET /api/community/channels/[id]/threads", () => {beforeEach(() => {vi.clearAllMocks()+ mockFilterMessageIdsByTag.mockResolvedValue([])mockGetChannel.mockResolvedValue({ id: "c1", serverId: "s1" })mockGetMember.mockResolvedValue({ id: "m1", userId: "u1", serverId: "s1" })// requireChannelAccess resolves through resolveChannelAccessContext — a@@ -155,20 +156,68 @@ describe("GET /api/community/channels/[id]/threads", () => {expect(mockListMessages).not.toHaveBeenCalled()})+ it("keeps non-forum child collections unchanged without querying archive tags", async () => {+ mockResolveChannelAccessContext.mockResolvedValue({+ channel: { id: "c1", serverId: "s1", parentChannelId: null, creatorId: null, type: "text" },+ anchor: { id: "c1", serverId: "s1", parentChannelId: null, creatorId: null, type: "text" },+ role: "member",+ isPrivate: false,+ isChannelMember: false,+ })+ mockListChildChannels.mockResolvedValue([+ { id: "thread_1", parentMessageId: "opener_1" },+ { id: "thread_2", parentMessageId: null },+ ])++ const res = await GET(req(), ctx)++ expect(res.status).toBe(200)+ expect((await res.json()).threads).toEqual([+ { id: "thread_1", parentMessageId: "opener_1" },+ { id: "thread_2", parentMessageId: null },+ ])+ expect(mockFilterMessageIdsByTag).not.toHaveBeenCalled()+ })+it("filters only the scoped child opener candidates for a normalized tag", async () => {mockListChildChannels.mockResolvedValue([{ id: "post_1", parentMessageId: "opener_1" },{ id: "post_2", parentMessageId: "opener_2" },{ id: "plain_thread", parentMessageId: null },])- mockFilterMessageIdsByTag.mockResolvedValue(["opener_2"])+ mockFilterMessageIdsByTag+ .mockResolvedValueOnce([])+ .mockResolvedValueOnce(["opener_2"])const res = await GET(req("http://localhost/api/community/channels/c1/threads?tag=%20BUG%20"), ctx)expect(res.status).toBe(200)- expect(mockFilterMessageIdsByTag).toHaveBeenCalledWith(expect.anything(), ["opener_1", "opener_2"], "bug")+ expect(mockFilterMessageIdsByTag).toHaveBeenNthCalledWith(1, expect.anything(), ["opener_1", "opener_2"], "archived")+ expect(mockFilterMessageIdsByTag).toHaveBeenNthCalledWith(2, expect.anything(), ["opener_1", "opener_2"], "bug")expect((await res.json()).threads).toEqual([{ id: "post_2", parentMessageId: "opener_2" }])})+ it("reuses the archive opener set for the legacy Archived tag filter", async () => {+ mockListChildChannels.mockResolvedValue([+ { id: "post_1", parentMessageId: "opener_1" },+ { id: "post_2", parentMessageId: "opener_2" },+ { id: "plain_thread", parentMessageId: null },+ ])+ mockFilterMessageIdsByTag.mockResolvedValueOnce(["opener_1"])++ const res = await GET(req(+ "http://localhost/api/community/channels/c1/threads?tag=%20ARCHIVED%20",+ ), ctx)++ expect(res.status).toBe(200)+ expect(mockFilterMessageIdsByTag).toHaveBeenCalledTimes(1)+ expect(mockFilterMessageIdsByTag).toHaveBeenCalledWith(+ expect.anything(),+ ["opener_1", "opener_2"],+ "archived",+ )+ expect((await res.json()).threads).toEqual([{ id: "post_1", parentMessageId: "opener_1" }])+ })+it("rejects an empty tag before querying message_tags", async () => {mockListChildChannels.mockResolvedValue([])const res = await GET(req("http://localhost/api/community/channels/c1/threads?tag=%20%20"), ctx)@@ -248,6 +297,19 @@ describe("GET /api/community/channels/[id]/threads", () => {expect(mockFilterMessageIdsByTag).not.toHaveBeenCalled()})+ it("passes the archive system tag through the created-order query scope", async () => {+ mockListForumThreadsByCreatedAt.mockResolvedValue([])+ const res = await GET(req(+ "http://localhost/api/community/channels/c1/threads?order=createdAt&tag=%20ARCHIVED%20&limit=5",+ ), ctx)+ expect(res.status).toBe(200)+ expect(mockListForumThreadsByCreatedAt).toHaveBeenCalledWith(expect.anything(), {+ parentChannelId: "c1",+ tag: "archived",+ limit: 6,+ })+ })+it("rejects malformed and cross-forum created-order cursors without querying children", async () => {const malformed = await GET(req("http://localhost/api/community/channels/c1/threads?order=createdAt&cursor=not-a-cursor",diff --git a/src/web/src/app/api/community/channels/[id]/threads/route.ts b/src/web/src/app/api/community/channels/[id]/threads/route.tsindex 32c05935e..31c5ebc63 100644--- a/src/web/src/app/api/community/channels/[id]/threads/route.ts+++ b/src/web/src/app/api/community/channels/[id]/threads/route.ts@@ -2,7 +2,7 @@ import { NextRequest } from "next/server"import { withAuth } from "@/lib/middleware/auth"import { writeJSON, writeError } from "@/lib/middleware/helpers"import { getDb } from "@/lib/db"-import { isForum, queries, MAX_FORUM_TAG_LENGTH } from "@alook/shared"+import { FORUM_ARCHIVE_TAG, isForum, queries, MAX_FORUM_TAG_LENGTH } from "@alook/shared"import { requireChannelAccess } from "@/lib/community/permissions"import { parseBoundedInt } from "@/lib/community/messages"import { encodeForumCreatedAtCursor, parseForumCreatedAtCursor } from "@/lib/community/forum-feed-cursor"@@ -102,10 +102,25 @@ export const GET = withAuth(async (req: NextRequest, ctx) => {type: "thread",})+ const forum = isForum(access.value.channel.type)+ const openerIds = childChannels.map((child) => child.parentMessageId).filter((id): id is string => !!id)+ const archivedOpeners = forum+ ? new Set(await queries.communityMessageTag.filterMessageIdsByTag(db, openerIds, FORUM_ARCHIVE_TAG))+ : new Set<string>()+if (rawTag !== null) {- const openerIds = childChannels.map((child) => child.parentMessageId).filter((id): id is string => !!id)- const matching = new Set(await queries.communityMessageTag.filterMessageIdsByTag(db, openerIds, tag!))- childChannels = childChannels.filter((child) => !!child.parentMessageId && matching.has(child.parentMessageId))+ const matching = tag === FORUM_ARCHIVE_TAG+ ? archivedOpeners+ : new Set(await queries.communityMessageTag.filterMessageIdsByTag(db, openerIds, tag!))+ childChannels = childChannels.filter((child) => (+ !!child.parentMessageId+ && matching.has(child.parentMessageId)+ && (tag === FORUM_ARCHIVE_TAG || !archivedOpeners.has(child.parentMessageId))+ ))+ } else if (forum) {+ childChannels = childChannels.filter((child) => (+ !child.parentMessageId || !archivedOpeners.has(child.parentMessageId)+ ))}// Plain nested collection representation. View-specific parent previews,diff --git a/src/web/src/app/api/community/messages/[id]/tags/route.test.ts b/src/web/src/app/api/community/messages/[id]/tags/route.test.tsindex 16ee3d766..fb7a4fa9a 100644--- a/src/web/src/app/api/community/messages/[id]/tags/route.test.ts+++ b/src/web/src/app/api/community/messages/[id]/tags/route.test.ts@@ -5,6 +5,7 @@ const mockGetMessage = vi.fn()const mockGetThread = vi.fn()const mockReplaceTags = vi.fn()const mockRequireChannelAccess = vi.fn()+const mockFanOutToChannel = vi.fn()vi.mock("@/lib/db", () => ({ getDb: vi.fn(() => ({})) }))vi.mock("@alook/shared", async () => {@@ -25,6 +26,9 @@ vi.mock("@alook/shared", async () => {vi.mock("@/lib/community/permissions", () => ({requireChannelAccess: (...args: unknown[]) => mockRequireChannelAccess(...args),}))+vi.mock("@/lib/community/fanout", () => ({+ fanOutToChannel: (...args: unknown[]) => mockFanOutToChannel(...args),+}))vi.mock("@/lib/middleware/auth", () => ({withAuth: (handler: any) => (req: any, routeCtx: any) => handler(req, {env: { DB: {} },@@ -61,6 +65,7 @@ describe("PUT /api/community/messages/[id]/tags", () => {value: { channel: { id: "forum1", type: "forum" }, member: { role: "member" } },})mockGetThread.mockResolvedValue({ id: "thread1", type: "thread", parentMessageId: "m1" })+ mockFanOutToChannel.mockResolvedValue(undefined)})it("lets the opener author replace the normalized tag set", async () => {@@ -104,4 +109,18 @@ describe("PUT /api/community/messages/[id]/tags", () => {expect(res.status).toBe(400)expect(mockGetMessage).not.toHaveBeenCalled()})++ it("accepts Archived in addition to five ordinary tags", async () => {+ const tags = ["a", "b", "c", "d", "e", "archived"]+ const res = await PUT(request(tags), ctx)++ expect(res.status).toBe(200)+ expect(mockReplaceTags).toHaveBeenCalledWith(expect.anything(), { messageId: "m1", tags })+ expect(mockFanOutToChannel).toHaveBeenCalledWith("forum1", {+ type: "community:channel.child_update",+ parentChannelId: "forum1",+ channelId: "thread1",+ changes: { tags },+ })+ })})diff --git a/src/web/src/app/api/community/messages/[id]/tags/route.ts b/src/web/src/app/api/community/messages/[id]/tags/route.tsindex d20c2fb44..024baf976 100644--- a/src/web/src/app/api/community/messages/[id]/tags/route.ts+++ b/src/web/src/app/api/community/messages/[id]/tags/route.ts@@ -5,10 +5,13 @@ import { getDb } from "@/lib/db"import {queries,canManageServer,+ FORUM_ARCHIVE_TAG,MAX_FORUM_TAG_LENGTH,MAX_FORUM_TAGS_PER_POST,+ WS_EVENTS,} from "@alook/shared"import { requireChannelAccess } from "@/lib/community/permissions"+import { fanOutToChannel } from "@/lib/community/fanout"/** Replace the tag set on a forum opener message. */export const PUT = withAuth(async (req: NextRequest, ctx) => {@@ -29,7 +32,7 @@ export const PUT = withAuth(async (req: NextRequest, ctx) => {return writeError("tags must contain only strings", 400)}const tags = [...new Set((input as string[]).map((tag) => tag.trim().toLowerCase()).filter(Boolean))]- if (tags.length > MAX_FORUM_TAGS_PER_POST) {+ if (tags.filter((tag) => tag !== FORUM_ARCHIVE_TAG).length > MAX_FORUM_TAGS_PER_POST) {return writeError(`too many tags (max ${MAX_FORUM_TAGS_PER_POST})`, 400)}if (tags.some((tag) => tag.length > MAX_FORUM_TAG_LENGTH)) {@@ -58,6 +61,12 @@ export const PUT = withAuth(async (req: NextRequest, ctx) => {if (!mayEdit) return writeError("forbidden", 403)await queries.communityMessageTag.replaceMessageTags(db, { messageId, tags })+ await fanOutToChannel(message.channelId, {+ type: WS_EVENTS.CHILD_CHANNEL_UPDATE,+ parentChannelId: message.channelId,+ channelId: thread.id,+ changes: { tags },+ })return writeJSON({ tags })})diff --git a/src/web/src/components/community/channels/forum-view.test.ts b/src/web/src/components/community/channels/forum-view.test.tsindex 1950e11de..c94cf8130 100644--- a/src/web/src/components/community/channels/forum-view.test.ts+++ b/src/web/src/components/community/channels/forum-view.test.ts@@ -1,4 +1,5 @@import { describe, it, expect } from "vitest"+import { readFileSync } from "node:fs"import { createElement } from "react"import { renderToStaticMarkup } from "react-dom/server"import {@@ -43,6 +44,20 @@ function render(posts: ForumThread[]): string {)}+function renderWithAvailableTags(posts: ForumThread[], availableTags: string[], tag = "All"): string {+ return renderToStaticMarkup(+ createElement(ForumView, {+ forumChannelId: "cha_forum",+ members: [],+ posts,+ tag,+ availableTags,+ onTagChange: () => {},+ onOpenPost: () => {},+ })+ )+}+// Render with the delete affordance wired. `canDeletePost` decides per-post// visibility; `deletingPost` is the in-flight post id (button disabled).function renderWithDelete(@@ -284,6 +299,7 @@ describe("ForumView filter bar / composer swap", () => {expect(railMarkup).toContain("flex-nowrap")expect(railMarkup).toContain("overflow-x-auto")expect(railMarkup).toContain("thin-scrollbar")+ expect(railMarkup).toContain("scrollbar-none")expect(railMarkup).not.toContain("sm:flex-wrap")expect(railMarkup).not.toContain("sm:overflow-x-visible")expect(railMarkup).toContain('tabindex="0"')@@ -293,12 +309,54 @@ describe("ForumView filter bar / composer swap", () => {expect(listMarkup).toContain("sm:px-4")})+ it("keeps the tag rail scrollable without a cross-browser scrollbar gutter", () => {+ const html = render([makePost({ tags: ["alpha", "beta", "gamma", "delta"] })])+ const railIndex = html.indexOf(tid.forumTagScroller)+ const railMarkup = html.slice(Math.max(0, railIndex - 400), railIndex + 900)+ const css = readFileSync(new URL("../../../app/globals.css", import.meta.url), "utf8")++ expect(railMarkup).toContain("overflow-x-auto")+ expect(railMarkup).toContain("thin-scrollbar scrollbar-none")+ expect(css).toContain(".scrollbar-none")+ expect(css).toContain("-ms-overflow-style: none")+ expect(css).toContain(".thin-scrollbar.scrollbar-none")+ expect(css).toContain("scrollbar-width: none")+ expect(css).toContain(".scrollbar-none::-webkit-scrollbar")+ expect(css).toContain("display: none")+ })++ it("keeps Archived last in the shared scroller and hides it without archived posts", () => {+ const withoutArchived = renderWithAvailableTags([makePost()], ["bug", "help"])+ expect(withoutArchived).not.toContain(tid.forumTagChip("archived"))++ const html = renderWithAvailableTags([makePost()], ["archived", "bug", "help"], "archived")+ const scrollerIndex = html.indexOf(tid.forumTagScroller)+ const allIndex = html.indexOf(tid.forumTagAll)+ const bugIndex = html.indexOf(tid.forumTagChip("bug"))+ const helpIndex = html.indexOf(tid.forumTagChip("help"))+ const archivedIndex = html.indexOf(tid.forumTagChip("archived"))+ const scrollerCloseIndex = html.indexOf("</div>", scrollerIndex)+ const newPostIndex = html.indexOf(tid.forumNewPost)++ expect(scrollerIndex).toBeGreaterThanOrEqual(0)+ expect(allIndex).toBeGreaterThan(scrollerIndex)+ expect(bugIndex).toBeGreaterThan(allIndex)+ expect(helpIndex).toBeGreaterThan(bugIndex)+ expect(archivedIndex).toBeGreaterThan(helpIndex)+ expect(archivedIndex).toBeLessThan(scrollerCloseIndex)+ expect(archivedIndex).toBeLessThan(newPostIndex)+ const archivedMarkup = html.slice(Math.max(0, archivedIndex - 500), archivedIndex + 500)+ expect(archivedMarkup).toContain("Archived")+ expect(archivedMarkup).toContain("opacity-100 ring-1")+ })+it("matches the real responsive filter rail and 28px chip footprints while loading", () => {const html = renderToStaticMarkup(createElement(ForumViewSkeleton))expect(html.match(/h-7/g)).toHaveLength(4)expect(html).not.toContain("h-5 w-10 rounded-full")expect(html).toContain("flex-nowrap")expect(html).toContain("overflow-x-auto")+ expect(html).toContain("thin-scrollbar scrollbar-none")expect(html).toContain("sm:flex-wrap")expect(html).toContain("sm:overflow-x-visible")expect(html).toContain("pointer-events-none")diff --git a/src/web/src/components/community/channels/forum-view.tsx b/src/web/src/components/community/channels/forum-view.tsxindex c9a33194f..3f6e39e7b 100644--- a/src/web/src/components/community/channels/forum-view.tsx+++ b/src/web/src/components/community/channels/forum-view.tsx@@ -22,6 +22,7 @@ import { VirtualRows } from "../messages/virtual-cursor-list"import { useVirtualCursorSentinel } from "@/hooks/community/use-virtual-cursor-sentinel"import { tagColorClassName, tagColorStyle } from "@/lib/community/tag-color"import { cn } from "@/lib/utils"+import { FORUM_ARCHIVE_TAG } from "@alook/shared"const MAX_AVATARS = 5const MAX_VISIBLE_TAGS = 2@@ -245,6 +246,11 @@ export function ForumView({const filterTags = availableTags.length > 0? availableTags: [...new Set(posts.flatMap((post) => post.tags))]+ const hasArchivedPosts = filterTags.includes(FORUM_ARCHIVE_TAG)+ const displayFilterTags = [+ ...filterTags.filter((candidate) => candidate !== FORUM_ARCHIVE_TAG),+ ...(hasArchivedPosts ? [FORUM_ARCHIVE_TAG] : []),+ ]const filterTagKey = filterTags.join("\0")const syncTagFades = useCallback(() => {const scroller = tagScrollerRef.current@@ -337,7 +343,7 @@ export function ForumView({syncTagFades()}}}- className="flex w-full min-w-0 flex-nowrap items-center gap-2 overflow-x-auto overscroll-x-contain thin-scrollbar"+ className="flex w-full min-w-0 flex-nowrap items-center gap-2 overflow-x-auto overscroll-x-contain thin-scrollbar scrollbar-none">{filterTags.length > 0 && (<>@@ -353,7 +359,7 @@ export function ForumView({>All</button>- {filterTags.map((t) => (+ {displayFilterTags.map((t) => (<buttonkey={t}ref={tag === t ? activeFilterRef : undefined}@@ -367,7 +373,7 @@ export function ForumView({data-testid={tid.forumTagChip(t)}onClick={() => onTagChange(t)}>- {`#${t}`}+ {t === FORUM_ARCHIVE_TAG ? "Archived" : `#${t}`}</button>))}</>@@ -561,7 +567,7 @@ export function ForumViewSkeleton() {<div className="relative min-w-0 flex-1"><divaria-hidden- className="pointer-events-none flex w-full min-w-0 flex-nowrap items-center gap-2 overflow-x-auto overscroll-x-contain thin-scrollbar sm:flex-wrap sm:overflow-x-visible"+ className="pointer-events-none flex w-full min-w-0 flex-nowrap items-center gap-2 overflow-x-auto overscroll-x-contain thin-scrollbar scrollbar-none sm:flex-wrap sm:overflow-x-visible"><Skeleton className="h-7 w-10 shrink-0 rounded-full" /><Skeleton className="h-7 w-16 shrink-0 rounded-full" />diff --git a/src/web/src/components/community/channels/post-tag-dialog.test.ts b/src/web/src/components/community/channels/post-tag-dialog.test.tsindex 05f67d99d..8c77b5d61 100644--- a/src/web/src/components/community/channels/post-tag-dialog.test.ts+++ b/src/web/src/components/community/channels/post-tag-dialog.test.ts@@ -1,6 +1,6 @@import { createElement, type ReactNode } from "react"import TestRenderer, { act, type ReactTestInstance } from "react-test-renderer"-import { MAX_FORUM_TAG_LENGTH, MAX_FORUM_TAGS_PER_POST } from "@alook/shared"+import { FORUM_ARCHIVE_TAG, MAX_FORUM_TAG_LENGTH, MAX_FORUM_TAGS_PER_POST } from "@alook/shared"import { describe, expect, it, vi } from "vitest"import { tid } from "@/lib/community/testids"@@ -70,6 +70,21 @@ function pressEnter(input: ReactTestInstance): void {}describe("PostTagDialog frontend limits", () => {+ it("always presets Archived and keeps it outside the ordinary tag quota", () => {+ const selected = Array.from({ length: MAX_FORUM_TAGS_PER_POST }, (_, index) => `tag-${index + 1}`)+ const onSave = vi.fn()+ const { renderer } = renderDialog({ current: selected, onSave })+ setOpen(renderer.root, true)++ const archived = tagButton(renderer.root, FORUM_ARCHIVE_TAG)+ expect(archived.props.disabled).toBe(false)+ expect(archived.props["data-testid"]).toBe(tid.forumTagDialogChip(FORUM_ARCHIVE_TAG))+ act(() => archived.props.onClick())+ setOpen(renderer.root, false)++ expect(onSave).toHaveBeenCalledWith([...selected, FORUM_ARCHIVE_TAG])+ })+it("uses the shared length limit and right-aligns the close-save hint", () => {const { renderer } = renderDialog()const input = renderer.root.findByType("input")diff --git a/src/web/src/components/community/channels/post-tag-dialog.tsx b/src/web/src/components/community/channels/post-tag-dialog.tsxindex dd416da1a..7a9046781 100644--- a/src/web/src/components/community/channels/post-tag-dialog.tsx+++ b/src/web/src/components/community/channels/post-tag-dialog.tsx@@ -2,7 +2,7 @@import { useEffect, useState, type ReactElement } from "react"import { X } from "lucide-react"-import { MAX_FORUM_TAG_LENGTH, MAX_FORUM_TAGS_PER_POST } from "@alook/shared"+import { FORUM_ARCHIVE_TAG, MAX_FORUM_TAG_LENGTH, MAX_FORUM_TAGS_PER_POST } from "@alook/shared"import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"import { Input } from "@/components/ui/input"import { onEnterSubmit } from "@/lib/ime"@@ -28,6 +28,7 @@ export function PostTagDialog({const [open, setOpen] = useState(false)const [selected, setSelected] = useState<string[]>(current)const [draft, setDraft] = useState("")+ const ordinaryTagCount = selected.filter((tag) => tag !== FORUM_ARCHIVE_TAG).lengthuseEffect(() => {if (!open) setSelected(current)@@ -36,7 +37,11 @@ export function PostTagDialog({const toggle = (tag: string) => {setSelected((previous) => {if (previous.includes(tag)) return previous.filter((candidate) => candidate !== tag)- if (previous.length >= MAX_FORUM_TAGS_PER_POST || tag.length > MAX_FORUM_TAG_LENGTH) {+ const ordinaryCount = previous.filter((candidate) => candidate !== FORUM_ARCHIVE_TAG).length+ if (+ (tag !== FORUM_ARCHIVE_TAG && ordinaryCount >= MAX_FORUM_TAGS_PER_POST)+ || tag.length > MAX_FORUM_TAG_LENGTH+ ) {return previous}return [...previous, tag]@@ -47,7 +52,11 @@ export function PostTagDialog({const tag = draft.trim().toLowerCase()if (!tag || tag.length > MAX_FORUM_TAG_LENGTH) returnsetSelected((previous) => {- if (previous.length >= MAX_FORUM_TAGS_PER_POST || previous.includes(tag)) return previous+ const ordinaryCount = previous.filter((candidate) => candidate !== FORUM_ARCHIVE_TAG).length+ if (+ previous.includes(tag)+ || (tag !== FORUM_ARCHIVE_TAG && ordinaryCount >= MAX_FORUM_TAGS_PER_POST)+ ) return previousreturn [...previous, tag]})setDraft("")@@ -60,7 +69,12 @@ export function PostTagDialog({if (changed) onSave(selected)}- const chips = [...new Set([...allTags, ...selected])].sort()+ const chips = [+ FORUM_ARCHIVE_TAG,+ ...[...new Set([...allTags, ...selected])]+ .filter((tag) => tag !== FORUM_ARCHIVE_TAG)+ .sort(),+ ]return (<Popover@@ -92,7 +106,7 @@ export function PostTagDialog({) : chips.map((tag) => {const active = selected.includes(tag)const additionBlocked = !active && (- selected.length >= MAX_FORUM_TAGS_PER_POST+ (tag !== FORUM_ARCHIVE_TAG && ordinaryTagCount >= MAX_FORUM_TAGS_PER_POST)|| tag.length > MAX_FORUM_TAG_LENGTH)return (@@ -125,7 +139,7 @@ export function PostTagDialog({maxLength={MAX_FORUM_TAG_LENGTH}placeholder="Add a tag…"className="h-8 text-sm"- disabled={saving || selected.length >= MAX_FORUM_TAGS_PER_POST}+ disabled={saving || ordinaryTagCount >= MAX_FORUM_TAGS_PER_POST}/><p className="text-right text-[11px] text-muted-foreground">diff --git a/src/web/src/hooks/community/community-ws/structure-tree-events.test.ts b/src/web/src/hooks/community/community-ws/structure-tree-events.test.tsindex db8403955..ba6f731f5 100644--- a/src/web/src/hooks/community/community-ws/structure-tree-events.test.ts+++ b/src/web/src/hooks/community/community-ws/structure-tree-events.test.ts@@ -461,6 +461,28 @@ describe("useCommunityWs — child_create patches parent thread badge with countexpect(cache?.pages[0].messages[0].thread?.messageCount).toBe(5)})+ it("child_update tag changes invalidate every forum feed and the vocabulary", async () => {+ await mountHook()+ const allFeed = communityKeys.forumFeed("forum_1", null)+ const archivedFeed = communityKeys.forumFeed("forum_1", "archived")+ const tags = communityKeys.forumTags("forum_1")+ const messages = communityKeys.channelMessages("forum_1")+ for (const key of [allFeed, archivedFeed, tags, messages]) {+ capturedQueryClient.setQueryData(key, { value: "stale" })+ }++ capturedOnMessage!({+ type: "community:channel.child_update",+ parentChannelId: "forum_1",+ channelId: "post_1",+ changes: { tags: ["archived"] },+ } satisfies CommunityChildChannelUpdate)++ for (const key of [allFeed, archivedFeed, tags, messages]) {+ expect(capturedQueryClient.getQueryState(key)?.isInvalidated).toBe(true)+ }+ })+it("child_update rename patches focused child metadata and its cached channel meta", async () => {await mountHook()const { useCommunityStore } = await import("@/stores/community")diff --git a/src/web/src/hooks/community/community-ws/structure-tree-events.ts b/src/web/src/hooks/community/community-ws/structure-tree-events.tsindex 7c8d8a9b5..0b41eff9d 100644--- a/src/web/src/hooks/community/community-ws/structure-tree-events.ts+++ b/src/web/src/hooks/community/community-ws/structure-tree-events.ts@@ -130,6 +130,12 @@ export function handleChildChannelUpdate(// child_update — sync counts/name on the parent message's thread// indicator if the update carries them.const changes = event.changes+ if (changes.tags !== undefined) {+ invalidateChannelMessages(projection, event.parentChannelId)+ projection.invalidate("forum-post-tags", {+ queryKey: communityKeys.forumTags(event.parentChannelId),+ })+ }const sidebarServerId = useCommunityStore.getState().currentServerIdif (changes.name !== undefined && sidebarServerId) {queryClient.setQueryData<Record<string, unknown> | undefined>(diff --git a/src/web/src/hooks/community/use-forum-feed.test.ts b/src/web/src/hooks/community/use-forum-feed.test.tsindex 0c11b223d..1f1f0ab90 100644--- a/src/web/src/hooks/community/use-forum-feed.test.ts+++ b/src/web/src/hooks/community/use-forum-feed.test.ts@@ -34,6 +34,14 @@ describe("forumFeedPageQueryFn", () => {expect(params.get("tag")).toBe("bug")expect(params.get("cursor")).toBe("opaque cursor")})++ it("uses the archive tag as its own feed query", async () => {+ apiFetchMock.mockResolvedValue({ threads: [], included: emptyIncluded, hasMore: false })+ await forumFeedPageQueryFn("forum_one", "archived")({ pageParam: null })++ const url = apiFetchMock.mock.calls[0]![0] as string+ expect(new URL(url, "http://localhost").searchParams.get("tag")).toBe("archived")+ })})describe("mapForumFeedPages", () => {diff --git a/src/web/src/lib/community/forum-tag-selection.test.ts b/src/web/src/lib/community/forum-tag-selection.test.tsindex dbe69d6b1..189f61d2b 100644--- a/src/web/src/lib/community/forum-tag-selection.test.ts+++ b/src/web/src/lib/community/forum-tag-selection.test.ts@@ -20,4 +20,8 @@ describe("forum tag selection", () => {expect(validateForumTagSelection("bug", ["bug", "feature"])).toBe("bug")expect(validateForumTagSelection("gone", ["bug", "feature"])).toBe("All")})++ it("retains an available Archived selection", () => {+ expect(validateForumTagSelection("archived", ["archived", "bug"])).toBe("archived")+ })})