The per-cell toolbar AI button (OpenCodeCellActions) is removed. A
single round button is mounted on document.body at the bottom-right of
the JupyterLab shell; clicking it opens a floating panel containing
the same OpenCodeInlinePrompt widget. Clicking again closes it.
The panel resolves the active notebook from app.shell.currentWidget
at open time and re-resolves it whenever currentChanged fires while
the panel is open. The active cell (used by the 📋 插入单元格内容,
↪ Insert, and ⟳ Replace cell actions) is resolved via a new
getActiveCell callback in OpenCodeInlinePrompt, decoupling the prompt
itself from any specific CodeCell instance.
Files:
- src/components/opencode_floating_panel.ts (new) — global panel
- src/components/opencode_cell_actions.ts (deleted) — logic moved up
- src/components/opencode_inline_prompt.ts — getActiveCell option
- src/index.ts — wire floating panel, drop toolbar factory
- style/base.css — .opencode-floating-* styles
- src/__tests__/opencode_floating_panel.spec.ts — new tests (renamed)
All existing functionality preserved: multi-session UI, SSE
streaming, permission/question interaction, history reload.
447 lines
12 KiB
CSS
447 lines
12 KiB
CSS
/*
|
|
See the JupyterLab Developer Guide for useful CSS Patterns:
|
|
|
|
https://jupyterlab.readthedocs.io/en/stable/developer/css.html
|
|
*/
|
|
|
|
/* Floating AI launcher (replaces the per-cell toolbar button).
|
|
Mounted on document.body with position: fixed so it sits above the
|
|
JupyterLab layout regardless of which dock is active. The panel
|
|
(when open) renders above the button via column flex. */
|
|
.opencode-floating-root {
|
|
position: fixed;
|
|
bottom: 24px;
|
|
right: 24px;
|
|
z-index: 1000; /* above JupyterLab's main UI (z-index tops out around 100) */
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
gap: 8px;
|
|
}
|
|
|
|
.opencode-floating-button {
|
|
width: 48px;
|
|
height: 48px;
|
|
border-radius: 50%;
|
|
border: none;
|
|
background: var(--jp-brand-color1, #1976d2);
|
|
color: white;
|
|
font-size: 20px;
|
|
cursor: pointer;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
|
padding: 0;
|
|
line-height: 1;
|
|
}
|
|
.opencode-floating-button:hover {
|
|
transform: scale(1.05);
|
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
|
|
}
|
|
.opencode-floating-button:focus {
|
|
outline: 2px solid var(--jp-brand-color2, #42a5f5);
|
|
outline-offset: 2px;
|
|
}
|
|
|
|
.opencode-floating-panel {
|
|
width: 480px;
|
|
max-width: calc(100vw - 48px);
|
|
max-height: 60vh;
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--jp-layout-color1, #fff);
|
|
border: 1px solid var(--jp-border-color2, #ddd);
|
|
border-radius: 6px;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
|
|
}
|
|
.opencode-floating-panel[hidden] {
|
|
display: none;
|
|
}
|
|
|
|
/* The inline prompt inside the floating panel should fill it: drop
|
|
the standalone panel's own margin/border, and let the panel's
|
|
scrollable region take over. */
|
|
.opencode-floating-panel .opencode-inline-prompt {
|
|
margin: 0;
|
|
border: none;
|
|
border-radius: 0;
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
}
|
|
.opencode-floating-panel .opencode-inline-history {
|
|
max-height: 40vh;
|
|
}
|
|
|
|
/* Inline prompt panel attached to the cell when the AI button is clicked. */
|
|
.opencode-inline-prompt {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
padding: 6px;
|
|
margin: 4px 8px;
|
|
border: 1px solid var(--jp-border-color2, #ddd);
|
|
border-radius: 4px;
|
|
background: var(--jp-layout-color1, #fff);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-prompt-providers {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-prompt-providers label {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: var(--jp-ui-font-size1);
|
|
color: var(--jp-ui-font-color1, #333);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-provider-select,
|
|
.opencode-inline-prompt .opencode-model-select {
|
|
flex: 1;
|
|
min-width: 120px;
|
|
padding: 2px 4px;
|
|
font-size: var(--jp-ui-font-size1);
|
|
font-family: inherit;
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
border-radius: 3px;
|
|
background: var(--jp-layout-color1, #fff);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-provider-select:disabled,
|
|
.opencode-inline-prompt .opencode-model-select:disabled {
|
|
opacity: 0.5;
|
|
cursor: default;
|
|
}
|
|
|
|
/* Scrollable history of the current session's messages. The owning
|
|
cell action populates it via setMessages(). max-height keeps the
|
|
inline prompt compact; the user scrolls to see older messages. */
|
|
.opencode-inline-prompt .opencode-inline-history {
|
|
max-height: 320px;
|
|
overflow-y: auto;
|
|
margin: 4px 0;
|
|
padding: 4px 6px;
|
|
border: 1px solid var(--jp-border-color1, #c0c0c0);
|
|
border-radius: 3px;
|
|
background: var(--jp-layout-color2, #f7f7f7);
|
|
font-size: var(--jp-ui-font-size1);
|
|
line-height: 1.45;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg {
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg-user {
|
|
white-space: pre-wrap;
|
|
padding: 4px 6px;
|
|
border-radius: 3px;
|
|
background: var(--jp-layout-color3, #eaeaea);
|
|
color: var(--jp-ui-font-color1, #333);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg-assistant {
|
|
padding: 4px 6px;
|
|
color: var(--jp-ui-font-color0, #000);
|
|
}
|
|
|
|
/* Per-code-block toolbar: wraps every rendered <pre> so the Copy /
|
|
Insert / Replace buttons live INSIDE the fenced section (not as a
|
|
message-level header). */
|
|
.opencode-inline-prompt .opencode-code-block {
|
|
margin: 6px 0;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-code-toolbar {
|
|
display: flex;
|
|
gap: 4px;
|
|
padding: 2px 6px;
|
|
background: var(--jp-layout-color2, #f0f0f0);
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
border-bottom: none;
|
|
border-top-left-radius: 3px;
|
|
border-top-right-radius: 3px;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
align-items: center;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-code-btn {
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
background: var(--jp-layout-color1, #fff);
|
|
padding: 0 6px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
line-height: 1.4;
|
|
color: var(--jp-ui-font-color1, #333);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-code-btn:hover {
|
|
background: var(--jp-layout-color2, #f7f7f7);
|
|
border-color: var(--jp-border-color1, #999);
|
|
}
|
|
|
|
/* The wrapped <pre> connects visually to the toolbar above (no top
|
|
border/radius, no top margin) so the block reads as one unit. */
|
|
.opencode-inline-prompt .opencode-code-block > pre {
|
|
margin-top: 0;
|
|
border-top-left-radius: 0;
|
|
border-top-right-radius: 0;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-history pre {
|
|
background: var(--jp-layout-color1, #fff);
|
|
padding: 6px 8px;
|
|
border-radius: 3px;
|
|
overflow-x: auto;
|
|
margin: 4px 0;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-history code {
|
|
font-family: var(--jp-code-font-family, monospace);
|
|
font-size: var(--jp-code-font-size, 13px);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-history p {
|
|
margin: 2px 0;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-history h1,
|
|
.opencode-inline-prompt .opencode-inline-history h2,
|
|
.opencode-inline-prompt .opencode-inline-history h3 {
|
|
margin: 6px 0 4px;
|
|
font-size: var(--jp-ui-font-size2, 14px);
|
|
}
|
|
|
|
.opencode-inline-prompt textarea {
|
|
width: 100%;
|
|
resize: vertical;
|
|
font-family: var(--jp-code-font-family, monospace);
|
|
font-size: var(--jp-code-font-size, 13px);
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-actions {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 4px;
|
|
align-items: center;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-actions button {
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
background: var(--jp-layout-color2, #f7f7f7);
|
|
padding: 2px 8px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
font-size: var(--jp-ui-font-size1);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-actions button:hover:enabled {
|
|
background: var(--jp-layout-color3, #eaeaea);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-inline-actions button:disabled {
|
|
opacity: 0.4;
|
|
cursor: default;
|
|
}
|
|
|
|
/* The "📋 插入单元格内容" button: left-aligned, visually distinct from
|
|
send/cancel so the user can tell at a glance it's a "modifier"
|
|
rather than a "submit/cancel" action. */
|
|
.opencode-inline-prompt .opencode-btn-insert-cell {
|
|
margin-right: auto; /* push to the left; send/cancel stay on the right */
|
|
background: #dbeafe;
|
|
color: #1e40af;
|
|
border-color: #93c5fd;
|
|
}
|
|
.opencode-inline-prompt .opencode-btn-insert-cell:hover:enabled {
|
|
background: #bfdbfe;
|
|
}
|
|
|
|
/* ------------------------------------------------------------------
|
|
Streaming event blocks (v4+ — see opencode_inline_prompt.applyEvent)
|
|
------------------------------------------------------------------ */
|
|
|
|
/* System / status line rendered for server.*, workspace.*, lsp.*, etc. */
|
|
.opencode-inline-prompt .opencode-msg-system {
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
color: var(--jp-ui-font-color2, #888);
|
|
padding: 2px 4px;
|
|
font-family: var(--jp-code-font-family, monospace);
|
|
white-space: pre-wrap;
|
|
word-break: break-all;
|
|
}
|
|
|
|
/* Base collapsible block used for reasoning / tool / permission / question. */
|
|
.opencode-inline-prompt .opencode-msg-block {
|
|
margin: 4px 0;
|
|
border: 1px solid var(--jp-border-color2, #ddd);
|
|
border-radius: 3px;
|
|
background: var(--jp-layout-color1, #fafafa);
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg-block > summary {
|
|
padding: 2px 6px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
background: var(--jp-layout-color2, #f1f5f9);
|
|
color: var(--jp-ui-font-color2, #64748b);
|
|
user-select: none;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
}
|
|
|
|
.opencode-inline-prompt .opencode-msg-block-content {
|
|
padding: 4px 8px;
|
|
font-family: var(--jp-code-font-family, monospace);
|
|
white-space: pre-wrap;
|
|
word-break: break-all;
|
|
color: var(--jp-ui-font-color1, #334155);
|
|
max-height: 240px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* Reasoning: green tint (matches demo.html). */
|
|
.opencode-inline-prompt .opencode-msg-block-reasoning > summary {
|
|
background: #f0fdf4;
|
|
color: #15803d;
|
|
}
|
|
|
|
/* Tool call: yellow tint. */
|
|
.opencode-inline-prompt .opencode-msg-block-tool > summary {
|
|
background: #fef3c7;
|
|
color: #b45309;
|
|
}
|
|
|
|
/* Permission / question: pink tint. */
|
|
.opencode-inline-prompt .opencode-msg-block-interaction > summary {
|
|
background: #fce7f3;
|
|
color: #be185d;
|
|
}
|
|
|
|
/* Permission block: description + 3 buttons. */
|
|
.opencode-inline-prompt .opencode-perm-desc {
|
|
margin-bottom: 6px;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
color: var(--jp-ui-font-color1, #334155);
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-buttons {
|
|
display: flex;
|
|
gap: 6px;
|
|
flex-wrap: wrap;
|
|
margin-top: 4px;
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-btn-allow,
|
|
.opencode-inline-prompt .opencode-perm-btn-reject {
|
|
border: none;
|
|
padding: 4px 10px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
color: white;
|
|
font-weight: 500;
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-btn-allow {
|
|
background: #10b981;
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-btn-allow:hover {
|
|
background: #059669;
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-btn-reject {
|
|
background: #ef4444;
|
|
}
|
|
.opencode-inline-prompt .opencode-perm-btn-reject:hover {
|
|
background: #dc2626;
|
|
}
|
|
|
|
/* Question block: text + input + submit. */
|
|
.opencode-inline-prompt .opencode-q-desc {
|
|
margin-bottom: 6px;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
color: var(--jp-ui-font-color1, #334155);
|
|
}
|
|
.opencode-inline-prompt .opencode-q-input-row {
|
|
display: flex;
|
|
gap: 6px;
|
|
margin-top: 4px;
|
|
}
|
|
.opencode-inline-prompt .opencode-q-input {
|
|
flex: 1;
|
|
padding: 3px 6px;
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
border-radius: 3px;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
font-family: inherit;
|
|
background: var(--jp-layout-color1, #fff);
|
|
}
|
|
.opencode-inline-prompt .opencode-q-submit {
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
background: var(--jp-layout-color2, #f0f0f0);
|
|
padding: 3px 10px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
}
|
|
.opencode-inline-prompt .opencode-q-submit:hover {
|
|
background: var(--jp-layout-color3, #e0e0e0);
|
|
}
|
|
|
|
/* ------------------------------------------------------------------
|
|
Session selector (multi-session UI) — top of the inline prompt
|
|
------------------------------------------------------------------ */
|
|
.opencode-inline-prompt .opencode-prompt-sessions {
|
|
display: flex;
|
|
gap: 6px;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
margin: 2px 0 4px;
|
|
}
|
|
.opencode-inline-prompt .opencode-prompt-sessions label {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: var(--jp-ui-font-size1);
|
|
color: var(--jp-ui-font-color1, #333);
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
.opencode-inline-prompt .opencode-session-select {
|
|
flex: 1;
|
|
min-width: 0;
|
|
padding: 2px 4px;
|
|
font-size: var(--jp-ui-font-size1);
|
|
font-family: inherit;
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
border-radius: 3px;
|
|
background: var(--jp-layout-color1, #fff);
|
|
}
|
|
.opencode-inline-prompt .opencode-session-btn-new,
|
|
.opencode-inline-prompt .opencode-session-btn-refresh {
|
|
border: 1px solid var(--jp-border-color2, #ccc);
|
|
background: var(--jp-layout-color2, #f0f0f0);
|
|
padding: 2px 8px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
font-size: var(--jp-ui-font-size0, 11px);
|
|
color: var(--jp-ui-font-color1, #333);
|
|
}
|
|
.opencode-inline-prompt .opencode-session-btn-new:hover,
|
|
.opencode-inline-prompt .opencode-session-btn-refresh:hover {
|
|
background: var(--jp-layout-color3, #e0e0e0);
|
|
}
|
|
.opencode-inline-prompt .opencode-session-btn-new {
|
|
background: #dbeafe;
|
|
color: #1e40af;
|
|
border-color: #93c5fd;
|
|
}
|