Add Comments, Mentions, Activity and Version History
Comment threads, notifying at-mentions, a per-record timeline and undo on any org-scoped record.
Install
npm i @dapplelight/signet-server @dapplelight/signet-ui @dapplelight/signet-db hono drizzle-ormAdd the tables and track versions
import { collabTables } from "@dapplelight/signet-db/columns/sqlite"
export const { comments, recordVersions } = collabTables()import { createDb } from "@dapplelight/signet-db/d1"
import { recordVersions, tasks } from "../db/schema"
import { audit } from "./audit"
import { bindings } from "./env"
export const db = createDb(bindings.DB, { audit, versions: { table: recordVersions, track: [tasks] } })Each tracked table needs an orgId column.
Create the collab service
import { createCollab } from "@dapplelight/signet-db/collab"
import { notifyMentions } from "@dapplelight/signet-server/http/collab"
import { comments, tasks } from "../db/schema"
import { db } from "./db"
import { notifier } from "./notifier"
import { orgs } from "./orgs"
import { namesById } from "./people"
export const collab = createCollab(db, {
tables: { comments },
records: { tasks },
orgs,
people: (ids) => namesById(ids),
notify: notifyMentions(notifier),
})Mount the routes after the tenant
import { collabRoutes, mentionTemplates } from "@dapplelight/signet-server/http/collab"
import { tenant } from "@dapplelight/signet-server/http/orgs"
import { Hono } from "hono"
import { collab } from "./server/collab"
import { orgs } from "./server/orgs"
import { appTemplates } from "./server/templates"
const app = new Hono()
const templates = { ...appTemplates, ...mentionTemplates({ url: (m) => `https://app.example.com/${m.table}/${m.rowId}` }) }
app.use("/api/*", tenant({ orgs, rootDomain: "app.example.com" }))
app.route("/api/collab", collabRoutes({ collab, userId: (c) => c.get("session")?.sub }))Pass templates to createNotifier.
Use it from code
import { collab } from "./collab"
export async function review(orgId: string, userId: string, taskId: string) {
const who = { orgId, userId }
const ref = { table: "tasks", id: taskId }
await collab.addComment(who, ref, { body: "Ready? @[Asha Rao](user:u_1)" })
await collab.timeline(who, ref, { limit: 20 })
await collab.restore(who, ref, 2)
await collab.undo(who, ref, { expected: 5 })
}Render it
See the collab screens for the thread, mention picker and history UI.
Next
Add a Waitlist, Invites, Referrals and Onboarding
Launch tooling in your own database: waitlist, one-shot invites, referral rewards, onboarding progress, a changelog and feedback.
Add CSV Import, an Editable Grid and a Rich Text Editor
Bulk-import customers from a CSV, edit them in a spreadsheet-style grid, and store sanitised rich notes.