Repository navigation
feat: "what changed" in the linked workspace, once when a session starts - #1752
saravmajestic wants to merge 1 commit into
Conversation
- `workspace-activity.ts`: reads altimate-backend's
`GET /datamates/{id}/activity` (skills and knowledge added, updated or
removed, last 30 days) and builds one line: "Since your last session in
Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed
(Glossary)." Each client keeps its own last look per server, tenant, account
and workspace in the person's state directory (`workspace-activity/`); the
mark is the newest change's server time, so a skewed clock cannot hide or
repeat a change. The first look records where to start and says nothing.
- `GET /altimate/workspace/activity?host=<client>` for the IDE extension.
- TUI: shows the line a few seconds after startup, after the review-decision
replay, and waits while a decision toast is up (one toast at a time).
- `review-requests.context` is exported for it (the linked workspace with one
captured credential).
- Docs: `usage/cli.md`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
7 issues found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/docs/usage/cli.md">
<violation number="1" location="docs/docs/usage/cli.md:71">
P3: The wait is bounded: the TUI retries four times at 5-second intervals, then shows the line even if a decision notice is still up. Say so, or the docs overstate the guarantee.</violation>
<violation number="2" location="docs/docs/usage/cli.md:71">
P3: The scope list is incomplete: the last-look marker is also kept per server and tenant (the state key includes the API URL and tenant). Name them here so readers know switching server or tenant starts a fresh baseline.</violation>
</file>
<file name="packages/opencode/src/server/server.ts">
<violation number="1" location="packages/opencode/src/server/server.ts:1469">
P2: This validation admits Object-prototype property names, but `changesSince` treats `state.seen[host]` as a timestamp; `host=constructor` therefore becomes an inherited function instead of an unset marker. Reject reserved property names here, or use an own-property lookup when reading the marker.</violation>
</file>
<file name="packages/opencode/src/plugin/tui/altimate/rules.tsx">
<violation number="1" location="packages/opencode/src/plugin/tui/altimate/rules.tsx:509">
P2: This request advances the activity marker before the summary is presented. If the TUI closes while the request or retry is in progress, disposal skips the toast but the next session sees the change as already read; acknowledge it only after presentation or preserve the pending summary for the next session.</violation>
<violation number="2" location="packages/opencode/src/plugin/tui/altimate/rules.tsx:523">
P2: The activity timer is not synchronized with the asynchronous startup replay, so a slow replay can show decision notices after—and replace—the activity summary. Start the activity request only after the replay promise completes, while retaining a timeout fallback if replay never responds.</violation>
</file>
<file name="packages/opencode/src/altimate/workspace/workspace-activity.ts">
<violation number="1" location="packages/opencode/src/altimate/workspace/workspace-activity.ts:77">
P2: `readSeen` treats every read failure as a missing marker. A transient I/O or permission error can reset the client baseline and silently lose or duplicate activity; only ignore `ENOENT` and propagate other errors.</violation>
</file>
<file name="packages/opencode/test/altimate/workspace/workspace-activity.test.ts">
<violation number="1" location="packages/opencode/test/altimate/workspace/workspace-activity.test.ts:14">
P3: This test redirects state with `XDG_STATE_HOME`, but `Global.Path.state` reads `OPENCODE_TEST_STATE_HOME` and a module-load `state` const, so this override only works if `@/global` has not loaded yet. Set `OPENCODE_TEST_STATE_HOME` to the sandbox state dir (and restore it in `afterAll`) so the state location does not depend on import order.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| const refused = workspaceRouteRefusal(c.req.header("origin"), c.req.header("host"), undefined, c.req.header("sec-fetch-site")) | ||
| if (refused) return c.json(refused.body, refused.status) | ||
| const host = c.req.query("host") ?? "" | ||
| if (!/^[a-z][a-z0-9-]{0,31}$/.test(host)) return c.json({ ok: false, error: "host must name the client, e.g. vscode." }, 400) |
There was a problem hiding this comment.
P2: This validation admits Object-prototype property names, but changesSince treats state.seen[host] as a timestamp; host=constructor therefore becomes an inherited function instead of an unset marker. Reject reserved property names here, or use an own-property lookup when reading the marker.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/server/server.ts, line 1469:
<comment>This validation admits Object-prototype property names, but `changesSince` treats `state.seen[host]` as a timestamp; `host=constructor` therefore becomes an inherited function instead of an unset marker. Reject reserved property names here, or use an own-property lookup when reading the marker.</comment>
<file context>
@@ -1460,6 +1460,26 @@ export namespace Server {
+ const refused = workspaceRouteRefusal(c.req.header("origin"), c.req.header("host"), undefined, c.req.header("sec-fetch-site"))
+ if (refused) return c.json(refused.body, refused.status)
+ const host = c.req.query("host") ?? ""
+ if (!/^[a-z][a-z0-9-]{0,31}$/.test(host)) return c.json({ ok: false, error: "host must name the client, e.g. vscode." }, 400)
+ try {
+ const { WorkspaceActivity } = await import("../altimate/workspace/workspace-activity")
</file context>
| if (!/^[a-z][a-z0-9-]{0,31}$/.test(host)) return c.json({ ok: false, error: "host must name the client, e.g. vscode." }, 400) | |
| if ( | |
| !/^[a-z][a-z0-9-]{0,31}$/.test(host) || | |
| ["constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toString", "valueOf"].includes(host) | |
| ) | |
| return c.json({ ok: false, error: "host must name the client, e.g. vscode." }, 400) |
| let activityTimer: ReturnType<typeof setTimeout> | undefined | ||
| const showActivity = async () => { | ||
| if (disposed) return | ||
| const answer = await get<{ ok: boolean; status?: string; line?: string }>(api, "/altimate/workspace/activity?host=tui") |
There was a problem hiding this comment.
P2: This request advances the activity marker before the summary is presented. If the TUI closes while the request or retry is in progress, disposal skips the toast but the next session sees the change as already read; acknowledge it only after presentation or preserve the pending summary for the next session.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/plugin/tui/altimate/rules.tsx, line 509:
<comment>This request advances the activity marker before the summary is presented. If the TUI closes while the request or retry is in progress, disposal skips the toast but the next session sees the change as already read; acknowledge it only after presentation or preserve the pending summary for the next session.</comment>
<file context>
@@ -501,10 +501,33 @@ function installCards(api: TuiPluginApi) {
+ let activityTimer: ReturnType<typeof setTimeout> | undefined
+ const showActivity = async () => {
+ if (disposed) return
+ const answer = await get<{ ok: boolean; status?: string; line?: string }>(api, "/altimate/workspace/activity?host=tui")
+ if (disposed || typeof answer?.line !== "string") return
+ const line = printable(answer.line)
</file context>
| } | ||
| announce(0) | ||
| } | ||
| activityTimer = setTimeout(() => void showActivity(), 6_000) |
There was a problem hiding this comment.
P2: The activity timer is not synchronized with the asynchronous startup replay, so a slow replay can show decision notices after—and replace—the activity summary. Start the activity request only after the replay promise completes, while retaining a timeout fallback if replay never responds.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/plugin/tui/altimate/rules.tsx, line 523:
<comment>The activity timer is not synchronized with the asynchronous startup replay, so a slow replay can show decision notices after—and replace—the activity summary. Start the activity request only after the replay promise completes, while retaining a timeout fallback if replay never responds.</comment>
<file context>
@@ -501,10 +501,33 @@ function installCards(api: TuiPluginApi) {
+ }
+ announce(0)
+ }
+ activityTimer = setTimeout(() => void showActivity(), 6_000)
+ activityTimer.unref?.()
+ // altimate_change end
</file context>
| ) | ||
|
|
||
| async function readSeen(scope: Scope): Promise<Seen> { | ||
| const raw = await fs.readFile(fileOf(scope), "utf8").catch(() => undefined) |
There was a problem hiding this comment.
P2: readSeen treats every read failure as a missing marker. A transient I/O or permission error can reset the client baseline and silently lose or duplicate activity; only ignore ENOENT and propagate other errors.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/workspace/workspace-activity.ts, line 77:
<comment>`readSeen` treats every read failure as a missing marker. A transient I/O or permission error can reset the client baseline and silently lose or duplicate activity; only ignore `ENOENT` and propagate other errors.</comment>
<file context>
@@ -0,0 +1,171 @@
+ )
+
+async function readSeen(scope: Scope): Promise<Seen> {
+ const raw = await fs.readFile(fileOf(scope), "utf8").catch(() => undefined)
+ if (raw !== undefined) {
+ try {
</file context>
| const raw = await fs.readFile(fileOf(scope), "utf8").catch(() => undefined) | |
| const raw = await fs.readFile(fileOf(scope), "utf8").catch((error: unknown) => { | |
| if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return undefined | |
| throw error | |
| }) |
| - In a project linked to a workspace, integrations come only from the workspace's engine, so the `datamate_manager` tool is not offered there and refuses to run. `datamate-*` MCP servers already in the config still load, and a one-time notice names the file they are in; the config is not edited. | ||
| - `altimate-code skill publish <name>` uploads a project skill to the linked workspace, attached directly for the workspace owner or an admin and sent for review for a member when review is on; see [Skills](../configure/skills.md#cli-commands). | ||
| - When the owner or an admin approves or rejects one of your skill or knowledge base requests that altimate-code has seen pending (submitted from it, or listed by an earlier check), or that is decided after it began checking, the TUI shows a notice once in each project linked to that workspace, with the reason for a rejection. Every altimate-code process that opens a linked project checks at start and every 5 minutes while workspaces are on and you are signed in: it lists your own requests on the workspace (up to 10 pages of 50); a server without review is asked again only after 6 hours. The decision is kept per account and workspace in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-reviews/`, the 50 most recent), so a TUI that was closed or disconnected when it arrived shows it when it next starts. The first time a TUI opens a project, decisions already kept are recorded without a notice; `altimate-code workspace review status` lists them. Withdrawing a waiting request and removing an approved one happen in the web app or from `/rules` in the TUI, which lists your skill and knowledge requests with your rule proposals. Editor and agent plugins read decisions with `altimate-code workspace review decisions --json` (see [Skills](../configure/skills.md#cli-commands)), which always prints one JSON object and exits 0. When the owner or an admin removes one of yours that altimate-code has seen approved or waiting (up to the 200 approved ones it tracks per workspace), the TUI shows that once too, with the reason; your own removal and withdrawal show nothing. | ||
| - A few seconds after the TUI starts in a linked project, it says in one line what changed in the skills and knowledge the workspace gives its team since you last looked, for example "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)." It reads the workspace's recent changes (the last 30 days) and keeps when you last looked per account, workspace and client in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-activity/`); the first time it only records where to start from. It waits while a review decision notice is showing. The VS Code extension asks `altimate-code serve` for the same line (`GET /altimate/workspace/activity?host=vscode`), with its own last look. Changes the service does not record (the owner detaching their own skill, the owner's knowledge selection) are not listed. |
There was a problem hiding this comment.
P3: The wait is bounded: the TUI retries four times at 5-second intervals, then shows the line even if a decision notice is still up. Say so, or the docs overstate the guarantee.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/usage/cli.md, line 71:
<comment>The wait is bounded: the TUI retries four times at 5-second intervals, then shows the line even if a decision notice is still up. Say so, or the docs overstate the guarantee.</comment>
<file context>
@@ -68,6 +68,7 @@ With workspaces on:
- In a project linked to a workspace, integrations come only from the workspace's engine, so the `datamate_manager` tool is not offered there and refuses to run. `datamate-*` MCP servers already in the config still load, and a one-time notice names the file they are in; the config is not edited.
- `altimate-code skill publish <name>` uploads a project skill to the linked workspace, attached directly for the workspace owner or an admin and sent for review for a member when review is on; see [Skills](../configure/skills.md#cli-commands).
- When the owner or an admin approves or rejects one of your skill or knowledge base requests that altimate-code has seen pending (submitted from it, or listed by an earlier check), or that is decided after it began checking, the TUI shows a notice once in each project linked to that workspace, with the reason for a rejection. Every altimate-code process that opens a linked project checks at start and every 5 minutes while workspaces are on and you are signed in: it lists your own requests on the workspace (up to 10 pages of 50); a server without review is asked again only after 6 hours. The decision is kept per account and workspace in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-reviews/`, the 50 most recent), so a TUI that was closed or disconnected when it arrived shows it when it next starts. The first time a TUI opens a project, decisions already kept are recorded without a notice; `altimate-code workspace review status` lists them. Withdrawing a waiting request and removing an approved one happen in the web app or from `/rules` in the TUI, which lists your skill and knowledge requests with your rule proposals. Editor and agent plugins read decisions with `altimate-code workspace review decisions --json` (see [Skills](../configure/skills.md#cli-commands)), which always prints one JSON object and exits 0. When the owner or an admin removes one of yours that altimate-code has seen approved or waiting (up to the 200 approved ones it tracks per workspace), the TUI shows that once too, with the reason; your own removal and withdrawal show nothing.
+- A few seconds after the TUI starts in a linked project, it says in one line what changed in the skills and knowledge the workspace gives its team since you last looked, for example "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)." It reads the workspace's recent changes (the last 30 days) and keeps when you last looked per account, workspace and client in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-activity/`); the first time it only records where to start from. It waits while a review decision notice is showing. The VS Code extension asks `altimate-code serve` for the same line (`GET /altimate/workspace/activity?host=vscode`), with its own last look. Changes the service does not record (the owner detaching their own skill, the owner's knowledge selection) are not listed.
- Workspace skills are synced at the version the workspace serves you: the approved version, or your own pending version of a skill you submitted. The next sync follows what the workspace serves: a skill whose first submission is rejected, or that is detached from the workspace, is removed from the project; when an update to an approved skill is rejected or replaced, the skill stays at its approved version. Each skill is downloaded as one version: if it is approved or rejected while its files are being read, nothing of it is installed from that sync and it is fetched again on the next one. When a download fails, the copy already in the project is kept only if it is still the version the workspace serves, as far as the server has said (its list, or a read refused because the version just changed), or if neither the copy nor the list names a version (a copy synced before revisions, or an older server), in which case it is kept until the server says otherwise; a copy of a version it no longer serves (for example your rejected pending version), or of a skill it no longer lists, is removed until the download succeeds, even when no other skill could be downloaded. Two processes syncing the same project take turns: a sync never replaces or removes a snapshot another process installed after it started, and the next sync starts from the newer one.
- When the linked workspace has knowledge, the agent is told to check it for best practices and team conventions before answering, without you having to mention the knowledge base.
</file context>
| - In a project linked to a workspace, integrations come only from the workspace's engine, so the `datamate_manager` tool is not offered there and refuses to run. `datamate-*` MCP servers already in the config still load, and a one-time notice names the file they are in; the config is not edited. | ||
| - `altimate-code skill publish <name>` uploads a project skill to the linked workspace, attached directly for the workspace owner or an admin and sent for review for a member when review is on; see [Skills](../configure/skills.md#cli-commands). | ||
| - When the owner or an admin approves or rejects one of your skill or knowledge base requests that altimate-code has seen pending (submitted from it, or listed by an earlier check), or that is decided after it began checking, the TUI shows a notice once in each project linked to that workspace, with the reason for a rejection. Every altimate-code process that opens a linked project checks at start and every 5 minutes while workspaces are on and you are signed in: it lists your own requests on the workspace (up to 10 pages of 50); a server without review is asked again only after 6 hours. The decision is kept per account and workspace in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-reviews/`, the 50 most recent), so a TUI that was closed or disconnected when it arrived shows it when it next starts. The first time a TUI opens a project, decisions already kept are recorded without a notice; `altimate-code workspace review status` lists them. Withdrawing a waiting request and removing an approved one happen in the web app or from `/rules` in the TUI, which lists your skill and knowledge requests with your rule proposals. Editor and agent plugins read decisions with `altimate-code workspace review decisions --json` (see [Skills](../configure/skills.md#cli-commands)), which always prints one JSON object and exits 0. When the owner or an admin removes one of yours that altimate-code has seen approved or waiting (up to the 200 approved ones it tracks per workspace), the TUI shows that once too, with the reason; your own removal and withdrawal show nothing. | ||
| - A few seconds after the TUI starts in a linked project, it says in one line what changed in the skills and knowledge the workspace gives its team since you last looked, for example "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)." It reads the workspace's recent changes (the last 30 days) and keeps when you last looked per account, workspace and client in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-activity/`); the first time it only records where to start from. It waits while a review decision notice is showing. The VS Code extension asks `altimate-code serve` for the same line (`GET /altimate/workspace/activity?host=vscode`), with its own last look. Changes the service does not record (the owner detaching their own skill, the owner's knowledge selection) are not listed. |
There was a problem hiding this comment.
P3: The scope list is incomplete: the last-look marker is also kept per server and tenant (the state key includes the API URL and tenant). Name them here so readers know switching server or tenant starts a fresh baseline.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/usage/cli.md, line 71:
<comment>The scope list is incomplete: the last-look marker is also kept per server and tenant (the state key includes the API URL and tenant). Name them here so readers know switching server or tenant starts a fresh baseline.</comment>
<file context>
@@ -68,6 +68,7 @@ With workspaces on:
- In a project linked to a workspace, integrations come only from the workspace's engine, so the `datamate_manager` tool is not offered there and refuses to run. `datamate-*` MCP servers already in the config still load, and a one-time notice names the file they are in; the config is not edited.
- `altimate-code skill publish <name>` uploads a project skill to the linked workspace, attached directly for the workspace owner or an admin and sent for review for a member when review is on; see [Skills](../configure/skills.md#cli-commands).
- When the owner or an admin approves or rejects one of your skill or knowledge base requests that altimate-code has seen pending (submitted from it, or listed by an earlier check), or that is decided after it began checking, the TUI shows a notice once in each project linked to that workspace, with the reason for a rejection. Every altimate-code process that opens a linked project checks at start and every 5 minutes while workspaces are on and you are signed in: it lists your own requests on the workspace (up to 10 pages of 50); a server without review is asked again only after 6 hours. The decision is kept per account and workspace in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-reviews/`, the 50 most recent), so a TUI that was closed or disconnected when it arrived shows it when it next starts. The first time a TUI opens a project, decisions already kept are recorded without a notice; `altimate-code workspace review status` lists them. Withdrawing a waiting request and removing an approved one happen in the web app or from `/rules` in the TUI, which lists your skill and knowledge requests with your rule proposals. Editor and agent plugins read decisions with `altimate-code workspace review decisions --json` (see [Skills](../configure/skills.md#cli-commands)), which always prints one JSON object and exits 0. When the owner or an admin removes one of yours that altimate-code has seen approved or waiting (up to the 200 approved ones it tracks per workspace), the TUI shows that once too, with the reason; your own removal and withdrawal show nothing.
+- A few seconds after the TUI starts in a linked project, it says in one line what changed in the skills and knowledge the workspace gives its team since you last looked, for example "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)." It reads the workspace's recent changes (the last 30 days) and keeps when you last looked per account, workspace and client in your own state directory (`$XDG_STATE_HOME/altimate-code/workspace-activity/`); the first time it only records where to start from. It waits while a review decision notice is showing. The VS Code extension asks `altimate-code serve` for the same line (`GET /altimate/workspace/activity?host=vscode`), with its own last look. Changes the service does not record (the owner detaching their own skill, the owner's knowledge selection) are not listed.
- Workspace skills are synced at the version the workspace serves you: the approved version, or your own pending version of a skill you submitted. The next sync follows what the workspace serves: a skill whose first submission is rejected, or that is detached from the workspace, is removed from the project; when an update to an approved skill is rejected or replaced, the skill stays at its approved version. Each skill is downloaded as one version: if it is approved or rejected while its files are being read, nothing of it is installed from that sync and it is fetched again on the next one. When a download fails, the copy already in the project is kept only if it is still the version the workspace serves, as far as the server has said (its list, or a read refused because the version just changed), or if neither the copy nor the list names a version (a copy synced before revisions, or an older server), in which case it is kept until the server says otherwise; a copy of a version it no longer serves (for example your rejected pending version), or of a skill it no longer lists, is removed until the download succeeds, even when no other skill could be downloaded. Two processes syncing the same project take turns: a sync never replaces or removes a snapshot another process installed after it started, and the next sync starts from the newer one.
- When the linked workspace has knowledge, the agent is told to check it for best practices and team conventions before answering, without you having to mention the knowledge base.
</file context>
| const ORIGINAL_XDG_STATE_HOME = process.env.XDG_STATE_HOME | ||
| const SANDBOX = mkdtempSync(path.join(os.tmpdir(), "altimate-activity-")) | ||
| mkdirSync(path.join(SANDBOX, "state"), { recursive: true }) | ||
| process.env.XDG_STATE_HOME = path.join(SANDBOX, "state") |
There was a problem hiding this comment.
P3: This test redirects state with XDG_STATE_HOME, but Global.Path.state reads OPENCODE_TEST_STATE_HOME and a module-load state const, so this override only works if @/global has not loaded yet. Set OPENCODE_TEST_STATE_HOME to the sandbox state dir (and restore it in afterAll) so the state location does not depend on import order.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/test/altimate/workspace/workspace-activity.test.ts, line 14:
<comment>This test redirects state with `XDG_STATE_HOME`, but `Global.Path.state` reads `OPENCODE_TEST_STATE_HOME` and a module-load `state` const, so this override only works if `@/global` has not loaded yet. Set `OPENCODE_TEST_STATE_HOME` to the sandbox state dir (and restore it in `afterAll`) so the state location does not depend on import order.</comment>
<file context>
@@ -0,0 +1,152 @@
+const ORIGINAL_XDG_STATE_HOME = process.env.XDG_STATE_HOME
+const SANDBOX = mkdtempSync(path.join(os.tmpdir(), "altimate-activity-"))
+mkdirSync(path.join(SANDBOX, "state"), { recursive: true })
+process.env.XDG_STATE_HOME = path.join(SANDBOX, "state")
+
+const { AltimateApi } = await import("../../../src/altimate/api/client")
</file context>
| const raw = await altimateRequest<unknown>("GET", `/${datamateId}/activity`, { | ||
| base: "/datamates", | ||
| actAs, | ||
| query: { limit: String(limit), ...(since ? { since } : {}) }, |
There was a problem hiding this comment.
WARNING: A server without the activity route reports an API-error row on every start
review-api.ts:127-132 passes expectedStatuses: [404] for exactly this reason ("A server or tenant without review answers 404 here on every poll: an answer, not an API error to report"). fetchActivity does not, so until altimate-backend#7876 is live on every tenant, each TUI start and extension connect sends a 404 that reportApiErrorRow records as workspace_api_error (api-client.ts:497-504). classify still maps it to unsupported afterwards, so the caller is unaffected — the row is pure telemetry noise. Passing expectedStatuses: [404] in this options object fixes it.
| if (mark !== since) await writeSeen({ ...state, seen: { ...state.seen, [host]: mark } }) | ||
| if (first) return { status: "first", workspace } | ||
| const line = summaryLine(workspace.name, items, hasMore) | ||
| return { status: "ok", workspace, items, ...(line ? { line } : {}) } |
There was a problem hiding this comment.
WARNING: items reaches clients with raw, non-printable server text
Item.name and actor_name are returned exactly as the server sent them, while the sibling /altimate/workspace/requests route makes every server string printable before responding (fromContribution, ruleRequests in review-requests.ts). Skill names are member-controlled, so they can carry terminal escapes or bidi controls; the TUI re-sanitizes line, but the VS Code extension is a separate consumer of this same payload and nothing in this repo guarantees it sanitizes. Either drop items from the response (no client here reads it — only line) or return printable(item.name).
| const since = state.seen[host] | ||
| const first = since === undefined | ||
| const { items, hasMore } = await fetchActivity(ctx.datamateId, since || undefined, ctx.actAs, first ? 1 : LIMIT) | ||
| const mark = items[0]?.at ?? since ?? "" |
There was a problem hiding this comment.
SUGGESTION: Changes past the 20-item cap are never shown
When hasMore is true the mark still jumps to the newest change, so the items between the previous mark and the 20th newest are excluded from every later since query: the line says "and more", but those changes can never be seen afterwards. Consider paging from the previous mark until it is reached (then the mark is honest), or wording the suffix as a capped sample.
| datamateId: ctx.datamateId, | ||
| } | ||
| const workspace = { id: ctx.datamateId, name: ctx.name } | ||
| await fs.mkdir(dir(), { recursive: true, mode: 0o700 }) |
There was a problem hiding this comment.
SUGGESTION: Redundant directory creation
writeSeen (line 89) and Flock.acquire (packages/core/src/util/flock.ts:320) both mkdir this same path, so this call duplicates them, and dir() is recomputed several times per call (here, in fileOf, and through the lock key). Computing it once and passing it down would remove the repetition.
| const line = printable(answer.line) | ||
| const announce = (tries: number) => { | ||
| if (disposed) return | ||
| if (tries < ACTIVITY_WAITS && toasterOf(api).shownSince(Date.now() - DECISION_TOAST_MS)) { |
There was a problem hiding this comment.
SUGGESTION: The line is marked seen before it is shown
changesSince already advanced the stored mark for this client before this GET returns, so if the TUI is disposed — or the toast never fires — during this up-to-20s wait for a decision toast, the line is lost permanently: the next start asks only for changes after it. Waiting for a decision toast before issuing the GET (rather than after) would close the window. The same exposure exists for any repeated or retried GET, since the route mutates per-user state on a GET.
| } | ||
|
|
||
| /** The longest a decision toast stays up: the activity line waits for it. */ | ||
| const DECISION_TOAST_MS = 15_000 |
There was a problem hiding this comment.
SUGGESTION: Duplicated toast duration
This restates the longest duration produced by decisionToast/combinedToast (15000). If one of those changes, this silently waits the wrong time and the "waits while a decision toast is up" behaviour drifts. Deriving it from a single shared constant would keep them in step.
| }) | ||
| // altimate_change start — workspace activity: what changed in the workspace's skills and knowledge since this | ||
| // client (`host`) last looked, as one line to show when a session starts. Marks it seen; the first look says nothing. | ||
| .get("/altimate/workspace/activity", async (c) => { |
There was a problem hiding this comment.
SUGGESTION: New route missing from the route-level tests
test/server/altimate-rules-routes.test.ts:103-114 lists every workspace route in its browser-origin refusal table, and this route plus its host validation (the 400 branch above) are not covered there. Worth adding, in particular because this GET mutates per-client state.
Code Review SummaryStatus: 7 Issues Found | Recommendation: Address before merge Overview
The design is sound: a per-client mark keyed by server, tenant, account and workspace, stored with a lock and temp-file rename, and the mark taken from the server's own newest change instead of the local clock. Two things stand out for the shipped path: the new fetch does not opt out of API-error telemetry for the 404 that older servers return (the sibling reviews client does), and the response hands clients the raw Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (6 files)
Fix these issues in Kilo Cloud Reviewed by deepseek-v4.1-flash-1017 · Input: 117.9K · Output: 34.4K · Cached: 2.1M Review guidance: REVIEW.md from base branch |
dev-punia-altimate
left a comment
There was a problem hiding this comment.
🤖 Code Review — OpenCodeReview (Gemini) — 3 finding(s)
- 3 anchored to a line (posted inline when the comment stream is on)
- 0 without a line anchor
All findings (full text)
1. packages/opencode/src/altimate/workspace/workspace-activity.ts (L147-L149)
[🔴 HIGH] The lock name string passed to Flock.withLock contains a colon (:). If Flock.withLock uses this identifier directly to construct a lock file or directory on the filesystem, it will crash on Windows OS, where colons are strictly prohibited in filenames (except for drive letters). Consider using a safe character like a hyphen (-) instead.
Suggested change:
return await Flock.withLock(
`workspace-activity-${path.basename(fileOf(scope))}`,
async (): Promise<Changes> => {
2. packages/opencode/src/altimate/workspace/workspace-activity.ts (L156-L157)
[🟠 MEDIUM] If the host parameter provided to changesSince is a dynamically generated identifier (like a unique session ID or UUID) rather than a bounded set of client names (e.g., 'ide' or 'tui'), the state.seen record stored in the local JSON file will grow indefinitely over time. This could lead to a storage and performance leak. Please ensure host is properly restricted or validated to prevent unbounded growth.
3. packages/opencode/src/altimate/workspace/workspace-activity.ts (L80-L81)
[🟠 MEDIUM] Relying on JSON.stringify for equality checking is brittle as it strictly depends on the property insertion order of objects. If the Zod parsed object or runtime construction ever alters the key order, this condition could evaluate to false, leading to a silent reset of the user's notification tracking state. Consider explicitly comparing the individual properties instead.
Suggested change:
const state = Seen.parse(JSON.parse(raw))
if (
state.scope.apiUrl === scope.apiUrl &&
state.scope.tenant === scope.tenant &&
state.scope.account === scope.account &&
state.scope.datamateId === scope.datamateId
) {
return state
}
| return await Flock.withLock( | ||
| `workspace-activity:${path.basename(fileOf(scope))}`, | ||
| async (): Promise<Changes> => { |
There was a problem hiding this comment.
[🔴 HIGH] The lock name string passed to Flock.withLock contains a colon (:). If Flock.withLock uses this identifier directly to construct a lock file or directory on the filesystem, it will crash on Windows OS, where colons are strictly prohibited in filenames (except for drive letters). Consider using a safe character like a hyphen (-) instead.
Suggested change:
| return await Flock.withLock( | |
| `workspace-activity:${path.basename(fileOf(scope))}`, | |
| async (): Promise<Changes> => { | |
| return await Flock.withLock( | |
| `workspace-activity-${path.basename(fileOf(scope))}`, | |
| async (): Promise<Changes> => { |
| const mark = items[0]?.at ?? since ?? "" | ||
| if (mark !== since) await writeSeen({ ...state, seen: { ...state.seen, [host]: mark } }) |
There was a problem hiding this comment.
[🟠 MEDIUM] If the host parameter provided to changesSince is a dynamically generated identifier (like a unique session ID or UUID) rather than a bounded set of client names (e.g., 'ide' or 'tui'), the state.seen record stored in the local JSON file will grow indefinitely over time. This could lead to a storage and performance leak. Please ensure host is properly restricted or validated to prevent unbounded growth.
| const state = Seen.parse(JSON.parse(raw)) | ||
| if (JSON.stringify(state.scope) === JSON.stringify(scope)) return state |
There was a problem hiding this comment.
[🟠 MEDIUM] Relying on JSON.stringify for equality checking is brittle as it strictly depends on the property insertion order of objects. If the Zod parsed object or runtime construction ever alters the key order, this condition could evaluate to false, leading to a silent reset of the user's notification tracking state. Consider explicitly comparing the individual properties instead.
Suggested change:
| const state = Seen.parse(JSON.parse(raw)) | |
| if (JSON.stringify(state.scope) === JSON.stringify(scope)) return state | |
| const state = Seen.parse(JSON.parse(raw)) | |
| if ( | |
| state.scope.apiUrl === scope.apiUrl && | |
| state.scope.tenant === scope.tenant && | |
| state.scope.account === scope.account && | |
| state.scope.datamateId === scope.datamateId | |
| ) { | |
| return state | |
| } |
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo supported files changed. |
Issue for this PR
No GitHub issue. This is part of the workspace review follow-ups, with backend AltimateAI/altimate-backend#7876 and the VS Code extension's client. Stacked on #1751, which it needs for the TUI's decision toaster.
Type of change
What does this PR do?
Everyone on a workspace learns what changed in the skills and knowledge it gives the team, in one line when a session starts. For example: "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)."
workspace-activity.ts:GET /datamates/{id}/activity(#7876: added, updated or removed, last 30 days) and builds the line.host) keeps its own last look per server, tenant, account and workspace, in the person's state directory (workspace-activity/).GET /altimate/workspace/activity?host=<client>for the IDE extension, behind the usual workspace-route checks.review-requests.contextis exported for it.usage/cli.md.How did you verify your code works?
bun test test/altimate/workspace/workspace-activity.test.tspasses 5 of 5:sinceand returns the line;bun run typecheckis clean, and the marker guard passes.test/cli/tui,test/altimate/rules,test/altimate/workspaceandtest/serverpass apart from failures that cleanmainhas too: threetest/serverHttpApi timeouts anddatamate_manager write that races the link.Cost side effects
None that grows with user data. It makes one small request per TUI start and per extension connection (
limit20).Screenshots / recordings
Checklist
🤖 Generated with Claude Code
Summary by cubic
Shows a one-line summary of what changed in the linked workspace's skills and knowledge since a client last looked, when a TUI session starts or an extension connects, for example "Since your last session in Growth: 2 skills added (naming, cost-guard), 1 knowledge base removed (Glossary)." The first look only records where to start and says nothing; each client keeps its own last look per server, tenant, account and workspace in the state directory, using server times so a skewed local clock cannot hide or repeat a change. The TUI shows the line a few seconds after startup, after the review-decision replay and only when no decision toast is showing.
Details
GET /altimate/workspace/activity?host=<client>for the VS Code extension, behind the usual workspace-route checks.GET /datamates/{id}/activity); servers without it report "unsupported" and show nothing.usage/cli.md.Written for commit 639b466. Summary will update on new commits.