feat: replace per-cell AI button with global floating panel
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.
This commit is contained in:
+57
-15
@@ -4,30 +4,72 @@
|
||||
https://jupyterlab.readthedocs.io/en/stable/developer/css.html
|
||||
*/
|
||||
|
||||
/* Single AI action button inside the native Cell toolbar (active cell, top-right). */
|
||||
.opencode-cell-actions {
|
||||
/* 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;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.opencode-cell-actions .opencode-btn {
|
||||
.opencode-floating-button {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0 6px;
|
||||
font-size: var(--jp-ui-font-size1);
|
||||
line-height: 20px;
|
||||
background: var(--jp-brand-color1, #1976d2);
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
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-cell-actions .opencode-btn:hover:enabled {
|
||||
background: var(--jp-layout-color2);
|
||||
border-radius: 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;
|
||||
}
|
||||
|
||||
.opencode-cell-actions .opencode-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
/* 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. */
|
||||
|
||||
Reference in New Issue
Block a user