Skip to content

Conversation

@eweren
Copy link
Contributor

@eweren eweren commented Oct 18, 2025

fixes #83 and #84

Summary by CodeRabbit

  • Style

    • Improved dark-mode theming: primary text color, better code editor placeholder contrast, and increased tooltip/bottom-actions stacking order.
  • New Features

    • Settings toggle to ignore hidden layers including their child texts; persisted in settings.
    • Ancestor-aware hidden-layer filtering when the toggle is enabled.
  • Bug Fixes / UX

    • More specific error messages for too-many uploaded images and invalid API key; screenshot upload errors surface while translations continue.
    • Connect icon now shows consistently; screenshot counting and upload flow refined.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Walkthrough

Adds a dark-mode primary text CSS variable and applies it to CodeMirror placeholders; introduces optional ignoreHiddenLayersIncludingChildren (type, storage, UI) and updates node inclusion to optionally check hidden ancestors; refines Pull/Push error handling for uploaded images and screenshot/tag flows; removes an unused mutation import; small UI and z-index tweaks.

Changes

Cohort / File(s) Summary
Global dark-mode styles
src/ui/styles.css
Adds --figma-color-text-primary: #ffffff inside @media (prefers-color-scheme: dark).
StringsEditor dark-mode placeholder style
src/ui/views/Settings/StringsEditor.css
Dark-mode rule: .strings-editor .cm-placeholder { color: var(--figma-color-text-primary) !important; }.
New setting: ignoreHiddenLayersIncludingChildren (type + storage)
src/types.ts, src/main/utils/settingsTools.ts
Adds optional ignoreHiddenLayersIncludingChildren?: boolean to GlobalSettings; reads/destructures and persists it to both global and document plugin storage.
Settings UI toggle
src/ui/views/Settings/StringsSection.tsx
Adds local state and handler for ignoreHiddenLayersIncludingChildren; renders nested checkbox when ignoreHiddenLayers is enabled and updates tolgeeConfig.
Node visibility filtering logic
src/main/utils/nodeTools.ts
Reworks shouldIncludeNode to optionally traverse ancestors when the new flag is enabled; excludes nodes with any hidden ancestor (with try/catch around traversal); otherwise retains prior hidden-node behavior.
Pull error handling
src/ui/views/Pull/Pull.tsx
Adds specific catch branch for "too_many_uploaded_images" setting message: "Too many uploaded images. Disable update screenshots in settings."
Push flow & mutation cleanup
src/ui/views/Push/Push.tsx
Removes addNewTranslations mutation import; introduces screenshot-count state / derived totalScreenshotCount; wraps tag and per-screenshot updates in try/catch with specific handling for too_many_uploaded_images; adjusts translation resolution logic (NEW vs OVERRIDE) and updates user-facing error messages.
Index list item UI tweak
src/ui/views/Index/ListItem.tsx
Removes editorMode.data !== "dev" gate so InsertLink icon renders based solely on node.connected.
Z-index adjustments
src/ui/components/ActionsBottom/ActionsBottom.css, src/ui/components/InfoTooltip/InfoTooltip.css
Increased .container z-index to 2 and added z-index: 2 to .info respectively.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant SettingsUI as Settings UI
  participant SettingsTools as settingsTools
  participant PluginStorage as Plugin Storage
  participant NodeTools as nodeTools
  Note over SettingsUI,NodeTools: Opt-in flag controls ancestor-aware filtering

  SettingsUI->>SettingsTools: setTolgeeConfig(ignoreHiddenLayersIncludingChildren)
  SettingsTools->>PluginStorage: setGlobalSettings(..., ignoreHiddenLayersIncludingChildren)
  SettingsTools->>PluginStorage: setDocumentData(..., ignoreHiddenLayersIncludingChildren)
  SettingsUI-->>SettingsUI: local state updated

  Note over NodeTools: Node inclusion check
  NodeTools->>PluginStorage: read ignoreHiddenLayersIncludingChildren
  PluginStorage-->>NodeTools: flag
  alt flag == true
    NodeTools->>NodeTools: traverse parent chain → if any.hidden => exclude node
  else
    NodeTools->>NodeTools: exclude node only if node.hidden === true
  end
