Skip to content

chore: remove export_count legacy alias from export state API#66

Merged
wpak-ai merged 3 commits into
masterfrom
chore/remove-export-count-alias
Jun 4, 2026
Merged

chore: remove export_count legacy alias from export state API#66
wpak-ai merged 3 commits into
masterfrom
chore/remove-export-count-alias

Conversation

@clean6378-max-it

@clean6378-max-it clean6378-max-it commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #63

Summary

  • Removes duplicate export_count field from GET /api/export/state; SPA reads last_export_session_count only
  • Updates docs/api-reference.md and records removal under [Unreleased] in CHANGELOG.md
  • Aligns tests in test_api_routes.py and test_export_api_bulk.py with the canonical response shape

Closes Chen W1 #4

Test plan

  • python -m pytest tests/test_api_routes.py tests/test_export_api_bulk.py -q
  • python -m pytest -q
  • npm test
  • CI green on Ubuntu + Windows
  • Manual: curl -s http://127.0.0.1:5000/api/export/state returns no export_count key

Summary by CodeRabbit

  • Breaking Changes

    • Removed export_count from GET /api/export/state response; use last_export_session_count and last_export_time instead.
  • Documentation

    • Updated API reference and changelog; removal recorded under Unreleased.
    • Clarified deprecation policy for removing SPA-only fields before the first tag.
  • Bug Fixes

    • UI treats missing/invalid last_export_session_count as 0.
  • Tests

    • Updated tests to expect last_export_session_count and omit export_count.

Complete the export_count migration by removing the duplicate field from GET /api/export/state and updating the bundled SPA, tests, and docs to use last_export_session_count only.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 329753f8-4e7f-40a3-a13e-3e2b7ed0b6a7

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf7cc9 and 721afcd.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • api/export_api.py
  • docs/api-reference.md
  • docs/deprecation-policy.md
  • static/js/projects.js
  • tests/test_api_routes.py
  • tests/test_export_api_bulk.py
💤 Files with no reviewable changes (1)
  • api/export_api.py
✅ Files skipped from review due to trivial changes (2)
  • docs/api-reference.md
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • static/js/projects.js
  • tests/test_api_routes.py

📝 Walkthrough

Walkthrough

Remove the legacy export_count field from the /api/export/state response, standardize on last_export_session_count, update the SPA fallback, synchronize tests, and update API docs, deprecation policy, and the changelog.

Changes

Export state API contract cleanup

Layer / File(s) Summary
Export state API contract removal
api/export_api.py
The /api/export/state response now returns last_export_time and last_export_session_count; the legacy export_count field was removed.
Frontend session count integration
static/js/projects.js
showProjects reads last_export_session_count and falls back to 0 when the value is missing or unparseable, removing the old export_count fallback.
Test assertions for new contract
tests/test_api_routes.py, tests/test_export_api_bulk.py
Tests updated to assert last_export_session_count presence and to assert that export_count is absent from the response JSON.
API documentation and changelog updates
docs/api-reference.md, CHANGELOG.md, docs/deprecation-policy.md
API reference example JSON, CHANGELOG.md, and deprecation policy updated to remove the deprecated export_count alias, document its removal under Unreleased, and add the “Bundled SPA + pre-first-tag (path B)” removal guidance.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs:

Suggested reviewers:

  • timon0305
  • wpak-ai

"I hopped through JSON fields with care,
Brought last_export_session_count into the light;
The old alias tucked away in changelog air,
Tests and SPA now read the single true sight.
Hooray — tidy bytes and a hopping delight! 🐰"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: remove export_count legacy alias from export state API' clearly and concisely summarizes the main change in the pull request—removing a deprecated field from the API response.
Linked Issues check ✅ Passed The PR fulfills all coding objectives from issue #63: removes export_count from api/export_api.py, updates static/js/projects.js to read only last_export_session_count, aligns tests in tests/test_api_routes.py and tests/test_export_api_bulk.py, and updates docs/api-reference.md and CHANGELOG.md accordingly.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the requirements from issue #63. Additionally, docs/deprecation-policy.md was updated to document the pre-first-tag removal pathway, which clarifies the policy context for this removal and is in-scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-export-count-alias

Comment @coderabbitai help to get the list of available commands and usage tips.

@clean6378-max-it

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit. please review this PR fully

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the PR diff and file contents
gh pr view 66 --repo cppalliance/claude-code-chat-browser --json title,body,files,state,additions,deletions

echo "=== PR DIFF ==="
gh pr diff 66 --repo cppalliance/claude-code-chat-browser

echo "=== api/export_api.py ==="
cat api/export_api.py

echo "=== static/js/projects.js ==="
cat static/js/projects.js

echo "=== tests/test_api_routes.py ==="
cat tests/test_api_routes.py

echo "=== tests/test_export_api_bulk.py ==="
cat tests/test_export_api_bulk.py

echo "=== docs/api-reference.md ==="
cat docs/api-reference.md

echo "=== CHANGELOG.md ==="
cat CHANGELOG.md

Length of output: 43780



@clean6378-max-it — here is the full review of PR #66.


Overall Assessment

The change is correct and well-scoped. All consumer sites (Python API, bundled SPA, tests, API docs, changelog) are updated atomically in a single PR, which is the right way to handle a breaking removal. No issues with the core logic.


File-by-file Review

api/export_api.py

Removing "export_count": n is clean. The remaining shape is clear:

{
    "last_export_time": state.get("lastExportTime"),   # null before first export
    "last_export_session_count": n,                     # 0 before first export
}

No issues.


static/js/projects.js

// Before
parseInt(exportState.last_export_session_count ?? exportState.export_count ?? 0, 10)
// After
parseInt(exportState.last_export_session_count ?? 0, 10)

The removed fallback was already dead code for any server running this PR, so the change is correct. The Math.max(0, ... || 0) double-guard against NaN/negative is retained — fine.


tests/test_api_routes.py ⚠️ Minor suggestion

The assertion was correctly flipped from export_count to last_export_session_count. However, neither this test nor test_export_state_json_fields asserts that export_count is absent from the response. A future accidental re-introduction (e.g. someone re-adds the alias) would pass the test suite silently.

Suggested addition to test_export_state_defaults:

def test_export_state_defaults(client_empty):
    resp = client_empty.get("/api/export/state")
    assert resp.status_code == 200
    body = resp.get_json()
    assert "last_export_session_count" in body
    assert "export_count" not in body          # guard: legacy alias must stay removed

Similarly for test_export_state_json_fields:

assert body["last_export_session_count"] == 5
assert "export_count" not in body              # guard: legacy alias must stay removed

tests/test_export_api_bulk.py

Dropping assert body["export_count"] == 5 is correct. The remaining assertion on last_export_session_count is sufficient.


docs/api-reference.md

Field table and JSON example are clean after removing the export_count row. The blank line between the table and the code block is harmless. No issues.


CHANGELOG.md 🔧 Nit

The entry reads:

export_count on GET /api/export/state — use last_export_session_count (deprecated since policy PR; bundled SPA updated in same release)

"deprecated since policy PR" is vague for anyone reading the changelog later. Consider referencing the PR number explicitly, e.g.:

- `export_count` on `GET /api/export/state` — use `last_export_session_count`
  (deprecated in PR `#XX` / [deprecation policy](docs/deprecation-policy.md); bundled SPA updated in same release)

Summary

Area Status Notes
API endpoint Correct removal
SPA JS Fallback correctly removed
Tests — positive assertions Correctly updated
Tests — negative assertions ⚠️ Missing "export_count" not in body guard
API docs Clean
CHANGELOG 🔧 nit "policy PR" reference is vague

The PR is mergeable as-is; the two test additions above would make the removal self-enforcing against regression.

Address PR review: add negative assertions so re-introducing the legacy alias fails the suite, and reference PR #60 in the CHANGELOG removal note.

@timon0305 timon0305 left a comment

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.

Diff is clean and the canonical-field path looks right. Main concern is on the deprecation timing — flagged inline.

Comment thread CHANGELOG.md Outdated
Comment thread docs/api-reference.md
Comment thread static/js/projects.js
Document path B: 0.1.0.dev0 has no git tag yet; export_count removal in [Unreleased] is acceptable for bundled SPA+API atomic deploy. Update example table and CHANGELOG wording per review.
@clean6378-max-it clean6378-max-it force-pushed the chore/remove-export-count-alias branch from 0cf7cc9 to 721afcd Compare June 4, 2026 21:12
@clean6378-max-it clean6378-max-it requested a review from wpak-ai June 4, 2026 21:55
@wpak-ai wpak-ai merged commit 6952d6d into master Jun 4, 2026
9 checks passed
@wpak-ai wpak-ai deleted the chore/remove-export-count-alias branch June 4, 2026 23:54
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.

claude-code-chat-browser: Remove export_count legacy alias from export state API

3 participants