Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b7cfc04
feat: foundation for the dbt Power User tools
hkaltai Nov 13, 2026
1eb722e
Merge remote-tracking branch 'origin/main' into feat/pu-mods-foundation
hkaltai Nov 13, 2026
e7c53b2
feat: docs_share_comments tool — list, reply to and resolve comment t…
hkaltai Nov 13, 2026
21d0494
fix: harden the dbt Power User tool foundation
hkaltai Nov 13, 2026
a0f07cb
fix: docs_share_comments — a post must be acknowledged, an unexpected…
hkaltai Nov 13, 2026
130aedf
Merge commit '21d0494c' into feat/docs-share-comments-tool
hkaltai Nov 13, 2026
35e1ccc
fix: docs_share_comments — a malformed share, thread or status is an …
hkaltai Nov 13, 2026
5da9186
test: docs_share_comments is no longer a placeholder in the allow-lis…
hkaltai Nov 13, 2026
6a139dd
fix: docs_share_comments review — tolerate paginated answers and unkn…
hkaltai Nov 15, 2026
d8c3469
fix: send falsy API bodies, follow cancellation in apiRequest, check …
hkaltai Nov 15, 2026
1e5d0b4
Merge remote-tracking branch 'origin/main' into feat/docs-share-comme…
hkaltai Nov 17, 2026
dace1c2
Merge remote-tracking branch 'origin/main' into feat/pu-mods-foundation
hkaltai Nov 17, 2026
18a3fc4
fix: keep the stored API key out of API errors, bound the dbt config …
hkaltai Nov 17, 2026
6024ac9
fix: redact the API key when a refused header races the caller's abor…
hkaltai Nov 17, 2026
f5159c5
docs: say which tools use the dbt adapter helper
hkaltai Nov 17, 2026
f57de3d
docs: rewrap and correct the adapter helper comments
hkaltai Nov 17, 2026
d6e37a7
Merge origin/feat/pu-mods-foundation into feat/docs-share-comments-tool
hkaltai Nov 17, 2026
c3dc492
fix: docs_share_comments passes the call's abort signal to every requ…
hkaltai Nov 17, 2026
aaff414
fix: never echo a send failure's text, so a trimmed key can't leak
hkaltai Nov 17, 2026
3a98dff
fix: a rejection with no reason is a send failure, not an abort
hkaltai Nov 17, 2026
be4e3e2
Merge remote-tracking branch 'origin/feat/pu-mods-foundation' into fe…
hkaltai Nov 17, 2026
ebd7926
Merge remote-tracking branch 'origin/main' into feat/docs-share-comme…
hkaltai Nov 17, 2026
50a42e9
fix: name authors by real name, check the thread before posting, keep…
hkaltai Nov 17, 2026
b1fb27a
merge origin/main
hkaltai Nov 17, 2026
e315733
fix: a failed pre-post check says nothing was sent, exact-100 threads…
hkaltai Nov 17, 2026
2489f78
fix: a paginated list that is not the whole answer is reported as inc…
hkaltai Nov 17, 2026
9b24389
fix: a post asks for permission, and a listing is cut at an overall size
hkaltai Nov 17, 2026
6335b6b
test: the implemented docs_share_comments is not a placeholder
hkaltai Nov 17, 2026
3abbb9f
fix: the listing's metadata is held to the same size budget as its ou…
hkaltai Nov 17, 2026
76686b2
test: leave the shared foundation test untouched
hkaltai Nov 17, 2026
253e29a
fix: a post asks for permission only once its thread is known, an unr…
hkaltai Nov 18, 2026
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
109 changes: 109 additions & 0 deletions packages/opencode/src/altimate/api/docs-share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import z from "zod"
import { AltimateApi } from "./client"

// The shared-docs comment endpoints of the Altimate backend. Shapes follow what the backend returns for
// a docs share: its threads ("conversation groups") and the messages in each.

export interface DocsShareMessage {
conversation_id: number
message: string
timestamp: string
user_id: number
}

export interface DocsShareRange {
start: { line: number; character: number }
end?: { line: number; character: number }
}

export interface DocsShareThread {
conversation_group_id: number
owner?: number
/** "Pending" is open; "Resolved" is closed. */
status: "Pending" | "Resolved"
meta?: {
field?: "description"
column?: string
highlight?: string
uniqueId?: string
filePath?: string
resource_type?: string
range?: DocsShareRange | null
} | null
conversations: DocsShareMessage[]
}