Loading
sequenceDiagram
  autonumber
  participant UI as Push UI
  participant API as Tolgee API
  Note over UI,API: Push flow with screenshot/tag updates and refined errors

  UI->>API: import keys (translations) [try]
  alt import success
    UI->>API: add tags to keys [try/catch]
    UI->>API: for each screenshot -> update bigMeta [try/catch per screenshot]
      alt too_many_uploaded_images
        API-->>UI: error "too_many_uploaded_images"
        UI-->>UI: set message -> "Too many uploaded images. Disable update screenshots in settings."
      else other error
        UI-->>UI: set generic push error
      end
    UI-->>UI: increment screenshot progress
  else import failure
    API-->>UI: error (invalid_project_api_key / other)
    UI-->>UI: show specific or generic "Cannot push translations." message
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Files/areas to pay extra attention to:

  • src/main/utils/nodeTools.ts — correctness and performance of ancestor traversal and try/catch handling.
  • src/ui/views/Push/Push.tsx — screenshot counting, per-screenshot error handling for too_many_uploaded_images, and UI state consistency after removing the mutation import.
  • src/main/utils/settingsTools.ts & src/types.ts — serialization/persistence of the new flag across global/document settings.

Possibly related PRs

Suggested reviewers

  • ZuzanaOdstrcilova
  • JanCizmar
  • stepan662

Poem

🐇 I hopped through dark and light with care,

I painted placeholders bright and fair,
I traced the roots where hidden texts hide,
I caught too many images on the ride,
A tiny rabbit nudged the plugin's stride.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning Significant portions of the PR introduce changes unrelated to the provided linked issue #83. Issue #83 specifically addresses dark mode styling for placeholders, icons, and tooltips. However, the changeset includes extensive modifications for hidden layers functionality (nodeTools.ts, settingsTools.ts, types.ts, StringsSection.tsx), screenshot upload error handling (Push.tsx, Pull.tsx), and removal of editor mode gates (ListItem.tsx), none of which are mentioned in the provided issue #83. While the PR description indicates these changes fix issue #84, that issue is not provided for reference. Either provide linked issue #84 to justify the hidden layers and screenshot handling changes, or remove these out-of-scope changes from the PR and create separate pull requests for the additional functionality. Ensure this PR focuses exclusively on addressing the three dark mode visibility issues specified in issue #83.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Linked Issues Check ❓ Inconclusive The provided linked issue #83 specifies three dark mode requirements: input placeholder visibility, help/info icon visibility, and tooltip text visibility. The PR includes some related changes (CSS variable for dark mode text color in styles.css, placeholder styling in StringsEditor.css, and z-index adjustments in InfoTooltip.css), but the scope is limited. The PR description references fixing both #83 and #84, yet only #83 is provided for validation. Without issue #84, it is unclear whether the extensive hidden layers changes (nodeTools.ts, settingsTools.ts, types.ts, StringsSection.tsx) and screenshot handling modifications (Push.tsx, Pull.tsx) meet their corresponding requirements. Provide the full text of linked issue #84 to validate the hidden layers requirements and associated code changes. Additionally, confirm that all three dark mode requirements from issue #83 (placeholder, icon, and tooltip styling) have been fully implemented and applied across the plugin as specified.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "83 fix darkmode colors and hidden layers" accurately describes the primary objectives of the changeset. It concisely identifies both main focus areas—dark mode styling and hidden layers functionality—and directly corresponds to the linked issue. The title is specific, clear, and provides meaningful information that helps reviewers understand the scope of changes at a glance.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67def4e and f95609e.

📒 Files selected for processing (1)
  • src/main/utils/nodeTools.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cypress
🔇 Additional comments (1)
src/main/utils/nodeTools.ts (1)

35-41: Logic inversion fixed; confirm intended gating semantics.

The hidden-layer filtering now correctly excludes hidden nodes. Please confirm that ancestor filtering should only apply when ignoreHiddenLayers is true/undefined, as currently implemented. If users set ignoreHiddenLayers = false but ignoreHiddenLayersIncludingChildren = true, ancestors won’t be checked. Is that the desired UX?


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@eweren eweren changed the title 83 fix darkmode colors 83 fix darkmode colors and hidden layers Oct 18, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/types.ts (1)

117-120: Type addition LGTM; add a brief doc for semantics/defaults.

