Skip to content

Fix self-healing of stale auth token on translate and UI improvements in console-crane#34

Merged
navidshad merged 8 commits into
mainfrom
dev
Jun 8, 2026
Merged

Fix self-healing of stale auth token on translate and UI improvements in console-crane#34
navidshad merged 8 commits into
mainfrom
dev

Conversation

@navidshad

@navidshad navidshad commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

🏷️ PR Title:
Fix self-healing of stale auth token on translate and UI improvements in console-crane

📋 Summary

This PR addresses an issue where translation requests failed due to stale authentication tokens by implementing a self-heal mechanism to refresh the token automatically. Additionally, it includes UI fixes for the console-crane module: aligning the bundle selector height with the Save button and isolating modal styles to prevent CSS leaks from the host page.

🔗 Related Tasks

#33 - Fix self-heal stale auth token on translate to prevent failure
#console-crane-ui-fixes - Align bundle selector height with Save button and isolate modal CSS

📝 Additional Details

  • Release versions 1.14.0-dev.2 and 1.14.1-dev.1 included as part of the deployment cycle.
  • Merged updates from main branch to keep dev branch up to date.

📜 Commit List

6ef3766 fix: self-heal stale auth token on translate instead of failing
cf057a0 fix(console-crane): align bundle selector height with the Save button
2b89736 fix(console-crane): isolate modal from host-page color/flex CSS leaks
c76121e chore(release): 1.14.0-dev.2 [skip ci]
16a6feb chore(release): 1.14.1-dev.1 [skip ci]
b1c5a13 Merge remote-tracking branch 'origin/main' into dev
98472c1 Merge pull request #33 from codebridger/fix/translate-auth-self-heal

navidshad and others added 7 commits June 8, 2026 16:16
studio.youtube.com (a Polymer app) leaks `html{color:#fff}` and
`flex:1 0 1e-9px` into our scoped UI, washing out the modal header icons
and inflating the header <section> so content was pushed down with large
gaps. Pin a per-theme base text color and restore the default
`flex:0 1 auto` on scoped flow elements in tailwind.css; add an e2e
host-style-isolation regression net.

Ref #86exw6kme

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# [1.14.0-dev.2](v1.14.0-dev.1...v1.14.0-dev.2) (2026-06-08)

### Bug Fixes

* **console-crane:** isolate modal from host-page color/flex CSS leaks ([2b89736](2b89736)), closes [#86exw6kme](https://github.com/codebridger/subturtle-extension-apps/issues/86exw6kme)
The pilotui Select renders its visible trigger button at the bottom of a
4-level wrapper chain, two links of which are display:block, so the bundle
selector field rendered a few px shorter than the adjacent lg Save button in
SaveWordSectionV2. Lay the SelectPhraseBundleV2 root out as a flex row and
stretch every link of the chain so the trigger fills the row height and lines
up with Save, in both the plain and freemium (InputGroup) save layouts.

(Also carries an in-progress justify-center tweak + reformatting in the same
component.)

Ref #86exw6kme

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
## [1.14.1-dev.1](v1.14.0...v1.14.1-dev.1) (2026-06-08)

### Bug Fixes

* **console-crane:** align bundle selector height with the Save button ([cf057a0](cf057a0)), closes [#86exw6kme](https://github.com/codebridger/subturtle-extension-apps/issues/86exw6kme)
* **console-crane:** isolate modal from host-page color/flex CSS leaks ([2b89736](2b89736)), closes [#86exw6kme](https://github.com/codebridger/subturtle-extension-apps/issues/86exw6kme)
A purged/invalid token in chrome.storage.sync made every translation
fail with "User not found" (and other token-dependent calls 412) until a
full reload. Requests now detect auth-shaped failures, recover the
session, and retry once.

- isAuthError: detect token failures from the response body (the client
  discards the HTTP status). Patterns are grounded in the actual
  modular-rest server output, including the swallowed "Precondition
  Failed" body for invalid/expired/wrong-signature tokens.
- withAuthRetry: reusable wrapper that recovers + retries once on an auth
  error; wired into TranslateService's three function/run calls.
- recoverSession: tears a dead registered session down system-wide via
  logout() (profile/isLogin/analytics reset + broadcast) then re-auths
  anonymous; anonymous sessions just re-auth (contained).
- single-flight recovery: concurrent failures share ONE loginAnonymous
  instead of each minting and stranding an anonymous user.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix: self-heal stale auth token on translate instead of failing
## [1.14.1-dev.2](v1.14.1-dev.1...v1.14.1-dev.2) (2026-06-08)

### Bug Fixes

* self-heal stale auth token on translate instead of failing ([6ef3766](6ef3766))
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.14.1-dev.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@navidshad navidshad changed the title Dev Fix self-healing of stale auth token on translate and UI improvements in console-crane Jun 8, 2026

@navidshad navidshad left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated PR Review

Primary Task: CU-86exw6kme — Console-crane UI fixes (align bundle selector + isolate modal CSS)
Related tasks from commits: Internal PR #33 / fix: self-heal stale auth token (the auth-recovery work)


Task alignment

Console-crane UI fixes (86exw6kme)

  • fix(console-crane): align bundle selector height with the Save button — flex stretch chain in SelectPhraseBundleV2.vue + scoped CSS handles both plain and freemium (InputGroup) save layouts.
  • fix(console-crane): isolate modal from host-page color/flex CSS leakstailwind.css pins a per-theme base color and resets flex: 0 1 auto on scoped flow elements.
  • ✅ E2E regression net added (tests/e2e/host-style-isolation.spec.ts) that reproduces the studio.youtube.com Polymer conditions.

Auth self-heal (stale token)

  • ✅ New src/common/helper/auth-recovery.tsisAuthError / reauthAnonymously / withAuthRetry / setSessionRecovery all implemented and well-documented.
  • TranslateService wraps all three functionProvider.run calls with withAuthRetry.
  • modular-rest.ts refactors the first-session anonymous fallback to the shared reauthAnonymously primitive, and installs recoverSession as the system-wide recovery strategy (logout + reauth for registered users, contained reauth for anonymous).
  • ✅ Single-flight coalescing (inflightReauth / inflightRecovery) prevents the "thundering herd of loginAnonymous calls" on a burst of concurrent failures.
  • ✅ Tests: tests/auth-recovery.test.ts (new, ~30 cases for isAuthError / reauthAnonymously / withAuthRetry) + recoverSession describe block in tests/auth-anon-flow.test.ts + integration tests in tests/translate.service.test.ts.

Commit messages

All three substantive commits are clean:

  • fix: self-heal stale auth token on translate instead of failing — thorough body explaining the mechanism, the server behavior, and the single-flight design.
  • fix(console-crane): align bundle selector height with the Save button — explains the 4-level pilotui wrapper chain and why flex stretch was needed.
  • fix(console-crane): isolate modal from host-page color/flex CSS leaks — names the specific host (studio.youtube.com), both leak types, and the fix approach.
  • ✅ Three chore(release): ... commits are semantic-release auto-generated. Type and format are correct.

Convention check

.subturtle-scope class present on existing mount roots — unaffected.
✅ New CSS in tailwind.css explicitly carries .subturtle-scope so the PostCSS prefixer's idempotent guard leaves them as-is (CLAUDE.md rule 1).
✅ No rem in new hand-rolled CSS; hardcoded hex colors are used instead of hand-rolled rem (CLAUDE.md rule 2).
✅ No lazy/dynamic imports added (CLAUDE.md bundle convention).
✅ Late-binding via setSessionRecovery correctly avoids a circular import (modular-restauth-recoverymodular-rest). Design rationale documented inline.
✅ Extensive multi-line docstrings in auth-recovery.ts are appropriate per CLAUDE.md's override: "Multi-line comments and docstrings are fine — encouraged, even, where the why is non-obvious."

Minor items (non-blocking):

  1. PR body uses placeholder task IDs. The body lists #33 (a GitHub PR number, not a ClickUp ID) and #console-crane-ui-fixes (invalid). The real ClickUp task 86exw6kme is referenced in the commit messages but not mentioned by name/URL in the PR description. Worth cleaning up the body for traceability.

  2. justify-center on InputGroup is labelled "in-progress" in the commit body. The commit for align bundle selector height notes "Also carries an in-progress justify-center tweak + reformatting in the same component." If this centers the search + Create row in the bundle dropdown header, it's a UI change that doesn't seem obviously incomplete — but calling it "in-progress" in the commit message is ambiguous. Confirm whether this is intentional and finished.

  3. CLAUDE.md test-count comment is now stale. The doc records "138 unit / component tests across 19 files; 16 E2E specs across 6 files". This PR adds tests/auth-recovery.test.ts (new file, ~30+ cases), extends auth-anon-flow.test.ts + translate.service.test.ts, and adds tests/e2e/host-style-isolation.spec.ts (new E2E file). A follow-up CLAUDE.md update would keep the docs accurate.


Verdict

APPROVE

The implementation is solid: the auth self-heal covers the exact failure paths derived from the server source (not guessed), the single-flight recovery prevents session storms, the CSS isolation fixes are well-scoped and low-risk, and the test coverage is thorough across unit, integration, and E2E layers. The three minor items above are documentation-level and do not affect correctness or maintainability.


Generated by Claude Code

@navidshad navidshad removed the review label Jun 8, 2026 — with Claude
@navidshad navidshad merged commit 577ea0a into main Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.14.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants