Skip to content

refactor(site): replace !! with Boolean() for boolean coercion#24180

Merged
DanielleMaywood merged 2 commits intomainfrom
dm/replace-double-negation-with-boolean
Apr 9, 2026
Merged

refactor(site): replace !! with Boolean() for boolean coercion#24180
DanielleMaywood merged 2 commits intomainfrom
dm/replace-double-negation-with-boolean

Conversation

@DanielleMaywood
Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agent on behalf of Danielle Maywood 🤖

Replaces all !!<variable> double-negation patterns in the frontend with Boolean(<variable>) for explicit boolean coercion.

Two special cases where !! was serving as a type-narrowing mechanism (TypeScript's aliased conditional narrowing):

  • GitPanel.tsx!!remoteDiffStats && remoteDiffStats.additions replaced with remoteDiffStats != null && ... to preserve narrowing.
  • NotificationsPage.tsxconst ready = !!(...data && ...data && ...data) replaced with explicit != null checks to preserve aliased narrowing through the ready variable.
  • TaskPage.tsx.filter((a) => !!a) replaced with .filter(Boolean) which is idiomatic and type-safe in TypeScript 5.5+.

25 files changed, zero !! remaining in site/src.

@github-actions github-actions bot added the community Pull Requests and issues created by the community. label Apr 8, 2026
@DanielleMaywood DanielleMaywood removed the community Pull Requests and issues created by the community. label Apr 9, 2026
@DanielleMaywood DanielleMaywood marked this pull request as ready for review April 9, 2026 08:54
@DanielleMaywood DanielleMaywood requested a review from johnstcn April 9, 2026 08:54
Copy link
Copy Markdown
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

I'm fine with this, but could you explain why this is better?

@DanielleMaywood
Copy link
Copy Markdown
Contributor Author

@johnstcn It's more explicit about what it's doing (that we're casting to a boolean) instead of using javascript double invert logic !!. It's also the codebase convention that we've drifted from in AgentsPage/

If @aslilac is reviewing a PR and spots them she always calls out to switch over to Boolean instead

@DanielleMaywood DanielleMaywood merged commit 3d139c1 into main Apr 9, 2026
52 of 55 checks passed
@DanielleMaywood DanielleMaywood deleted the dm/replace-double-negation-with-boolean branch April 9, 2026 09:48
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants