Repository navigation
π fix(ui): make click-to-copy work on insecure contexts and fix tooltip feedback (#472) - #481
Conversation
β¦e contexts (#472) - π fix(ui): stop CopyableTag's failed-state color from being clobbered by parent style fallthrough β move the danger color onto an inner span so it survives Vue 3's parent-wins style merge at real call sites (ContainerFullPageTabContent, ContainerSideTabContent, ContainerFullPageOverviewTab, DashboardRecentUpdatesWidget) - π fix(ui): harden useClipboard's execCommand fallback with try/finally so a throw during textarea append/select (e.g. a sandboxed iframe) can't leak the textarea or reject the copy promise instead of resolving false - π fix(ui): give AppLogViewer's Copy button a real failed-copy state (reuses the CopyableTag "Copy failed" tooltip copy) instead of looking identical to idle when the write fails - β test(ui): add a real-mount CopyableTag spec covering the fallthrough regression (verified to fail pre-fix), success path, and execCommand fallback path; extend useClipboard and AppLogViewer specs for the new branches
β¦472) - π the mousedown-hide + show-time-only text read meant state-driven tooltip text (like the copy button's "Copied"/"Copy failed" confirmations) never refreshed without a re-hover; now open tooltips live-update and reposition, and a content change while the pointer is still on the element re-shows immediately. - β test: directive coverage for live-update, post-click re-show, no-resurrection-on-unchanged-text, delay bypass.
π outer v-tooltip bindings on <CopyableTag> fell through to the same root element as the component's own copy-state tooltip, clobbering directive state at 3 sites (containers version cell digest-delta, dashboard recent-updates widget x2); replaced with an idleTooltip prop so one tooltip carries both the informative text and the copy feedback. β test: idleTooltip prop coverage + preserved digest-delta assertions.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: π Files selected for processing (3)
π§ Files skipped from review as they are similar to previous changes (2)
π WalkthroughWalkthroughChangesAdds a legacy Sequence Diagram(s)sequenceDiagram
participant Component
participant useClipboard
participant writeToClipboard
participant NavigatorClipboard
participant execCommandFallback
Component->>useClipboard: copyToClipboard(text, key)
useClipboard->>writeToClipboard: writeToClipboard(text)
writeToClipboard->>NavigatorClipboard: writeText(text)
alt success
NavigatorClipboard-->>writeToClipboard: resolved
else unavailable or rejected
writeToClipboard->>execCommandFallback: execCommand('copy')
execCommandFallback-->>writeToClipboard: boolean success
end
writeToClipboard-->>useClipboard: boolean success
useClipboard->>useClipboard: set copiedKey or failedKey
useClipboard-->>Component: Promise<boolean>
Compact metadata
Related issues
Related PRs
Suggested labels
Suggested reviewers
Poem π₯ Pre-merge checks | β 2β Passed checks (2 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (1)
ui/tests/composables/useClipboard.spec.ts (1)
6-17: π― Functional Correctness | π‘ Minor | β‘ Quick winAwait the reset copy before advancing fake timers.
copyToClipboard('__reset__')is async, sovi.advanceTimersByTime(1500)runs beforescheduleReset()registers the timeout. MakebeforeEachasync andawait copyToClipboard('__reset__')so the shared clipboard state is cleared before each test.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/tests/composables/useClipboard.spec.ts` around lines 6 - 17, The clipboard state reset in beforeEach is racing the fake timers because copyToClipboard('__reset__') is async, so the timeout may not be registered before vi.advanceTimersByTime runs. Make the beforeEach callback async in useClipboard.spec.ts, await the copyToClipboard('__reset__') call from useClipboard() before advancing timers, and then clear writeTextMock so each test starts from a fully reset shared state.
π§Ή Nitpick comments (2)
ui/src/components/containers/ContainersGroupedViews.vue (1)
664-664: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueHardcoded tooltip string bypasses i18n placeholders.
The digest-transition tooltip text is built as a raw JS template literal (
`${c.currentTag} β ${...} β ${...}`) rather than a locale entry with named placeholders (the convention used elsewhere, e.g.dataFilterBar.viewModeLabel). Not blocking since line 675 already does this, but worth aligning eventually for translatability.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/src/components/containers/ContainersGroupedViews.vue` at line 664, The tooltip in CopyableTag for the container version tag is built with a hardcoded template literal instead of using an i18n entry with named placeholders. Update the tooltip construction in ContainersGroupedViews.vue to use the existing tt translation helper with a locale key and placeholder values, following the same pattern used by dataFilterBar.viewModeLabel, while keeping the digest values from c.currentTag, c.currentDigest, and c.newDigest.ui/src/components/CopyableTag.vue (1)
21-26: π Maintainability & Code Quality | π΅ Trivial | π€ Low valueExtract tooltip ternary to a computed.
The nested ternary on line 24 mixes three states (failed/copied/idle) inline in the template. A
computed(e.g.tooltipContent) would be easier to test and read.β»οΈ Proposed refactor
-const { copyToClipboard, isCopied, isFailed } = useClipboard(); +const { copyToClipboard, isCopied, isFailed } = useClipboard(); + +const tooltipContent = computed<BindingValue>(() => { + if (isFailed(props.tag)) return t('sharedComponents.copyableTag.failed'); + if (isCopied(props.tag)) return t('sharedComponents.copyableTag.copied'); + return props.idleTooltip ?? t('sharedComponents.copyableTag.clickToCopy'); +});- v-tooltip.top="isFailed(props.tag) ? t('sharedComponents.copyableTag.failed') : isCopied(props.tag) ? t('sharedComponents.copyableTag.copied') : (props.idleTooltip ?? t('sharedComponents.copyableTag.clickToCopy'))" + v-tooltip.top="tooltipContent"π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/src/components/CopyableTag.vue` around lines 21 - 26, Refactor the nested tooltip ternary in CopyableTag.vue into a computed value named something like tooltipContent so the template stays readable and easier to test. Move the failed/copied/idle selection logic currently embedded in the v-tooltip.top binding into that computed, using the existing isFailed, isCopied, and props.idleTooltip logic, then bind the template to the computed result instead of inline branching.
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui/src/components/AppLogViewer.vue`:
- Around line 396-407: The copy feedback reset logic in AppLogViewerβs clipboard
handler is racing because each click schedules a new timeout without cancelling
the previous one. Update the same block that sets copySuccess and copyFailed to
track the pending reset timer, clear any existing timer before scheduling a new
one, and reuse the timer cleanup pattern already used in useClipboard.tsβs
scheduleReset so rapid same-outcome clicks keep the indicator visible for the
full duration.
---
Outside diff comments:
In `@ui/tests/composables/useClipboard.spec.ts`:
- Around line 6-17: The clipboard state reset in beforeEach is racing the fake
timers because copyToClipboard('__reset__') is async, so the timeout may not be
registered before vi.advanceTimersByTime runs. Make the beforeEach callback
async in useClipboard.spec.ts, await the copyToClipboard('__reset__') call from
useClipboard() before advancing timers, and then clear writeTextMock so each
test starts from a fully reset shared state.
---
Nitpick comments:
In `@ui/src/components/containers/ContainersGroupedViews.vue`:
- Line 664: The tooltip in CopyableTag for the container version tag is built
with a hardcoded template literal instead of using an i18n entry with named
placeholders. Update the tooltip construction in ContainersGroupedViews.vue to
use the existing tt translation helper with a locale key and placeholder values,
following the same pattern used by dataFilterBar.viewModeLabel, while keeping
the digest values from c.currentTag, c.currentDigest, and c.newDigest.
In `@ui/src/components/CopyableTag.vue`:
- Around line 21-26: Refactor the nested tooltip ternary in CopyableTag.vue into
a computed value named something like tooltipContent so the template stays
readable and easier to test. Move the failed/copied/idle selection logic
currently embedded in the v-tooltip.top binding into that computed, using the
existing isFailed, isCopied, and props.idleTooltip logic, then bind the template
to the computed result instead of inline branching.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 75e47d80-aa60-4d16-8f3c-651f70c4688f
β Files ignored due to path filters (1)
CHANGELOG.mdis excluded by!CHANGELOG.md
π Files selected for processing (11)
ui/src/components/AppLogViewer.vueui/src/components/CopyableTag.vueui/src/components/containers/ContainersGroupedViews.vueui/src/composables/useClipboard.tsui/src/directives/tooltip.tsui/src/locales/en/sharedComponents.jsonui/src/views/dashboard/components/DashboardRecentUpdatesWidget.vueui/tests/components/AppLogViewer.spec.tsui/tests/components/CopyableTag.spec.tsui/tests/composables/useClipboard.spec.tsui/tests/directives/tooltip.spec.ts
β¦472) - π fix: track a single copy-feedback reset timer in AppLogViewer's copyLogs, clearing any pending timer before scheduling a new one, so a rapid second copy click no longer lets the first click's timer clear the indicator early - β test: cover the rapid-double-copy case with fake timers in AppLogViewer.spec.ts - β test: await the async clipboard reset before advancing fake timers in useClipboard.spec.ts's beforeEach
|
Fixed the reset-timer race in AppLogViewer and the un-awaited clipboard reset in the spec (05c4e3e). Skipping the i18n nitpick on the digest tooltip: it's the same raw-literal pattern this view already uses (line 675 and friends), and the UI literal sweep is queued with the v1.6 i18n gate work rather than piecemeal here. |
biggest-littlest
left a comment
There was a problem hiding this comment.
LGTM. execCommand fallback is properly guarded with try/finally, tooltip live-update covers the click path, and the double-binding cleanup closes the loop.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Approving β full gate green at 100% coverage, QA'd on an insecure LAN context.
Fixes #472.
Click-to-copy did nothing (and logged a TypeError) on deployments served over plain HTTP, which is the common self-hosted LAN setup, because
navigator.clipboardonly exists in secure contexts. Three commits:useClipboardnow falls back to the legacydocument.execCommand('copy')textarea technique when the Clipboard API is missing or rejects. The log viewer's Copy button goes through the same path, and when no copy mechanism works at all the UI shows an explicit "Copy failed" state instead of failing silently. The temp textarea teardown is wrapped in try/finally with a parentNode guard so a mid-copy DOM error can't leave it behind or skip focus restore.v-tooltipdirectly on<CopyableTag>, which falls through to the same root element as the component's own copy-state tooltip and clobbered its directive state. Those sites now pass their text through a newidleTooltipprop so one tooltip carries both the informative text and the copy feedback. Swept everyCopyableTagusage inui/srcβ no other double bindings.Gate: full UI suite green at 100% coverage, build/typecheck/biome clean, e2e + playwright via pre-push hook. Manually QA'd on a LAN IP (insecure context) to exercise the fallback path.
π Fixed
document.execCommand('copy')so click-to-copy works whennavigator.clipboardis missing or rejects (e.g., insecure/plain HTTP contexts).AppLogViewerβs toolbar copy button use the same copy helper and surface explicit failure UI (βCopy failedβ) when no copy method succeeds.π§ Changed
useClipboard()now tracks both success (isCopied) and failure (isFailed) viacopiedKey/failedKey, andcopyToClipboard()returnsPromise<boolean>.writeToClipboard(text): Promise<boolean>that triesnavigator.clipboard.writeTextfirst, then falls back to theexecCommand('copy')textarea path with hardened cleanup + focus restoration.CopyableTagnow supports an optionalidleTooltipprop to prevent duplicate/staked tooltip bindings and preserve correct copy-state tooltip precedence.CopyableTagcall sites to passidleTooltipfor digest/version displays.sharedComponents.copyableTag.clickToCopyandsharedComponents.copyableTag.failed.β¨ Added
navigator.clipboardand failing/throwingdocument.execCommandCopyableTagidleTooltip precedence and failure styling regression.