-
Notifications
You must be signed in to change notification settings - Fork 0
Import upstream quality fixes #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { DEFAULT_THEME_STATE } from "../theme/theme.logic"; | ||
|
|
||
| function installThemeDom() { | ||
| const classList = { | ||
| add: vi.fn(), | ||
| remove: vi.fn(), | ||
| toggle: vi.fn(), | ||
| }; | ||
| const style = { | ||
| removeProperty: vi.fn(), | ||
| setProperty: vi.fn(), | ||
| }; | ||
| const root = { | ||
| classList, | ||
| offsetHeight: 0, | ||
| setAttribute: vi.fn(), | ||
| style, | ||
| }; | ||
|
|
||
| vi.stubGlobal("document", { documentElement: root }); | ||
| vi.stubGlobal("localStorage", { | ||
| getItem: vi.fn(() => null), | ||
| setItem: vi.fn(), | ||
| }); | ||
| vi.stubGlobal("window", { | ||
| matchMedia: vi.fn(() => ({ matches: false })), | ||
| }); | ||
|
|
||
| return { classList, root, style }; | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| vi.resetModules(); | ||
| vi.unstubAllGlobals(); | ||
| }); | ||
|
|
||
| describe("applyThemeState", () => { | ||
| it("does not rewrite DOM attributes or variables for identical theme inputs", async () => { | ||
| const dom = installThemeDom(); | ||
| const { applyThemeState } = await import("./useTheme"); | ||
|
|
||
| const initialAttributeWrites = dom.root.setAttribute.mock.calls.length; | ||
| const initialClassToggles = dom.classList.toggle.mock.calls.length; | ||
| const initialVariableWrites = dom.style.setProperty.mock.calls.length; | ||
| const initialVariableRemovals = dom.style.removeProperty.mock.calls.length; | ||
|
|
||
| applyThemeState(DEFAULT_THEME_STATE); | ||
|
|
||
| expect(dom.root.setAttribute).toHaveBeenCalledTimes(initialAttributeWrites); | ||
| expect(dom.classList.toggle).toHaveBeenCalledTimes(initialClassToggles); | ||
| expect(dom.style.setProperty).toHaveBeenCalledTimes(initialVariableWrites); | ||
| expect(dom.style.removeProperty).toHaveBeenCalledTimes(initialVariableRemovals); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
docs/superpowers/plans/2026-05-24-upstream-quality-imports.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Upstream Quality Imports Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Import three high-value upstream ideas into JCode with local tests and minimal, idiomatic adaptations. | ||
|
|
||
| ## File Structure | ||
|
|
||
| - `docs/superpowers/specs/2026-05-24-upstream-quality-imports-design.md`: approved design for the import tranche. | ||
| - `docs/superpowers/plans/2026-05-24-upstream-quality-imports.md`: this implementation plan. | ||
| - `apps/web/src/hooks/useTheme.ts`: theme mode resolution and DOM synchronization seam. | ||
| - `apps/web/src/hooks/useTheme.test.ts` or existing theme hook/runtime test file: focused tests for repeated theme sync no-op behavior. | ||
| - `apps/server/src/provider/Layers/ProviderHealth.ts`: provider update command execution seam. | ||
| - `apps/server/src/provider/Layers/ProviderHealth.test.ts`: focused tests that update commands run through a shell on Windows. | ||
| - `apps/server/src/checkpointing/Layers/CheckpointDiffQuery.ts`: checkpoint diff query seam for narrow hot-path improvement. | ||
| - `apps/server/src/checkpointing/Layers/CheckpointDiffQuery.test.ts`: focused tests for scoped diff reads and stable checkpoint lookup behavior. | ||
| - `apps/web/src/components/DiffPanel.tsx`: only touch if server-side diff seam cannot fully address the hot path. | ||
|
|
||
| ## Tasks | ||
|
|
||
| - [ ] Create or update a focused theme sync test that fails because repeated identical theme application rewrites DOM state. | ||
| - [ ] Run the focused theme test and confirm the failure is the expected repeated-write assertion. | ||
| - [ ] Implement the smallest theme sync no-op cache in `useTheme.ts` or a helper extracted from it. | ||
| - [ ] Run the focused theme test and confirm it passes. | ||
| - [ ] Create or update a focused provider update test for Windows shell execution. | ||
| - [ ] Run the focused provider test and confirm the expected shell assertion. | ||
| - [ ] Implement the provider update Windows-shell adaptation in `ProviderHealth.ts` if the test shows it is missing, without changing update locking or result reporting. | ||
| - [ ] Run the focused provider test and confirm it passes. | ||
| - [ ] Inspect `CheckpointDiffQuery` current tests and choose one narrow DPCode #129 hot-path behavior that is locally testable. | ||
| - [ ] Create or update a focused checkpoint diff test that fails for the chosen hot-path behavior. | ||
| - [ ] Run the focused checkpoint diff test and confirm the expected failure. | ||
| - [ ] Implement the smallest checkpoint/diff adaptation needed to pass the test. | ||
| - [ ] Run the focused checkpoint diff test and confirm it passes. | ||
| - [ ] Run focused workspace tests for all touched areas. | ||
| - [ ] Run `bun run --cwd apps/web typecheck` and `bun run --cwd apps/server typecheck`. | ||
| - [ ] Run `bun run fmt:check -- <touched files>`. | ||
| - [ ] Run LSP diagnostics for touched TypeScript files. | ||
| - [ ] Run Aikido full scan on modified first-party code. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - [ ] Reapplying the same theme inputs is a no-op while real theme changes still apply. | ||
| - [ ] Provider update commands run through a shell on Windows. | ||
| - [ ] One narrow diff/checkpoint hot-path improvement is implemented and tested. | ||
| - [ ] No upstream branch is merged wholesale or copied 1:1 without local adaptation. | ||
| - [ ] All focused verification and security checks pass or are reported with exact evidence. | ||
|
|
||
| ## Notes | ||
|
|
||
| - Keep the slices independently revertible. | ||
| - Stop and defer the DPCode diff slice if it expands beyond a narrow tested seam. | ||
| - Prefer strengthening existing JCode tests when an upstream idea is already implemented. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.