export interface DocsShare {
share_id: number
name?: string
description?: string
project_name?: string
conversation_group: DocsShareThread[]
}

export interface DocsShareUser {
id: number
display_name?: string
first_name?: string
last_name?: string
email?: string
}

// What a share and its threads must carry for the tool to read them: an answer without these is an
// error, so a changed or broken response is never shown as "no open comments".
const Range = z.object({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR — one thread with a partial meta.range fails the whole list (Claude; Codex accepted as major)

Range requires start.line/start.character whenever range is present, and SharesAnswer validates all shares in one go. The backend passes meta through unchanged. The dbt Power User extension writes range: range ? { end: range.end, start: range.start } : undefined (src/comment_provider/conversationProvider.ts), and its own test (src/test/suite/conversationProvider.test.ts) documents Range objects whose start is undefined in the wild. So { end: {...} } or {} can be stored.

Reproduced: one good Pending thread plus one with range: { end: { line: 1, character: 1 } } (or range: {}) → Could not load the comment threads: The shared docs service returned an unexpected answer for the shares. Every open thread of the project disappears, for the tool and for the plugin pane.

Fix: parse range leniently and drop it, so the thread is kept without a line, when it doesn't have the shape. Keep the strict checks for the fields that identify a thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 50a42e9: range is parsed leniently (.catch(undefined)), so a partial range drops only the thread's line; the identifying fields stay strict. Test uses a range with only end and an empty one.

start: z.object({ line: z.number(), character: z.number() }),
end: z.object({ line: z.number(), character: z.number() }).optional(),
})
const SharesAnswer = z.array(
z.object({
share_id: z.number(),
name: z.string().nullish(),
project_name: z.string().nullish(),
conversation_group: z.array(
z.object({
conversation_group_id: z.number(),
// The backend's status is a closed set: a value outside it is an error, never "no open threads".
status: z.enum(["Pending", "Resolved"]),
// A range that is partial (the editor extension can store one without a start) drops the
// line of the thread, never the thread or the list.
meta: z.object({ range: Range.nullish().catch(undefined) }).passthrough().nullish(),
conversations: z.array(
z.object({ conversation_id: z.number(), message: z.string(), timestamp: z.string(), user_id: z.number() }),
),
}),
),
}),
)

/** The shares of the given dbt projects, each with its comment threads. */
export async function listSharedDocs(
projects: string[],
signal?: AbortSignal,
): Promise<{ shares: DocsShare[]; /** Set when the service says it holds more shares than it sent. */ missing?: number }> {
const params = new URLSearchParams()
for (const project of projects) params.append("projects", project)
const shares = await AltimateApi.apiRequest("GET", `/dbt/dbt_docs_share/all?${params.toString()}`, undefined, signal)
// A paginated answer wraps the shares in `items`; a bare array is accepted too.
const wrapped = shares && !Array.isArray(shares) ? shares : undefined
const list = Array.isArray(wrapped?.items) ? wrapped.items : shares
const parsed = SharesAnswer.safeParse(list)
if (!parsed.success) throw new Error("The shared docs service returned an unexpected answer for the shares.")
const total = typeof wrapped?.total === "number" ? wrapped.total : undefined
const missing = total !== undefined && total > parsed.data.length ? total - parsed.data.length : undefined
return { shares: parsed.data as DocsShare[], missing }
}

/** The people in the tenant, for naming who wrote each message. */
export async function listTenantUsers(signal?: AbortSignal): Promise<DocsShareUser[]> {
const users = await AltimateApi.apiRequest("GET", "/users/chat", undefined, signal)
return Array.isArray(users) ? users : []
}

export async function replyToThread(shareId: number, groupId: number, message: string, signal?: AbortSignal): Promise<{ ok: boolean }> {
return AltimateApi.apiRequest("POST", `/dbt/dbt_docs_share/${shareId}/conversation_group/${groupId}/conversation`, { message }, signal)
}

export async function resolveThread(shareId: number, groupId: number, signal?: AbortSignal): Promise<{ ok: boolean }> {
return AltimateApi.apiRequest("POST", `/dbt/dbt_docs_share/${shareId}/conversation_group/${groupId}/resolve`, { resolved: true }, signal)
}
Loading
Loading