Skip to content

Cookie banner uncategorised category#1077

Merged
codenem merged 7 commits intomainfrom
cookie-banner-uncategorised-category
Apr 21, 2026
Merged

Cookie banner uncategorised category#1077
codenem merged 7 commits intomainfrom
cookie-banner-uncategorised-category

Conversation

@codenem
Copy link
Copy Markdown
Contributor

@codenem codenem commented Apr 20, 2026

Closes ENG-302


Summary by cubic

Adds an Uncategorised cookie category and replaces the required flag with a kind enum to simplify consent logic, category management, and UI. Also adds an atomic moveCookieToCategory mutation and improves delete flows with confirmation and clearer error handling.

  • New Features

    • Switched from required to kind (NORMAL, NECESSARY, UNCATEGORISED) across backend, GraphQL, and packages/cookie-banner.
    • Added a single UNCATEGORISED category per banner. Deleting a NORMAL category moves its cookies there. NECESSARY and UNCATEGORISED are undeletable; NECESSARY is always on.
    • New GraphQL mutation moveCookieToCategory for atomic cookie moves. Console adds a per-cookie “Move to” dropdown, delete confirmations with clear messaging, and toasts that surface server errors; badges/buttons reflect kind. Edit/add forms were extracted into components for a cleaner cookie editor.
    • Documented a React guideline to avoid destructuring unused values and removed an unused destructured variable.
  • Migration

    • Run pkg/coredata/migrations/20260420T143027Z.sql to add kind, backfill from required, drop required, and enforce one NECESSARY and one UNCATEGORISED per banner.
    • Update GraphQL usage: CookieCategory.requiredkind; remove required from CreateCookieCategoryInput. Use moveCookieToCategory instead of two updateCookieCategory calls when moving cookies.
    • Update web components and client: probo-category now uses a kind attribute; consent defaults in packages/cookie-banner depend on kind === "NECESSARY".

Written for commit 9848795. Summary will update on new commits.

@codenem codenem force-pushed the cookie-banner-uncategorised-category branch from 507e61c to 39acc2b Compare April 21, 2026 05:23
@codenem codenem marked this pull request as ready for review April 21, 2026 05:25
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/CategorySection.tsx">

<violation number="1" location="apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/CategorySection.tsx:271">
P1: Moving a cookie is implemented as two non-atomic updates, so a partial failure can duplicate the cookie across categories.</violation>
</file>

<file name="pkg/coredata/cookie_banner_version.go">

<violation number="1" location="pkg/coredata/cookie_banner_version.go:42">
P1: This snapshot schema change is not backward-compatible with existing stored version JSON (`required`), so legacy snapshots deserialize with an empty `kind` and can lose necessary-category semantics.</violation>
</file>

<file name="pkg/cookiebanner/service.go">

<violation number="1" location="pkg/cookiebanner/service.go:973">
P2: Uncategorised is only auto-created when the deleted category has cookies, so banners missing that system category can stay invalid after deleting empty categories.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread pkg/coredata/cookie_banner_version.go
Comment thread pkg/cookiebanner/service.go
@codenem codenem requested a review from a team April 21, 2026 06:41
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx">

<violation number="1" location="apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx:35">
P2: Don't initialize editable state once from props here. With index keys in the parent, the row can be reused for a different cookie while keeping stale form values, so Save may write the wrong data.</violation>
</file>

<file name="pkg/cookiebanner/service.go">

<violation number="1" location="pkg/cookiebanner/service.go:951">
P1: Reject moves where source and target category are identical; currently this duplicates the cookie when both IDs are the same.</violation>
</file>

<file name="pkg/server/api/console/v1/graphql/cookie_banner.graphql">

<violation number="1" location="pkg/server/api/console/v1/graphql/cookie_banner.graphql:245">
P1: Reject source==target here; a self-move can duplicate the cookie.</violation>

<violation number="2" location="pkg/server/api/console/v1/graphql/cookie_banner.graphql:247">
P2: Use a stable cookie identifier instead of the name; name-only lookup is ambiguous.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread pkg/cookiebanner/service.go
Comment thread pkg/server/api/console/v1/graphql/cookie_banner.graphql
Comment thread pkg/server/api/console/v1/graphql/cookie_banner.graphql
Comment thread pkg/server/api/console/v1/types/cookie_category.go Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="pkg/server/api/console/v1/cookie_banner_resolvers.go">

<violation number="1" location="pkg/server/api/console/v1/cookie_banner_resolvers.go:540">
P2: Return a non-NotFound error for banner mismatches; both categories were already found, so this path is an invalid move, not a missing resource.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread pkg/server/api/console/v1/cookie_banner_resolvers.go
codenem added 7 commits April 21, 2026 11:40
Replace the `required` boolean column on cookie_categories with a `kind`
enum (NORMAL, NECESSARY, UNCATEGORISED). The Necessary category remains
undeletable and always-on for consent; the new Uncategorised category is
also undeletable but users can opt out of it.

When a category is deleted, its cookies are merged into the Uncategorised
category (lazy-created for legacy banners that don't have one yet).

Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Moving a cookie between categories previously required two sequential
updateCookieCategory mutations, which was not atomic and could leave
data in an inconsistent state if the second call failed. This adds a
dedicated moveCookieToCategory mutation that performs both updates in
a single transaction.

Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem force-pushed the cookie-banner-uncategorised-category branch from f4591e5 to 9848795 Compare April 21, 2026 07:40
@codenem codenem merged commit 9848795 into main Apr 21, 2026
17 checks passed
@codenem codenem deleted the cookie-banner-uncategorised-category branch April 21, 2026 07:46
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