The new flag fits the model. Consider a short JSDoc describing behavior and its relation to ignoreHiddenLayers (default false; only applied when ignoreHiddenLayers is true). Optionally, group related flags under a nested shape in a future breaking change.

src/main/utils/settingsTools.ts (1)

70-89: Propagates the new flag correctly to document data.

Looks good. If you want a cross-document default, also persist to global settings; if not, keeping it document-scoped (as now) is fine. Minor: consider nullish-coalescing defaults in readers for clarity.

Also applies to: 90-108

src/ui/views/Settings/StringsSection.tsx (1)

121-125: Wiring looks good; consider auto-reset + test id.

  • When turning off “hidden layers”, also clear the child flag to avoid stale config and simplify UX.
  • Add a data-cy on the nested checkbox for E2E coverage.

Example tweaks:

 function handleIgnoreHiddenLayersChange(
   event: TargetedEvent<HTMLInputElement, Event>
 ): void {
   setIgnoreHiddenLayers(event.currentTarget.checked);
-  setTolgeeConfig({
-    ...tolgeeConfig,
-    ignoreHiddenLayers: event.currentTarget.checked,
-  });
+  if (!event.currentTarget.checked) {
+    setIgnoreHiddenLayersIncludingChildren(false);
+  }
+  setTolgeeConfig({
+    ...tolgeeConfig,
+    ignoreHiddenLayers: event.currentTarget.checked,
+    ...(event.currentTarget.checked ? {} : { ignoreHiddenLayersIncludingChildren: false }),
+  });
 }
@@
-            <Checkbox
+            <Checkbox
+              data-cy="settings_checkbox_hidden_layers_include_children"
               value={ignoreHiddenLayersIncludingChildren}
               onChange={handleIgnoreHiddenLayersIncludingChildrenChange}
             >

Also applies to: 185-193, 300-314

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 559498c and 2ea11c7.

📒 Files selected for processing (6)
  • src/main/utils/nodeTools.ts (1 hunks)
  • src/main/utils/settingsTools.ts (2 hunks)
  • src/types.ts (1 hunks)
  • src/ui/views/Pull/Pull.tsx (1 hunks)
  • src/ui/views/Push/Push.tsx (0 hunks)
  • src/ui/views/Settings/StringsSection.tsx (3 hunks)
💤 Files with no reviewable changes (1)
  • src/ui/views/Push/Push.tsx
🔇 Additional comments (1)
src/ui/views/Pull/Pull.tsx (1)

54-60: Error handling is correct and consistent; no code changes needed.

After tracing the error flow: the client (src/ui/client/client.ts, line 114) converts errors to strings before throwing, so Pull.tsx correctly expects string error codes. The error handling across Pull.tsx, Push.tsx, and useAllTranslations.ts is uniform—all treat errors as strings. The "too_many_uploaded_images" error code is properly defined in the API schema and handled appropriately.

Note: Whether the backend actually throws "too_many_uploaded_images" should be confirmed with your API team, but that's outside code review scope.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ea11c7 and 9acf8ea.

📒 Files selected for processing (1)
  • src/ui/views/Push/Push.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cypress
🔇 Additional comments (5)
src/ui/views/Push/Push.tsx (5)

1-436: PR objectives don't match the code changes in this file.

The PR is titled "fix darkmode colors and hidden layers" and the objectives from issue #83 mention fixing input placeholder visibility, help/info icon visibility, and tooltip text visibility in dark mode. The AI summary also mentions "dark-mode primary text CSS" and an "ignoreHiddenLayersIncludingChildren" setting.

However, this file only contains error handling improvements and screenshot count logic changes—no dark mode CSS, no hidden layers functionality, and no changes related to the stated objectives.

Either the dark mode and hidden layers changes are in other files not provided for review, or this PR contains unrelated changes that should be in a separate PR.


255-282: Excellent error handling improvement.

Wrapping the tag operations in a try/catch block allows translations to be pushed successfully even if tagging fails. The error message clearly communicates this partial success to users, which significantly improves the user experience.


286-311: Good error handling with specific error cases.

Wrapping each screenshot update in a try/catch block and providing specific handling for too_many_uploaded_images improves resilience and user feedback. The error messages clearly indicate that translations were still updated successfully.

However, note that the screenshotCount increment at line 300 conflicts with its usage at line 404 (already flagged separately).


