Skip to content

OpenConceptLab/ocl_online#641 | The usage chip shows the count for the open map project - #134

Merged
snyaggarwal merged 6 commits into
mainfrom
ocl_online-641-pool
Nov 20, 2026
Merged

snyaggarwal merged 6 commits into
mainfrom
ocl_online-641-pool

Conversation

@paynejd

@paynejd paynejd commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Part of OpenConceptLab/ocl_online#641. Stacked on #132 (base ocl_online#641): merge #132 first, then retarget this to main.

What it does

  • The chip's report is kept per person and per map project. On a project that isn't saved yet, the person's own report is kept.
  • The usage read names the open project as map_project in the query string. The OCL AI Assistant reports the count that calls on that project are charged to, the same count each $invoke reply carries. So the chip no longer switches between two counts on one project.
  • A project's first save asks for the new project's report once the route has the project's id.
  • The Mapper doesn't work out whose count it is and never branches on who owns the project: the service decides. No wording changes.

Needs the OCL AI Assistant change that reads map_project (OpenConceptLab/ocl_online#641) to be deployed first. Until then, the service ignores the parameter and the chip behaves as it does with #132.

Tests

  • npm test: 693 pass. New tests cover the query parameter, the per-project reports and the first save.
  • CI's ESLint command: clean.

Review

Codex lean loop; each pass is posted below.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP

paynejd and others added 2 commits November 19, 2026 10:58
…ject, and each project keeps its own report

The OCL AI Assistant reports the count for the map project a call names.
The Mapper's $invoke calls already name it in X-OCL-Event-Metadata, but
GET /match/usage/ named none, so the chip could switch between two counts
on one project. The read now names the project the same way, and the
report is kept per person and project (none for a project not saved yet).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP
…he query string, and a first save asks once the route has the id

The usage read names the map project as `map_project` in the query string
rather than in the attribution header, which attributes a call: the OCL AI
Assistant reports the count the calls on that project are charged to.

A project's first save refreshed the usage before the route had the new
project's id, so its report was never asked for. The save now refreshes
only the capabilities, and the route gaining a project id asks for that
project's report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP
@paynejd
paynejd requested a review from snyaggarwal November 19, 2026 16:09
…r another project asks for the open one's report

F1.3: a call made before a project's first save keeps its reply's report
for no project, and skipped the refresh because the reply carried one, so
the saved project's report could miss that call. When the reply's project
isn't the open one, the open one's report is asked for.

F1.4: the route gaining a project id refreshes the capabilities with the
usage, so a permission granted only now still asks for the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 1 (codex-cli 0.169.0, commit cf38d73)

Verdict: findings, 4 findings.

  • F1.1 (P1) src/components/map-projects/MapperQuotaChip.jsx:38: A project cache miss makes the Preview tooltip show the AI Assistant call limit. Response: Not fixed here. The fallback line is main's, unchanged: main shows it on every project because it has no report, and the tooltip's other lines are of the same kind. It's existing debt on OpenConceptLab/ocl_online#532, which OpenConceptLab/ocl_online#714 removes. Here it shows on a project's first open until the read made on opening lands, or while that read fails. Removing it changes how the chip looks, so it's left to #714.
  • F1.2 (P1) src/components/map-projects/MapProject.jsx:6173: A recommendation can send a personal invocation after the project has been saved to an organization. Response: Declined: consistent as built. A call and the report it keeps both use the project open when the call was set up. A call set up before the first save names no project, so the service counts it as the person's own, and its reply is kept as theirs; the saved project's chip isn't affected. Which project a call names comes from main's attrHeaders, unchanged here.
  • F1.3 (P1) src/components/map-projects/MapProject.jsx:6270: A recommendation sent before the first save can leave the saved personal project's count stale. Response: Fixed in c335c17: when a reply is kept for a project other than the open one, the open one's report is asked for. Test added.
  • F1.4 (P2) src/components/map-projects/MapProject.jsx:855: The first-save usage read can be skipped when the capability refresh discovers a newly granted permission. Response: Fixed in c335c17: the route gaining a project id refreshes the capabilities along with the usage, so a permission granted only now still asks for the report.
findings.json
{
 "reviewer": "codex-cli 0.169.0",
 "perspective": "defects",
 "mode": "full",
 "commit": "cf38d73de0bed2fb2da404d1bf88f721adbf4d28",
 "verdict": "findings",
 "prior": [],
 "findings": [
  {
   "id": "F1.1",
   "severity": "P1",
   "tag": null,
   "file": "src/components/map-projects/MapperQuotaChip.jsx",
   "line": 38,
   "claim": "A project cache miss makes the Preview tooltip show the AI Assistant call limit.",
   "scenario": "A Preview user with a cached personal usage report opens a project for the first time. The new project key has no report, so the tooltip falls back to displaying calls used out of the call limit. A failed usage request leaves that limit visible.",
   "action": "Omit the AI Assistant line until a supported usage report is available for the project.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.2",
   "severity": "P1",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 6173,
   "claim": "A recommendation can send a personal invocation after the project has been saved to an organization.",
   "scenario": "A member requests a recommendation on an unsaved project. The first save navigates to the organization's project URL while the prompt template request is pending. When that request completes, both the invocation and its cache write still use the old render's missing project ID. The invocation is charged to the member while the chip reads the organization's count.",
   "action": "Capture the current project ID when the invocation is first sent and use that same ID for attribution, retries, and the reply cache key.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.3",
   "severity": "P1",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 6270,
   "claim": "A recommendation sent before the first save can leave the saved personal project's count stale.",
   "scenario": "A member sends a single recommendation on an unsaved personal project and saves while the invocation is pending. The first-save usage read returns before the service charges the invocation. The later reply contains the updated personal count but writes it to the no-project key. Because the reply carried usage, completion skips the refresh for the saved project, and the chip keeps showing the earlier count.",
   "action": "Refresh the displayed project's usage when a completed invocation wrote its report to a different key during first-save navigation.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F1.4",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 855,
   "claim": "The first-save usage read can be skipped when the capability refresh discovers a newly granted permission.",
   "scenario": "A member can save projects, but their cached permissions lack the newly granted AI Assistant permission. The route effect runs before the save's capability refresh completes and skips the usage read. The capability response then grants access locally, but the save refresh disabled its usage callback and the route ID has already been recorded. The chip has no project report until another action refreshes it.",
   "action": "Coordinate the first-save usage read with the capability refresh and add a lifecycle test that delays the capability response until after navigation.",
   "lines_delta": null,
   "confidence": "high"
  }
 ]
}

…h reply for another project asks for the open one's report

F2.1: an AutoMatch reply that lands after the project was saved is kept
for no project, and a run leaves the usage to its end, which had passed.
It now asks for the open project's report too.

F2.2: the source test also pins that the usage read names the route's
project, the same id the calls name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex review, pass 2 (codex-cli 0.169.0, commit c335c17)

Verdict: findings, 2 findings.

Earlier findings: FC.1 resolved, FC.2 resolved, F1.1 unresolved, F1.2 unresolved, F1.3 unresolved, F1.4 resolved. F1.1 and F1.2 stand as answered in pass 1. Codex left F1.3 open because of the AutoMatch path, which is F2.1's fix.

  • F2.1 (P2) src/components/map-projects/MapProject.jsx:6266: The follow-up refresh for a reply kept under a different project key only runs for single-row calls. Response: Fixed in 9d60f10: an AutoMatch reply kept for a project other than the open one asks for the open one's report, as a single call's does.
  • F2.2 (P2) src/components/map-projects/__tests__/usageRouteProject.test.js:37: The first-save test checks the callback's source text without verifying that the usage request names the saved project. Response: Fixed in part in 9d60f10. The repo's integration harness mirrors a pattern rather than mounting MapProject, so it wouldn't exercise this code either. The source test now pins that the read names the route's project (project: usageProjectIdRef.current, set from params.projectId each render), the same id the calls' attribution and their kept reports use, so project: undefined fails it.
findings.json
{
 "reviewer": "codex-cli 0.169.0",
 "perspective": "defects",
 "mode": "verify",
 "commit": "c335c17e834549e825e83ff5e130d1ca9f1569f5",
 "verdict": "findings",
 "prior": [
  {
   "id": "FC.1",
   "status": "resolved"
  },
  {
   "id": "FC.2",
   "status": "resolved"
  },
  {
   "id": "F1.1",
   "status": "unresolved"
  },
  {
   "id": "F1.2",
   "status": "unresolved"
  },
  {
   "id": "F1.3",
   "status": "unresolved"
  },
  {
   "id": "F1.4",
   "status": "resolved"
  }
 ],
 "findings": [
  {
   "id": "F2.1",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 6266,
   "claim": "The follow-up refresh for a reply kept under a different project key only runs for single-row calls.",
   "scenario": "Stop Auto Match on an unsaved personal project while an AI row is still running, then save before its reply arrives. The saved project's usage read can capture the provisional token count. When the final reply arrives, it updates only the unsaved entry, leaving the saved project's chip stale until another refresh.",
   "action": "Apply the project-change refresh to late Auto Match replies too. Keep each reply under the key for the project its request named.",
   "lines_delta": null,
   "confidence": "high"
  },
  {
   "id": "F2.2",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/__tests__/usageRouteProject.test.js",
   "line": 37,
   "claim": "The first-save test checks the callback's source text without verifying that the usage request names the saved project.",
   "scenario": "Replacing `project: usageProjectIdRef.current` with `project: undefined` leaves all three source assertions green. After the first save, the request would read the member's own count and the saved project's chip would receive no report.",
   "action": "Use the repository's React integration harness to exercise the first-save route transition and assert that the usage request sends the new project ID exactly once.",
   "lines_delta": null,
   "confidence": "high"
  }
 ]
}

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Simplification review (Claude subagent, commit 9d60f10)

2 items: 1 applied in 5f5614f, 1 declined.

  • S1 (dup-test), declined: the source-text assertions in usageRouteProject.test.js. MapProject can't be mounted in these tests, and they're what catches the read losing its project (Codex F2.2). They break on a reformat, which is the cost of that.
  • S2 (shrink), applied: hasProject uses project != null, as viewBuilders.js does.

Tests: npm test gives 695 pass. CI's ESLint: clean. A Codex check of 9d60f10..5f5614f follows.

…oject asks only for the open one's report

Codex's check of c335c17..5f5614f on #134 (FC.1): the
refresh also asked for the account, and a throttled reply to that could
hold up the Mapper. A run's own refresh already did the capabilities, so
this asks only for the report, which never blocks the Mapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qVq1YwJv43QFnQSLDP
@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits c335c17..5f5614f (codex-cli 0.169.0)

Verdict: findings, 1 finding. F2.1 and F2.2 are resolved.

  • FC.1 (P2) src/components/map-projects/MapProject.jsx:6276: A late AutoMatch reply can block the Mapper by starting an unnecessary account refresh. Response: Fixed in 800f5f5: that branch asks only for the report, which goes through axios and never blocks the Mapper. A run's own refresh already did the capabilities.
findings.json
{
 "reviewer": "codex-cli 0.169.0",
 "perspective": "defects",
 "mode": "final",
 "commit": "5f5614fcb5e04f75b099ac48c4061896c7ca4cb2",
 "verdict": "findings",
 "prior": [
  {
   "id": "F2.1",
   "status": "resolved"
  },
  {
   "id": "F2.2",
   "status": "resolved"
  }
 ],
 "findings": [
  {
   "id": "FC.1",
   "severity": "P2",
   "tag": null,
   "file": "src/components/map-projects/MapProject.jsx",
   "line": 6276,
   "claim": "A late AutoMatch reply can block the Mapper by starting an unnecessary account refresh.",
   "scenario": "Stop AutoMatch on an unsaved project while an AI request is pending, then save the project. When the reply arrives, this branch sends an extra GET /user/. If that request returns HTTP 429 with a Retry-After header, the app-wide countdown blocks the Mapper even though the save succeeded.",
   "action": "Use the existing usage-only refresh for the open project in this branch. Keep the account refreshes at run completion and route change.",
   "lines_delta": null,
   "confidence": "high"
  }
 ]
}

@paynejd

paynejd commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Codex check of commits 5f5614f..800f5f5 (codex-cli 0.169.0)

Verdict: clean. FC.1 is resolved. #134 is ready for review at 800f5f5, with CI green.

Summary of the loop:

  • Pass 1 found F1.3 (P1) and F1.4 (P2), both fixed. F1.1 and F1.2 were declined with reasons.
  • Pass 2 found F2.1 and F2.2 (P2), both fixed.
  • Simplification: S2 taken, S1 declined.
  • The checks found FC.1 (P2), now fixed, and this one is clean.

Merge #132 first, then retarget this PR to main. The OCL AI Assistant change it needs deploys first.

findings.json
{
 "reviewer": "codex-cli 0.169.0",
 "perspective": "defects",
 "mode": "final",
 "commit": "800f5f5f02a9894e54f751659e89de2e75d88975",
 "verdict": "clean",
 "prior": [
  {
   "id": "FC.1",
   "status": "resolved"
  }
 ],
 "findings": []
}

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved at 800f5f5.

Checked:

  • Saved reports are per person and project (ai_assistant_usage:<user>:project:<id>), and a project that isn't saved yet keeps the plain key.
  • The usage read sends map_project only when there's a project. Only one refresh runs per person and project at a time.
  • The ids match: a reply is kept for the project its $invoke named (params.projectId at send time). If that's no longer the open project, the open project's report is fetched again, both for a single row and for a run.
  • First save: the save's own refresh skips the report. The route effect fetches the new project's report once the id is in the URL, and does the same on any change of project.
  • The Mapper only shows what the OCL AI Assistant reports. It never decides whose count it is. It's safe before the service is deployed: an older service ignores the parameter.

P3, not blocking: saved reports for old projects are never pruned from localStorage.

Merge order: #132 first, then retarget this to main. Deploy after the OCL AI Assistant release that reads map_project (OpenConceptLab/ocl-ai-assistant#256).

@paynejd

paynejd commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Thanks, Sunny. The P3 is recorded and left as is: each saved report is one small {meter, used} entry per person and project, read only for the open project. It can be pruned later if storage use ever shows up.

Merge order noted: #132 first, then this goes to main. If #132 is squash-merged, I'll rebase this onto main; with a merge commit, GitHub retargets it.

Base automatically changed from ocl_online#641 to main November 20, 2026 05:27
@snyaggarwal
snyaggarwal merged commit ca4576a into main Nov 20, 2026
2 checks passed
@snyaggarwal
snyaggarwal deleted the ocl_online-641-pool branch November 20, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants