Files
jetbrains-cc-gui/webview/src/components/ChatInputBox/styles/context-bar.css
T
toxehandClaude f6f4206846 feat(webview): plan-usage indicator component + pace utils
Adds the provider-agnostic plan-usage UI for the chat input ContextBar:

- planUsagePace.ts: pace coloring (TP = usage %, TT = linear time budget
  through the reset window), capacity payload normalization into a
  PlanUsageSnapshot, window resolution/switching (5h/7d) with persisted
  selection, and reset formatting (short bar label without trailing
  period + full tooltip datetime).
- PlanUsageIndicator.tsx: mini bar + % + window chip + short reset +
  worst-window dot; tooltip lists all windows and reset times.
- context-bar.css: .plan-usage* styles (green/yellow/red pace colors).
- Unit tests for the pace utils and the indicator.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-18 07:17:09 -04:00

496 lines
10 KiB
CSS

/* ============================================================
Context Display Bar (Top Control Bar)
============================================================ */
.context-bar {
display: flex;
flex-wrap: nowrap;
align-items: center;
gap: 8px;
padding: 6px 12px;
background: var(--context-bar-bg);
min-height: 32px;
}
/* Ensure the first visible child element (usually ContextBar or AttachmentList) has rounded corners */
/* ResizeHandles are absolutely positioned :first-child, so select the next visible element after them */
.chat-input-box > .resize-handle + * {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
.context-tools {
display: flex;
align-items: center;
gap: 4px;
}
.context-token-indicator {
display: flex;
align-items: center;
justify-content: center;
}
.context-tool-btn {
display: flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 4px;
cursor: pointer;
color: var(--text-secondary);
transition: all 0.2s;
font-size: 14px;
/* Reset button styles */
background: transparent;
border: none;
padding: 0;
margin: 0;
outline: none;
}
.context-tool-btn:hover:not(:disabled) {
background: var(--button-hover);
color: var(--text-primary);
}
.context-tool-btn:disabled {
cursor: not-allowed;
opacity: 0.4;
}
.context-tool-divider {
width: 1px;
height: 16px;
background: var(--input-border);
margin: 0 4px;
}
/* Right side tools container */
.context-tools-right {
display: flex;
align-items: center;
gap: 4px;
margin-left: auto;
}
/* StatusPanel toggle button */
.status-panel-toggle {
position: relative;
transition: all 0.2s ease;
}
.status-panel-toggle .codicon {
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.status-panel-toggle.expanded .codicon {
transform: rotate(0deg);
}
.status-panel-toggle.collapsed .codicon {
transform: rotate(0deg);
}
.status-panel-toggle:hover .codicon {
color: var(--text-primary);
}
.context-item {
display: flex;
align-items: center;
background: var(--dropdown-bg);
border: 1px solid var(--input-border);
border-radius: 4px;
padding: 1px 6px;
font-size: 12px;
color: var(--text-primary);
max-width: 200px;
}
/* Tooltip styles - for ContextBar item (CSS implementation) */
.context-item.has-tooltip {
position: relative;
}
.context-item.has-tooltip:hover::after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
margin-bottom: 4px;
background: var(--dropdown-bg);
color: var(--text-primary);
border: 1px solid var(--dropdown-border);
border-radius: 6px;
padding: 6px 12px;
font-size: 12px;
line-height: 1.4;
white-space: pre-wrap;
word-break: break-all;
max-width: 300px;
width: max-content;
z-index: 1000;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
pointer-events: none;
opacity: 0;
animation: tooltip-fade-in 0.2s forwards;
}
.context-item.has-tooltip:hover::before {
content: '';
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
margin-bottom: -2px;
border: 6px solid transparent;
border-top-color: var(--dropdown-border);
z-index: 1000;
opacity: 0;
animation: tooltip-fade-in 0.2s forwards;
}
/* Tooltip Popup (JS implementation, used to break out of overflow constraints in InputBox) */
.tooltip-popup {
position: fixed;
/* Remove translateY from transform, use margin-top for fine-tuning instead to avoid animation conflicts */
transform: translateX(-50%);
background: var(--dropdown-bg);
color: var(--text-primary);
border: 1px solid var(--dropdown-border);
border-radius: 6px;
padding: 6px 12px;
font-size: 12px;
line-height: 1.4;
white-space: pre-wrap;
word-break: break-all;
max-width: 300px;
width: max-content;
/* Ensure z-index is high enough */
z-index: 99999;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
pointer-events: none;
/* Use CSS variable to control horizontal offset, defaults to -50% (centered) */
--tooltip-tx: -50%;
transform: translate(var(--tooltip-tx), -100%);
}
@keyframes tooltip-fade-in {
from { opacity: 0; transform: translate(var(--tooltip-tx), -80%); }
to { opacity: 1; transform: translate(var(--tooltip-tx), -100%); }
}
.tooltip-bar {
max-width: none;
border-radius: 6px 6px 0 0;
border-bottom: none;
/* Slightly adjust background color to differentiate */
background: var(--dropdown-bg);
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
/* Override transform */
transform: translate(0, -100%);
animation: tooltip-bar-fade-in 0.2s forwards;
}
@keyframes tooltip-bar-fade-in {
from { opacity: 0; transform: translate(0, -90%); }
to { opacity: 1; transform: translate(0, -100%); }
}
.context-text {
margin: 0 4px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
direction: rtl;
text-align: left;
}
.context-close {
cursor: pointer;
opacity: 0.7;
font-size: 14px;
margin-left: 4px;
}
.context-close:hover {
opacity: 1;
color: var(--text-primary);
}
/* ============================================================
File Context Empty Placeholder (dashed rectangle)
============================================================ */
.context-file-placeholder-wrapper {
position: relative;
}
button.context-file-placeholder {
display: flex;
align-items: center;
gap: 4px;
padding: 1px 8px;
border: 1px dashed var(--input-border);
border-radius: 4px;
font-size: 11px;
font-family: inherit;
color: var(--text-secondary);
background: transparent;
cursor: pointer;
transition: all 0.2s;
opacity: 0.7;
outline: none;
}
button.context-file-placeholder:hover {
border-color: var(--text-secondary);
color: var(--text-primary);
opacity: 1;
background: var(--button-hover);
}
button.context-file-placeholder:focus-visible {
border-color: var(--focus-border, #007acc);
opacity: 1;
}
.context-file-placeholder .codicon {
font-size: 12px;
}
.context-file-placeholder .placeholder-text {
white-space: nowrap;
}
/* ============================================================
File Context Enable Confirmation Popover
============================================================ */
.file-context-confirm-popover {
position: absolute;
bottom: calc(100% + 8px);
left: 0;
z-index: 1000;
min-width: 260px;
max-width: 320px;
background: var(--dropdown-bg);
border: 1px solid var(--dropdown-border);
border-radius: 8px;
padding: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
animation: popover-fade-in 0.15s ease-out;
}
.file-context-confirm-popover::before {
content: '';
position: absolute;
top: 100%;
left: 16px;
border: 6px solid transparent;
border-top-color: var(--dropdown-border);
}
.file-context-confirm-popover::after {
content: '';
position: absolute;
top: 100%;
left: 17px;
border: 5px solid transparent;
border-top-color: var(--dropdown-bg);
}
.popover-title {
font-size: 13px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 6px;
}
.popover-description {
font-size: 12px;
line-height: 1.5;
color: var(--text-secondary);
margin-bottom: 12px;
}
.popover-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.popover-btn {
padding: 4px 12px;
border-radius: 4px;
font-size: 12px;
cursor: pointer;
border: 1px solid var(--input-border);
transition: all 0.15s;
}
.popover-btn-cancel {
background: transparent;
color: var(--text-secondary);
}
.popover-btn-cancel:hover {
background: var(--button-hover);
color: var(--text-primary);
}
.popover-btn-confirm {
background: var(--button-primary-bg, #007acc);
color: var(--button-primary-fg, #fff);
border-color: var(--button-primary-bg, #007acc);
}
.popover-btn-confirm:hover {
opacity: 0.9;
}
@keyframes popover-fade-in {
from {
opacity: 0;
transform: translateY(4px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Plan usage indicator (layout D: mini-bar + % + window + short reset) */
.plan-usage {
display: flex;
align-items: center;
gap: 5px;
max-width: 200px;
min-width: 0;
padding: 2px 6px;
border-radius: 4px;
color: var(--text-secondary);
font-size: 11px;
line-height: 1;
flex-shrink: 1;
white-space: nowrap;
overflow: hidden;
}
/* Leading dot = worst pace across all windows (not just selected). */
.plan-usage-worst-dot {
width: 7px;
height: 7px;
border-radius: 50%;
flex-shrink: 0;
background: var(--text-secondary);
opacity: 0.85;
}
.plan-usage-worst-dot.pace-green {
background: #3ba55d;
opacity: 1;
}
.plan-usage-worst-dot.pace-yellow {
background: #d4a017;
opacity: 1;
}
.plan-usage-worst-dot.pace-red {
background: #e34850;
opacity: 1;
}
.plan-usage-worst-dot.pace-neutral {
background: var(--text-secondary);
opacity: 0.5;
}
.plan-usage-bar {
width: 36px;
height: 4px;
border-radius: 2px;
background: var(--input-border);
overflow: hidden;
flex-shrink: 0;
}
.plan-usage-fill {
height: 100%;
border-radius: 2px;
background: var(--text-secondary);
transition: width 0.25s ease, background 0.2s ease;
}
.plan-usage-pct {
font-variant-numeric: tabular-nums;
font-weight: 500;
flex-shrink: 0;
}
.plan-usage-reset {
overflow: hidden;
text-overflow: ellipsis;
color: var(--text-secondary);
opacity: 0.9;
}
/* 5h/7d window switcher */
.plan-usage-window {
flex-shrink: 0;
margin: 0;
padding: 1px 4px;
border: 1px solid var(--input-border);
border-radius: 3px;
background: transparent;
color: var(--text-secondary);
font-size: 10px;
font-weight: 600;
line-height: 1.2;
letter-spacing: 0.02em;
text-transform: lowercase;
cursor: default;
}
.plan-usage-window.switchable {
cursor: pointer;
}
.plan-usage-window.switchable:hover {
background: var(--button-hover);
color: var(--text-primary);
}
.plan-usage-window:disabled {
opacity: 0.85;
}
.plan-usage.pace-green .plan-usage-fill {
background: #3ba55d;
}
.plan-usage.pace-green .plan-usage-pct {
color: #3ba55d;
}
.plan-usage.pace-yellow .plan-usage-fill {
background: #d4a017;
}
.plan-usage.pace-yellow .plan-usage-pct {
color: #d4a017;
}
.plan-usage.pace-red .plan-usage-fill {
background: #e34850;
}
.plan-usage.pace-red .plan-usage-pct {
color: #e34850;
}
.plan-usage.unavailable {
opacity: 0.75;
}
.plan-usage-label {
font-size: 11px;
color: var(--text-secondary);
}