317-333: Improved error messages for better user guidance.

The enhanced error handling provides specific, actionable messages for different error scenarios:

  • Clear distinction between API key errors, image upload limits, and import errors
  • Helpful guidance (e.g., "Disable update screenshots in settings")
  • More accurate error message: "Cannot push translations" vs. the previous generic "Cannot get translation data"

These changes significantly improve the user experience during error scenarios.


222-234: Verify that empty translation strings are correctly handled as "NEW" instead of "OVERRIDE".

The conditional on line 230 is actually justified and not redundant. While changedKeys items always have an oldValue object, the extracted oldValue.translation string can be empty ("") or undefined. Empty strings are falsy in JavaScript, so the condition correctly treats them as "NEW" rather than "OVERRIDE".

However, this represents a change in behavior: previously, changed keys may have always used "OVERRIDE", but now empty-to-nonempty translation updates use "NEW". Confirm this aligns with the intended Tolgee API semantics (i.e., whether an empty existing translation should be treated as a non-existent translation when pushing updates).

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/ui/views/Index/ListItem.tsx (1)

126-136: Icon color application works; consider centralizing via a CSS class.

Inline style={{ color: "var(--figma-color-text-secondary)" }} is fine, but a named class (e.g., .secondaryIcon) keeps dark/light token usage consistent across the app and eases future theme tweaks.

-  <InsertLink
-    width={16}
-    height={16}
-    style={{
-      color: "var(--figma-color-text-secondary)",
-    }}
-  />
+  <InsertLink width={16} height={16} className={styles.secondaryIcon} />

And in Index.css (or a shared icon stylesheet):

.secondaryIcon { color: var(--figma-color-text-secondary); }
src/ui/views/Push/Push.tsx (3)

259-286: Nice resilience: tagging wrapped in try/catch with user feedback.

This isolates non-critical tag failures from the main push flow. Consider also logging the original error for diagnostics if not already captured by useApiMutation.

-      } catch (e) {
+      } catch (e) {
+        console.warn("addTagsToKeys failed", e);
         setErrorMessage(
           `Error adding tags. ${e}. Translations were still updated.`
         );

399-409: Checkbox label wired to computed count: LGTM.

Minor UX nit: consider proper pluralization (“1 screenshot” vs “N screenshots”).

-  <Text>Upload {totalScreenshotCount} screenshot(s)</Text>
+  <Text>
+    Upload {totalScreenshotCount} {totalScreenshotCount === 1 ? "screenshot" : "screenshots"}
+  </Text>

47-47: Clarify screenshotCount semantics.

It now tracks processed screenshots (not total). Rename to uploadedScreenshotCount (or updatedScreenshotCount) to avoid confusion with totalScreenshotCount.

-  const [screenshotCount, setScreenshotCount] = useState(0);
+  const [uploadedScreenshotCount, setUploadedScreenshotCount] = useState(0);

And update references accordingly.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9acf8ea and 0aab745.

📒 Files selected for processing (2)
  • src/ui/views/Index/ListItem.tsx (1 hunks)
  • src/ui/views/Push/Push.tsx (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/ui/views/Index/ListItem.tsx (1)
src/ui/icons/SvgIcons.tsx (1)
  • InsertLink (32-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cypress
🔇 Additional comments (3)
src/ui/views/Push/Push.tsx (3)

104-107: Good fix: derive total screenshot count from changes.

Memoizing totalScreenshotCount from changes?.screenshots.length resolves the initial “0 screenshots” label issue and keeps UI reactive.


423-425: Finish/Push gating now correctly respects screenshot-only pushes.

Condition reads clearly and prevents showing “Finish” when screenshots are pending. Nice.


325-333: Error codes confirmed correct.

All three error strings (invalid_project_api_key, too_many_uploaded_images, import_keys_error) are legitimate server response codes defined in the ErrorResponseTyped enum in src/ui/client/apiSchema.generated.ts, confirming they properly align with what useApiMutation throws. Usage is consistent across the codebase (Pull.tsx, Push.tsx, Settings.tsx, useAllTranslations.ts).

@eweren eweren closed this Dec 17, 2025
@eweren
Copy link
Contributor Author

eweren commented Dec 17, 2025

Is included in #86

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.

Bugs - darkmode

1 participant