@vibe-x/dsh-html-workbench 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/client.js CHANGED
@@ -8,10 +8,17 @@
8
8
  *
9
9
  * Responsibilities (runs in the browser):
10
10
  * - Register a right-side panel + corner trigger in `shell.overlay`.
11
- * - Preview takes the full panel height; the HTML-asset picker is a compact,
12
- * collapsible dock at the bottom (a <select> switcher + expandable list).
11
+ * - Layout is browser-like: a two-row chrome at the TOP (identity row +
12
+ * address/toolbar row) and the preview filling everything below. Nothing
13
+ * sits at the bottom, so the panel never visually competes with the chat
14
+ * composer on the left.
13
15
  * - Open a file by calling Host `open`, then embed the workbench URL in an
14
- * iframe. Left edge is draggable to resize the panel width.
16
+ * iframe. Left edge is draggable to resize the panel width (persisted).
17
+ *
18
+ * Styling contract: every colour/shadow comes from the host's `--dsw-alias-*`
19
+ * design tokens (see the DSH first-party plugins) so light/dark themes and
20
+ * future re-skins are inherited for free. No hard-coded palette, no magic
21
+ * offsets — all overlays are laid out with flex/grid.
15
22
  */
16
23
 
17
24
  return {
@@ -20,66 +27,270 @@ return {
20
27
  const slots = ctx.get('slots')
21
28
  if (slots === undefined) return
22
29
 
23
- styles.insert(`
24
- html #root { margin-right: var(--hwb-panel-width, 0px); transition: margin-right var(--ds-transition-duration-slow, 200ms) ease; }
30
+ // ── Styles ───────────────────────────────────────────────────────────────
31
+ // NOTE: both style shims (dynamic runner + static bundle) de-duplicate by a
32
+ // fixed element id and BAIL OUT when it already exists. During iterative
33
+ // development that silently keeps a STALE stylesheet alive — the symptom is
34
+ // "functionality works but the layout is broken" (e.g. an absolutely
35
+ // positioned chevron collapsing into a block below the input). So manage the
36
+ // <style> element here: drop every previous generation, then insert fresh.
37
+ const STYLE_MARK = 'data-hwb-styles'
38
+ const STYLE_VERSION = '5'
39
+
40
+ const CSS = `
41
+ html #root {
42
+ margin-right: calc(var(--dsh-sidebar-width, 0px) + var(--hwb-panel-width, 0px));
43
+ transition: margin-right var(--ds-transition-duration-slow, 200ms) var(--ds-ease-in-out, ease);
44
+ }
25
45
  body[data-hwb-dragging] #root { transition: none; }
26
- body[data-hwb-dragging] { user-select: none; }
46
+ body[data-hwb-dragging] { user-select: none; cursor: col-resize; }
47
+
48
+ /* Reserve right-side clearance in the session header so the corner trigger
49
+ never overlaps its right-aligned utilities (e.g. "Session log"). The
50
+ clearance relaxes as the panel opens, because the trigger then hides. */
51
+ header:has([data-slot="conversation.session.header.utilities"]) {
52
+ padding-right: max(28px, calc(60px - var(--hwb-panel-width, 0px)));
53
+ transition: padding-right var(--ds-transition-duration-slow, 200ms) var(--ds-ease-in-out, ease);
54
+ }
55
+
27
56
  .hwb-panel, .hwb-panel * { box-sizing: border-box; }
28
- .hwb-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 820px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); border-left: 1px solid var(--dsw-alias-border-l1); box-shadow: var(--dsw-shadow-lv2); z-index: 9999; font-family: var(--dsw-font-family, system-ui, sans-serif); font-size: 13px; line-height: 1.5; pointer-events: auto; }
29
- .hwb-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 9px; cursor: col-resize; z-index: 3; touch-action: none; }
30
- .hwb-resize::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
31
- .hwb-resize:hover::after, .hwb-resize:active::after { background: var(--dsw-alias-interactive-bg-hover-accent); }
32
- .hwb-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-1); flex: none; }
33
- .hwb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dsw-alias-state-error-primary); flex: none; }
34
- .hwb-dot.on { background: var(--dsw-alias-state-success-primary); }
35
- .hwb-titlewrap { min-width: 0; display: flex; flex-direction: column; }
36
- .hwb-title { font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; }
37
- .hwb-sub { font-size: 11px; color: var(--dsw-alias-label-tertiary); line-height: 1.2; }
38
- .hwb-spacer { flex: 1; }
39
- .hwb-close { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: none; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; border-radius: 6px; flex: none; }
40
- .hwb-close:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
41
- .hwb-preview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: #fff; }
42
- .hwb-frame { flex: 1; border: 0; width: 100%; }
43
- .hwb-hint { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--dsw-alias-label-tertiary); text-align: center; padding: 16px; }
44
- .hwb-error { padding: 10px 14px; color: var(--dsw-alias-state-error-primary); font-size: 12px; }
45
- .hwb-dock { flex: none; border-top: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-1); display: flex; flex-direction: column; }
46
- .hwb-dockbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }
47
- .hwb-select { flex: 1; min-width: 0; height: 28px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; padding: 0 8px; cursor: pointer; }
48
- .hwb-count { font-size: 11px; color: var(--dsw-alias-label-tertiary); flex: none; white-space: nowrap; }
49
- .hwb-docktoggle { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: none; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; border-radius: 6px; flex: none; }
50
- .hwb-docktoggle:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
51
- .hwb-docklist { flex: none; max-height: 38vh; overflow-y: auto; border-top: 1px solid var(--dsw-alias-border-l2); }
52
- .hwb-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--dsw-alias-border-l2); cursor: pointer; }
53
- .hwb-item:hover { background: var(--dsw-alias-interactive-bg-hover); }
54
- .hwb-item.active { background: var(--dsw-alias-interactive-bg-active); }
55
- .hwb-item-main { flex: 1; min-width: 0; }
56
- .hwb-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
57
- .hwb-item-path { font-size: 11px; color: var(--dsw-alias-label-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
58
- .hwb-item-btn { border: 1px solid var(--dsw-alias-border-l2); background: transparent; color: var(--dsw-alias-label-secondary); border-radius: 6px; padding: 2px 9px; cursor: pointer; font-size: 12px; flex: none; }
59
- .hwb-item-btn:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
60
- .hwb-dockempty { padding: 14px; color: var(--dsw-alias-label-tertiary); text-align: center; font-size: 12px; }
61
- /* Keep the trigger below the DSH session header's title row (~44px tall: 12px
62
- padding + 32px min-height) so it never covers the right-aligned header
63
- utilities — e.g. the "Session Log" button — when a session is open. */
64
- .hwb-trigger { position: fixed; top: 56px; right: 12px; z-index: 10000; width: 36px; height: 36px; border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; pointer-events: auto; }
65
- .hwb-trigger:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
66
- `)
57
+ .hwb-panel {
58
+ position: fixed; top: 0; right: var(--dsh-sidebar-width, 0px); bottom: 0;
59
+ display: flex; flex-direction: column; min-width: 0;
60
+ background: var(--dsw-alias-bg-base);
61
+ color: var(--dsw-alias-label-primary);
62
+ border-left: 1px solid var(--dsw-alias-border-l1);
63
+ box-shadow: var(--dsw-shadow-lv2);
64
+ z-index: 9999; pointer-events: auto;
65
+ font-family: var(--dsw-font-family, ui-sans-serif, system-ui, sans-serif);
66
+ font-size: 13px; line-height: 1.5;
67
+ --hwb-mono: var(--dsh-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
68
+ }
69
+
70
+ /* Resize handle — a wide invisible hit area with a thin visible rail. */
71
+ .hwb-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 9px; z-index: 5; cursor: col-resize; touch-action: none; border: none; padding: 0; background: transparent; }
72
+ .hwb-resize::after { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: transparent; transition: background 150ms ease; }
73
+ .hwb-resize:hover::after, .hwb-resize:focus-visible::after, .hwb-resize[data-active]::after { background: var(--dsw-alias-interactive-bg-hover-accent); }
74
+ .hwb-resize:focus-visible { outline: none; }
75
+
76
+ /* ── Chrome: identity row + toolbar row ───────────────────────────────────── */
77
+ .hwb-chrome { flex: none; display: flex; flex-direction: column; background: var(--dsw-alias-bg-layer-1); border-bottom: 1px solid var(--dsw-alias-border-l2); }
78
+ .hwb-idrow { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px 0 14px; }
79
+ .hwb-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
80
+ .hwb-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dsw-alias-label-dimmed, var(--dsw-alias-label-tertiary)); box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); }
81
+ .hwb-dot[data-on] { background: var(--dsw-alias-state-success-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-success-primary) 16%, transparent); }
82
+ .hwb-dot[data-off] { background: var(--dsw-alias-state-error-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-error-primary) 16%, transparent); }
83
+ /* The dot is the ONLY signal that a start failed, so make it the way in: it is a
84
+ button that opens the diagnostics log. */
85
+ .hwb-statusbtn { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 2px 6px 2px 4px; margin-left: -4px; border: 0; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
86
+ .hwb-statusbtn:hover { background: var(--dsw-alias-interactive-bg-hover); }
87
+ .hwb-statusbtn:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe); outline-offset: 1px; }
88
+
89
+ /* ── Diagnostics ──────────────────────────────────────────────────────────── */
90
+ .hwb-diag { flex: none; display: flex; flex-direction: column; max-height: 46vh; border-bottom: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-1); }
91
+ .hwb-diag-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--dsw-alias-border-l2); }
92
+ .hwb-diag-title { font-size: 12px; font-weight: 600; }
93
+ .hwb-diag-facts { flex: none; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 14px; border-bottom: 1px solid var(--dsw-alias-border-l2); font-size: 11.5px; }
94
+ .hwb-diag-key { color: var(--dsw-alias-label-tertiary); white-space: nowrap; }
95
+ .hwb-diag-val { min-width: 0; font-family: var(--hwb-mono); word-break: break-all; }
96
+ .hwb-diag-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 0; }
97
+ .hwb-diag-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 4px 14px; font-size: 11.5px; line-height: 1.55; }
98
+ .hwb-diag-row + .hwb-diag-row { border-top: 1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 50%, transparent); }
99
+ .hwb-diag-time { color: var(--dsw-alias-label-tertiary); font-family: var(--hwb-mono); font-size: 10.5px; padding-top: 1px; }
100
+ .hwb-diag-msg { min-width: 0; }
101
+ .hwb-diag-row[data-level="error"] .hwb-diag-msg { color: var(--dsw-alias-state-error-primary); }
102
+ .hwb-diag-detail { display: block; margin-top: 3px; padding: 6px 8px; border-radius: 6px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-secondary); font-family: var(--hwb-mono); font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto; }
103
+ .hwb-diag-empty { padding: 16px 14px; color: var(--dsw-alias-label-tertiary); font-size: 11.5px; }
104
+ .hwb-diag-hint { padding: 8px 14px; border-top: 1px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 1.6; }
105
+ .hwb-diag-hint code { padding: 1px 4px; border-radius: 4px; background: var(--dsw-alias-bg-base); font-family: var(--hwb-mono); font-size: 10.5px; }
106
+ .hwb-btn-quiet { background: transparent; border-color: var(--dsw-alias-border-l2); color: var(--dsw-alias-label-primary); }
107
+ .hwb-btn-quiet:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
108
+ .hwb-btn-sm { height: 26px; padding: 0 10px; border-radius: 7px; font-size: 11.5px; }
109
+ .hwb-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
110
+ .hwb-sep { width: 1px; height: 14px; flex: none; background: var(--dsw-alias-border-l1); }
111
+ .hwb-filechip { display: flex; align-items: center; gap: 6px; min-width: 0; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--dsw-alias-bg-layer-2, var(--dsw-alias-interactive-bg-hover)); color: var(--dsw-alias-label-secondary); font-size: 11.5px; }
112
+ .hwb-filechip > svg { flex: none; opacity: .7; }
113
+ .hwb-filechip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--hwb-mono); }
114
+ .hwb-spacer { flex: 1 1 auto; min-width: 8px; }
115
+ .hwb-actions { display: flex; align-items: center; gap: 2px; flex: none; }
116
+
117
+ .hwb-icon { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; flex: none; border: none; border-radius: 7px; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; transition: background 120ms ease, color 120ms ease; }
118
+ .hwb-icon:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
119
+ .hwb-icon:disabled { opacity: .4; cursor: default; }
120
+ .hwb-icon:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe); outline-offset: 1px; }
121
+ .hwb-icon[data-spin] > svg { animation: hwb-spin 800ms linear infinite; }
122
+
123
+ .hwb-toolbar { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px; }
124
+
125
+ /* Combobox field: input + status + chevron composed with flex — no absolute
126
+ positioning, so nothing can escape the field box. */
127
+ .hwb-fieldwrap { position: relative; flex: 1 1 auto; min-width: 0; }
128
+ .hwb-field { display: flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 9px; background: var(--dsw-alias-bg-base); transition: border-color 150ms ease, box-shadow 150ms ease; }
129
+ .hwb-field:hover { border-color: var(--dsw-alias-border-l1); }
130
+ .hwb-field[data-focus] { border-color: var(--dsw-alias-state-business-primary, #4d6bfe); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-business-primary, #4d6bfe) 16%, transparent); }
131
+ .hwb-input { flex: 1 1 auto; min-width: 0; height: 100%; border: none; outline: none; background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 12.5px; font-family: var(--hwb-mono); }
132
+ .hwb-input::placeholder { color: var(--dsw-alias-label-tertiary); font-family: var(--dsw-font-family, ui-sans-serif, system-ui, sans-serif); }
133
+ .hwb-state { display: grid; place-items: center; width: 20px; height: 20px; flex: none; }
134
+ .hwb-state[data-state="exists"] { color: var(--dsw-alias-state-success-primary); }
135
+ .hwb-state[data-state="missing"] { color: var(--dsw-alias-state-error-primary); }
136
+ .hwb-state[data-state="invalid"] { color: var(--dsw-alias-state-warning-primary, var(--dsw-alias-state-warn-label)); }
137
+ .hwb-state[data-state="checking"] { color: var(--dsw-alias-label-tertiary); }
138
+ .hwb-state[data-state="checking"] > svg { animation: hwb-spin 800ms linear infinite; }
139
+ .hwb-caret { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border: none; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); cursor: pointer; transition: background 120ms ease, color 120ms ease; }
140
+ .hwb-caret:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
141
+ .hwb-caret > svg { transition: transform 180ms ease; }
142
+ .hwb-caret[aria-expanded="true"] > svg { transform: rotate(180deg); }
143
+
144
+ .hwb-btn { flex: none; height: 32px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background 120ms ease, opacity 120ms ease; }
145
+ .hwb-btn-primary { background: var(--dsw-alias-button-primary-fill, #4d6bfe); color: var(--dsw-alias-button-primary-label, #fff); }
146
+ .hwb-btn-primary:hover:not(:disabled) { opacity: .88; }
147
+ .hwb-btn:disabled { opacity: .45; cursor: default; }
148
+ .hwb-btn:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe); outline-offset: 2px; }
149
+
150
+ /* Dropdown opens DOWNWARD (the field lives at the top of the panel). */
151
+ .hwb-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; display: flex; flex-direction: column; max-height: min(340px, 50vh); overflow: hidden; border: 1px solid var(--dsw-alias-border-l1); border-radius: 12px; background: var(--dsw-alias-bg-layer-1); box-shadow: var(--dsw-shadow-lv2); animation: hwb-pop 140ms var(--ds-ease-in-out, ease); }
152
+ .hwb-menu-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-tertiary); font-size: 11px; }
153
+ .hwb-menu-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px; }
154
+ .hwb-menu-empty { padding: 22px 16px; color: var(--dsw-alias-label-tertiary); text-align: center; font-size: 12px; line-height: 1.7; }
155
+
156
+ .hwb-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: none; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
157
+ .hwb-item:hover, .hwb-item:focus-visible { background: var(--dsw-alias-interactive-bg-hover); outline: none; }
158
+ .hwb-item[data-active] { background: var(--dsw-alias-interactive-bg-active, var(--dsw-alias-interactive-bg-hover)); }
159
+ .hwb-item > svg { flex: none; color: var(--dsw-alias-label-tertiary); }
160
+ .hwb-item-main { flex: 1 1 auto; min-width: 0; display: block; }
161
+ .hwb-item-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
162
+ .hwb-item-path { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); font-size: 11px; font-family: var(--hwb-mono); }
163
+ .hwb-tag { flex: none; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 600; }
164
+ .hwb-tag[data-kind="create"] { background: var(--dsw-alias-state-success-tertiary, color-mix(in srgb, var(--dsw-alias-state-success-primary) 14%, transparent)); color: var(--dsw-alias-state-success-primary); }
165
+ .hwb-tag[data-kind="edit"] { background: var(--dsw-alias-state-warn-tertiary, color-mix(in srgb, var(--dsw-alias-state-warning-primary, #b7791f) 14%, transparent)); color: var(--dsw-alias-state-warn-label, var(--dsw-alias-state-warning-primary, #b7791f)); }
166
+
167
+ /* ── Banner ───────────────────────────────────────────────────────────────── */
168
+ .hwb-banner { flex: none; display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px 9px 14px; border-bottom: 1px solid var(--dsw-alias-border-l2); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent); color: var(--dsw-alias-state-error-primary); font-size: 12px; }
169
+ .hwb-banner > svg { flex: none; margin-top: 1px; }
170
+ .hwb-banner-text { flex: 1 1 auto; min-width: 0; word-break: break-word; }
171
+
172
+ /* ── Body ─────────────────────────────────────────────────────────────────── */
173
+ .hwb-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--dsw-alias-bg-base); }
174
+ .hwb-frame { flex: 1 1 auto; width: 100%; border: 0; background: #fff; }
67
175
 
176
+ /* ── Visual selection chips (rendered INTO the host composer) ─────────────── */
177
+ /* The workbench posts one selection at a time; each becomes a removable chip
178
+ above the chat input, mirroring how file attachments behave. The markdown
179
+ evidence is held in memory and only spliced into the message on send, so the
180
+ user never has to look at a wall of HTML while typing. */
181
+ .hwb-chips {
182
+ display: flex; flex-wrap: wrap; gap: 6px;
183
+ margin: 0 14px 8px; padding: 0;
184
+ }
185
+ .hwb-chip {
186
+ display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
187
+ padding: 3px 4px 3px 8px; border-radius: 8px;
188
+ border: 1px solid var(--dsw-alias-border-l2);
189
+ background: var(--dsw-alias-bg-layer-1);
190
+ color: var(--dsw-alias-label-primary);
191
+ font-size: 11.5px; line-height: 18px;
192
+ }
193
+ .hwb-chip > svg { flex: none; color: var(--dsw-alias-state-business-primary, #4d6bfe); }
194
+ .hwb-chip-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--hwb-mono); }
195
+ .hwb-chip-x {
196
+ flex: none; display: grid; place-items: center; width: 18px; height: 18px; padding: 0;
197
+ border: 0; border-radius: 5px; background: transparent;
198
+ color: var(--dsw-alias-label-tertiary); cursor: pointer;
199
+ }
200
+ .hwb-chip-x:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
201
+ .hwb-chip-note { align-self: center; color: var(--dsw-alias-label-tertiary); font-size: 11px; }
202
+
203
+ .hwb-center { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; overflow-y: auto; text-align: center; }
204
+ .hwb-blank { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-tertiary); }
205
+ .hwb-blank-title { font-size: 13.5px; font-weight: 600; color: var(--dsw-alias-label-primary); }
206
+ .hwb-blank-desc { max-width: 320px; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 1.7; }
207
+ .hwb-recent { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 4px; margin-top: 2px; text-align: left; }
208
+ .hwb-recent-label { padding: 0 8px 2px; color: var(--dsw-alias-label-tertiary); font-size: 11px; }
209
+ .hwb-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--dsw-alias-border-l1); border-top-color: var(--dsw-alias-state-business-primary, #4d6bfe); animation: hwb-spin 700ms linear infinite; }
210
+
211
+ /* ── Corner trigger ───────────────────────────────────────────────────────── */
212
+ .hwb-trigger {
213
+ position: fixed; top: 8px;
214
+ right: calc(var(--dsh-sidebar-width, 0px) + var(--hwb-panel-width, 0px) + 12px);
215
+ z-index: 10000; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
216
+ border: none; border-radius: 8px; background: transparent;
217
+ color: var(--dsw-alias-label-secondary); cursor: pointer; pointer-events: auto;
218
+ transition: right var(--ds-transition-duration-slow, 200ms) var(--ds-ease-in-out, ease), background 120ms ease, color 120ms ease;
219
+ }
220
+ .hwb-trigger:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
221
+ .hwb-trigger:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe); outline-offset: 1px; }
222
+
223
+ @keyframes hwb-spin { to { transform: rotate(360deg); } }
224
+ @keyframes hwb-pop { from { opacity: 0; transform: translateY(-4px); } }
225
+ @media (prefers-reduced-motion: reduce) {
226
+ html #root, .hwb-trigger, header:has([data-slot="conversation.session.header.utilities"]) { transition: none; }
227
+ .hwb-menu { animation: none; }
228
+ }
229
+ `
230
+
231
+ const applyStyles = () => {
232
+ if (typeof document === 'undefined') { try { styles.insert(CSS) } catch (e) {} return () => {} }
233
+ const stale = document.querySelectorAll('style[' + STYLE_MARK + '], style#html-workbench-dsh-plugin-styles')
234
+ for (let i = 0; i < stale.length; i += 1) {
235
+ const node = stale[i]
236
+ if (node.parentNode) node.parentNode.removeChild(node)
237
+ }
238
+ const el = document.createElement('style')
239
+ el.setAttribute(STYLE_MARK, STYLE_VERSION)
240
+ el.textContent = CSS
241
+ document.head.appendChild(el)
242
+ return () => { if (el.parentNode) el.parentNode.removeChild(el) }
243
+ }
244
+
245
+ if (typeof ctx.effect === 'function') ctx.effect(applyStyles, 'html-workbench: styles')
246
+ else applyStyles()
247
+
248
+ // ── Store ────────────────────────────────────────────────────────────────
68
249
  const DEFAULT_WIDTH = 820
69
- const MIN_WIDTH = 480
250
+ const MIN_WIDTH = 460
251
+ const WIDTH_KEY = 'hwb:panel-width'
252
+
253
+ const readWidth = () => {
254
+ try {
255
+ const raw = window.localStorage.getItem(WIDTH_KEY)
256
+ const n = raw == null ? NaN : parseInt(raw, 10)
257
+ return Number.isFinite(n) && n >= MIN_WIDTH ? n : DEFAULT_WIDTH
258
+ } catch (e) { return DEFAULT_WIDTH }
259
+ }
260
+ const writeWidth = (w) => { try { window.localStorage.setItem(WIDTH_KEY, String(w)) } catch (e) {} }
261
+
262
+ let resolveTimer = null
70
263
 
71
264
  const store = {
72
265
  open: false,
73
- panelWidth: DEFAULT_WIDTH,
74
- expanded: false,
266
+ panelWidth: readWidth(),
75
267
  assets: [],
76
268
  running: false,
77
269
  current: null,
270
+ nonce: 0,
78
271
  loading: false,
272
+ refreshing: false,
79
273
  error: null,
274
+ pathInput: '',
275
+ resolveState: 'idle',
276
+ context: null,
277
+ diag: null,
278
+ diagOpen: false,
279
+ restarting: false,
80
280
  listeners: [],
81
281
  subscribe(fn) { this.listeners.push(fn); return () => { this.listeners = this.listeners.filter((f) => f !== fn) } },
82
- set(p) { Object.assign(this, p); this.listeners.forEach((fn) => { try { fn() } catch (e) {} }) },
282
+ set(patch) {
283
+ // Only notify when something actually changed: the panel polls `list`
284
+ // every few seconds, and blindly re-rendering on every tick makes the
285
+ // input feel laggy and needlessly churns the preview subtree.
286
+ let dirty = false
287
+ const keys = Object.keys(patch)
288
+ for (let i = 0; i < keys.length; i += 1) {
289
+ const k = keys[i]
290
+ if (this[k] !== patch[k]) { this[k] = patch[k]; dirty = true }
291
+ }
292
+ if (dirty) this.listeners.forEach((fn) => { try { fn() } catch (e) {} })
293
+ },
83
294
  }
84
295
 
85
296
  const useStore = () => {
@@ -89,117 +300,724 @@ body[data-hwb-dragging] { user-select: none; }
89
300
  }
90
301
 
91
302
  const basename = (p) => {
92
- const parts = String(p).split('/')
93
- return parts[parts.length - 1] || p
303
+ const parts = String(p || '').split('/')
304
+ return parts[parts.length - 1] || String(p || '')
94
305
  }
95
306
 
96
- const refresh = () => {
97
- host.call('list').then((res) => {
98
- if (res && res.ok) store.set({ assets: res.assets || [], running: !!res.running })
99
- else store.set({ error: (res && res.error) || 'list failed' })
307
+ const dirname = (p) => {
308
+ const s = String(p || '')
309
+ const i = s.lastIndexOf('/')
310
+ return i <= 0 ? '/' : s.slice(0, i)
311
+ }
312
+
313
+ // Paths are long and their INFORMATIVE half is the tail, so clip the head
314
+ // (CSS ellipsis would eat the tail). The CSS ellipsis stays as a backstop
315
+ // for narrow panels.
316
+ const clipHead = (s, max) => {
317
+ const str = String(s || '')
318
+ return str.length <= max ? str : '…' + str.slice(str.length - max + 1)
319
+ }
320
+
321
+ const sameAssets = (a, b) => {
322
+ if (a === b) return true
323
+ if (!a || !b || a.length !== b.length) return false
324
+ for (let i = 0; i < a.length; i += 1) {
325
+ if (a[i].path !== b[i].path || a[i].kind !== b[i].kind || a[i].seq !== b[i].seq) return false
326
+ }
327
+ return true
328
+ }
329
+
330
+ // The panel polls `list` every few seconds and the payload now carries the
331
+ // whole diagnostics journal — a fresh object every tick. Compare by the
332
+ // facts that actually change so polling does not re-render continuously.
333
+ const sameDiag = (a, b) => {
334
+ if (a === b) return true
335
+ if (!a || !b) return false
336
+ const ja = a.journal || []
337
+ const jb = b.journal || []
338
+ if (ja.length !== jb.length) return false
339
+ if (ja.length && (ja[0].at !== jb[0].at || ja[0].message !== jb[0].message)) return false
340
+ return a.running === b.running && a.startError === b.startError
341
+ && a.processStatus === b.processStatus && a.exitCode === b.exitCode
342
+ }
343
+
344
+ const refresh = (explicit) => {
345
+ if (explicit) store.set({ refreshing: true })
346
+ return host.call('list').then((res) => {
347
+ if (res && res.ok) {
348
+ const next = res.assets || []
349
+ store.set({
350
+ assets: sameAssets(store.assets, next) ? store.assets : next,
351
+ running: !!res.running,
352
+ diag: sameDiag(store.diag, res) ? store.diag : res,
353
+ })
354
+ } else {
355
+ store.set({ error: (res && res.error) || 'list failed' })
356
+ }
100
357
  }).catch((e) => store.set({ error: String(e && e.message ? e.message : e) }))
358
+ .then(() => { if (explicit) store.set({ refreshing: false }) })
359
+ }
360
+
361
+ // Killing and re-spawning is the one action that fixes most start failures,
362
+ // so it belongs next to the log that reports them.
363
+ const restartService = () => {
364
+ store.set({ restarting: true, error: null })
365
+ return host.call('restart').then((res) => {
366
+ store.set({
367
+ restarting: false,
368
+ running: !!(res && res.ok),
369
+ diag: (res && res.diagnostics) || store.diag,
370
+ error: res && res.ok ? null : (res && res.error) || '重启失败',
371
+ })
372
+ if (res && res.ok) refresh()
373
+ }).catch((e) => store.set({ restarting: false, error: String(e && e.message ? e.message : e) }))
101
374
  }
102
375
 
103
376
  const openFile = (path) => {
104
- store.set({ loading: true, current: { path: path, url: null }, error: null })
105
- host.call('open', { file: path }).then((res) => {
106
- if (res && res.ok) store.set({ loading: false, current: { path: path, url: res.url }, running: true })
107
- else store.set({ loading: false, error: (res && res.error) || 'open failed' })
377
+ const file = String(path || '').trim()
378
+ if (!file) return
379
+ store.set({ loading: true, error: null, pathInput: file })
380
+ host.call('open', { file: file }).then((res) => {
381
+ if (res && res.ok) {
382
+ // Bump the nonce so re-opening the SAME file remounts the iframe:
383
+ // with an unchanged `src` the browser would otherwise keep the old
384
+ // document and "打开" would look like a no-op.
385
+ store.set({
386
+ loading: false,
387
+ running: true,
388
+ resolveState: 'exists',
389
+ current: { path: file, url: res.url },
390
+ nonce: store.nonce + 1,
391
+ })
392
+ } else {
393
+ // A failed open used to collapse into one opaque line. The host now
394
+ // sends the journal along, so open the log on failure: the cause is
395
+ // one glance away instead of a terminal session away.
396
+ store.set({
397
+ loading: false,
398
+ error: (res && res.error) || 'open failed',
399
+ diag: (res && res.diagnostics) || store.diag,
400
+ diagOpen: !!(res && res.diagnostics),
401
+ })
402
+ }
108
403
  }).catch((e) => store.set({ loading: false, error: String(e && e.message ? e.message : e) }))
109
404
  }
110
405
 
406
+ const STATE_TITLE = {
407
+ exists: '文件存在',
408
+ missing: '未找到该文件',
409
+ invalid: '仅支持 .html / .htm 文件',
410
+ checking: '检测中…',
411
+ }
412
+
413
+ // ── Visual selection → composer chips ────────────────────────────────────
414
+ //
415
+ // The workbench posts one selection per click. Each becomes a removable chip
416
+ // above the chat input, and the bulky markdown evidence stays in memory
417
+ // until the user actually sends — so they compose against a short list of
418
+ // labels instead of a wall of HTML.
419
+ //
420
+ // Two deliberate choices:
421
+ // 1. Chips are plain DOM appended into the host's composer card, not a
422
+ // React portal. The card is a flex column owned by the host's React
423
+ // tree; React leaves DOM nodes it never created alone, but it may
424
+ // `insertBefore` around them, so a MutationObserver re-asserts position.
425
+ // 2. The evidence is spliced in during the CAPTURE phase of send. React 18
426
+ // dispatches discrete events synchronously, so writing the value through
427
+ // the native setter + `input` event during capture means React state is
428
+ // already updated by the time the host's own handler reads it.
429
+
430
+ const CHIP_HOST = '.hwb-chips'
431
+ const pendingSelections = []
432
+ let chipRow = null
433
+ let composerObserver = null
434
+
435
+ const findComposer = () => {
436
+ const nodes = document.querySelectorAll('textarea')
437
+ for (let i = 0; i < nodes.length; i += 1) {
438
+ const node = nodes[i]
439
+ // The panel's own inputs are inside `.hwb-panel`; never target those.
440
+ if (node.closest('.hwb-panel')) continue
441
+ const box = node.getBoundingClientRect()
442
+ if (box.width >= 120 && box.height > 0) return node
443
+ }
444
+ return null
445
+ }
446
+
447
+ // The card is the flex column holding the textarea and the tool row. Walking
448
+ // up from the textarea keeps this working if the host renames its classes.
449
+ const findComposerCard = (textarea) => {
450
+ let node = textarea && textarea.parentElement
451
+ let depth = 0
452
+ while (node && depth < 6) {
453
+ const style = window.getComputedStyle(node)
454
+ if (style.display === 'flex' && style.flexDirection === 'column' && node.querySelector('button')) return node
455
+ node = node.parentElement
456
+ depth += 1
457
+ }
458
+ return textarea ? textarea.parentElement : null
459
+ }
460
+
461
+ const setComposerValue = (node, next) => {
462
+ const descriptor = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value')
463
+ const setter = descriptor && descriptor.set
464
+ if (setter) setter.call(node, next)
465
+ else node.value = next
466
+ node.dispatchEvent(new Event('input', { bubbles: true }))
467
+ }
468
+
469
+ const evidenceBlock = () => {
470
+ if (!pendingSelections.length) return ''
471
+ return pendingSelections.map((item) => item.markdown).join('\n')
472
+ }
473
+
474
+ const clearSelections = () => {
475
+ pendingSelections.length = 0
476
+ renderChips()
477
+ }
478
+
479
+ const removeSelection = (key) => {
480
+ const index = pendingSelections.findIndex((item) => item.key === key)
481
+ if (index >= 0) pendingSelections.splice(index, 1)
482
+ renderChips()
483
+ }
484
+
485
+ const chipIcon = '<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7.5v-3A1.5 1.5 0 0 1 4.5 3h3M16.5 3h3A1.5 1.5 0 0 1 21 4.5v3M21 16.5v3a1.5 1.5 0 0 1-1.5 1.5h-3M7.5 21h-3A1.5 1.5 0 0 1 3 19.5v-3"/></svg>'
486
+
487
+ const renderChips = () => {
488
+ const textarea = findComposer()
489
+ const card = findComposerCard(textarea)
490
+ if (!card) return
491
+ if (!pendingSelections.length) {
492
+ if (chipRow && chipRow.parentNode) chipRow.parentNode.removeChild(chipRow)
493
+ chipRow = null
494
+ return
495
+ }
496
+ if (!chipRow) {
497
+ chipRow = document.createElement('div')
498
+ chipRow.className = CHIP_HOST.slice(1)
499
+ }
500
+ chipRow.textContent = ''
501
+ pendingSelections.forEach((item) => {
502
+ const chip = document.createElement('span')
503
+ chip.className = 'hwb-chip'
504
+ chip.title = item.textHint ? item.label + ' — ' + item.textHint : item.label
505
+ chip.innerHTML = chipIcon
506
+ const label = document.createElement('span')
507
+ label.className = 'hwb-chip-label'
508
+ label.textContent = item.label
509
+ const close = document.createElement('button')
510
+ close.type = 'button'
511
+ close.className = 'hwb-chip-x'
512
+ close.setAttribute('aria-label', '移除 ' + item.label)
513
+ close.innerHTML = '<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg>'
514
+ close.addEventListener('click', (event) => {
515
+ event.preventDefault()
516
+ event.stopPropagation()
517
+ removeSelection(item.key)
518
+ })
519
+ chip.appendChild(label)
520
+ chip.appendChild(close)
521
+ chipRow.appendChild(chip)
522
+ })
523
+ const note = document.createElement('span')
524
+ note.className = 'hwb-chip-note'
525
+ note.textContent = '发送时会自动附上选区源码'
526
+ chipRow.appendChild(note)
527
+
528
+ // Sit directly above the tool row (the last flex child), which puts the
529
+ // chips between the text input and the model/send controls.
530
+ const anchor = card.lastElementChild
531
+ if (chipRow.parentNode !== card || chipRow.nextElementSibling !== anchor) {
532
+ card.insertBefore(chipRow, anchor)
533
+ }
534
+ observeComposer(card)
535
+ }
536
+
537
+ const observeComposer = (card) => {
538
+ if (composerObserver) return
539
+ composerObserver = new MutationObserver(() => {
540
+ if (!pendingSelections.length) return
541
+ if (!chipRow || chipRow.parentNode !== card) renderChips()
542
+ })
543
+ composerObserver.observe(card, { childList: true })
544
+ ctx.effect(() => () => {
545
+ if (composerObserver) composerObserver.disconnect()
546
+ composerObserver = null
547
+ })
548
+ }
549
+
550
+ const receiveContext = (packet) => {
551
+ const key = packet.key || packet.label
552
+ const existing = pendingSelections.findIndex((item) => item.key === key)
553
+ const entry = {
554
+ key: key,
555
+ label: packet.label || 'element',
556
+ textHint: packet.textHint || '',
557
+ markdown: packet.markdown,
558
+ fileName: packet.fileName,
559
+ }
560
+ // Re-adding the same element refreshes its evidence rather than stacking a
561
+ // duplicate: the file may have changed since the first click.
562
+ if (existing >= 0) pendingSelections[existing] = entry
563
+ else pendingSelections.push(entry)
564
+ renderChips()
565
+ const textarea = findComposer()
566
+ if (textarea) textarea.focus()
567
+ store.set({ context: { count: pendingSelections.length, label: entry.label, at: Date.now() } })
568
+ }
569
+
570
+ // Splice the evidence in just before the host reads the composer, then drop
571
+ // the chips: the message now carries the context, so keeping them would
572
+ // silently re-attach the same source to the next turn.
573
+ const spliceEvidenceIntoMessage = () => {
574
+ if (!pendingSelections.length) return
575
+ const textarea = findComposer()
576
+ if (!textarea) return
577
+ const typed = (textarea.value || '').trim()
578
+ if (!typed) return
579
+ setComposerValue(textarea, evidenceBlock() + '\n' + typed)
580
+ clearSelections()
581
+ }
582
+
583
+ const bindSendInterception = () => {
584
+ const onClick = (event) => {
585
+ if (!pendingSelections.length) return
586
+ const target = event.target instanceof Element ? event.target : null
587
+ const button = target && target.closest('button')
588
+ if (!button || button.closest('.hwb-panel')) return
589
+ const label = button.getAttribute('aria-label') || ''
590
+ if (!/发送|send/i.test(label)) return
591
+ spliceEvidenceIntoMessage()
592
+ }
593
+ const onKeyDown = (event) => {
594
+ if (!pendingSelections.length) return
595
+ if (event.key !== 'Enter' || event.shiftKey || event.isComposing) return
596
+ const target = event.target
597
+ if (!(target instanceof HTMLTextAreaElement) || target.closest('.hwb-panel')) return
598
+ spliceEvidenceIntoMessage()
599
+ }
600
+ document.addEventListener('click', onClick, true)
601
+ document.addEventListener('keydown', onKeyDown, true)
602
+ ctx.effect(() => () => {
603
+ document.removeEventListener('click', onClick, true)
604
+ document.removeEventListener('keydown', onKeyDown, true)
605
+ })
606
+ }
607
+
608
+ bindSendInterception()
609
+
610
+
611
+ const checkPath = (value) => {
612
+ const trimmed = (value || '').trim()
613
+ if (resolveTimer) { clearTimeout(resolveTimer); resolveTimer = null }
614
+ if (!trimmed) { store.set({ resolveState: 'idle' }); return }
615
+ store.set({ resolveState: 'checking' })
616
+ resolveTimer = setTimeout(() => {
617
+ resolveTimer = null
618
+ host.call('resolve', { file: trimmed }).then((res) => {
619
+ if (!res || res.ok === false) { store.set({ resolveState: 'idle' }); return }
620
+ if (!res.isHtml) store.set({ resolveState: 'invalid' })
621
+ else if (res.exists === true) store.set({ resolveState: 'exists' })
622
+ else if (res.exists === false) store.set({ resolveState: 'missing' })
623
+ else store.set({ resolveState: 'idle' })
624
+ }).catch(() => store.set({ resolveState: 'idle' }))
625
+ }, 300)
626
+ }
627
+
628
+ // ── Icons ────────────────────────────────────────────────────────────────
629
+ const icon = (size, children, extra) => {
630
+ const props = {
631
+ width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
632
+ stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round',
633
+ strokeLinejoin: 'round', 'aria-hidden': true,
634
+ }
635
+ if (extra) Object.assign(props, extra)
636
+ return React.createElement('svg', props, children)
637
+ }
638
+ const path = (d, key) => React.createElement('path', { d: d, key: key })
639
+
640
+ const I_CLOSE = icon(15, [path('M18 6 6 18', 'a'), path('m6 6 12 12', 'b')])
641
+ const I_REFRESH = icon(15, [path('M21 12a9 9 0 1 1-3.2-6.9', 'a'), path('M21 4v5h-5', 'b')])
642
+ const I_EXTERNAL = icon(15, [path('M15 3h6v6', 'a'), path('M10 14 21 3', 'b'), path('M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5', 'c')])
643
+ const I_CARET = icon(14, [path('m6 9 6 6 6-6', 'a')])
644
+ const I_CHECK = icon(14, [path('M20 6 9 17l-5-5', 'a')], { strokeWidth: 2.2 })
645
+ const I_MISSING = icon(14, [path('M18 6 6 18', 'a'), path('m6 6 12 12', 'b')], { strokeWidth: 2.2 })
646
+ const I_WARN = icon(14, [path('M12 9v4', 'a'), path('M12 17h.01', 'b'), path('M10.3 3.9 2.4 17.5A1.8 1.8 0 0 0 4 20.2h16a1.8 1.8 0 0 0 1.6-2.7L13.7 3.9a1.8 1.8 0 0 0-3.4 0Z', 'c')])
647
+ const I_LOADING = icon(14, [React.createElement('circle', { cx: 12, cy: 12, r: 9, strokeOpacity: .25, key: 'a' }), path('M21 12a9 9 0 0 0-9-9', 'b')], { strokeWidth: 2.2 })
648
+ const I_FILE = icon(14, [path('M14 3v5h5', 'a'), path('M15 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7Z', 'b')])
649
+ const I_ALERT = icon(14, [React.createElement('circle', { cx: 12, cy: 12, r: 9, key: 'a' }), path('M12 8v4', 'b'), path('M12 16h.01', 'c')])
650
+ const I_BLANK = icon(22, [path('M14 3v5h5', 'a'), path('M15 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7Z', 'b'), path('m9 15 1.8-2.2L12.4 15l1.4-1.8', 'c')])
651
+ const I_TRIGGER = icon(17, [
652
+ React.createElement('rect', { x: 2.5, y: 4, width: 19, height: 14, rx: 2.4, key: 'a' }),
653
+ path('M2.5 8.4h19', 'b'),
654
+ path('M8 21h8', 'c'),
655
+ path('M12 18v3', 'd'),
656
+ ])
657
+ const I_LOGS = icon(15, [path('M8 6h10', 'a'), path('M8 12h10', 'b'), path('M8 18h6', 'c'), path('M4 6h.01', 'd'), path('M4 12h.01', 'e'), path('M4 18h.01', 'f')])
658
+
659
+ // ── Diagnostics view ─────────────────────────────────────────────────────
660
+ //
661
+ // A start failure has exactly one visible symptom by default: a red dot. The
662
+ // cause lives in a Python traceback or a spawn error inside the host process,
663
+ // so surface it verbatim here — plus the facts needed to reproduce by hand
664
+ // (port, script path, exit code). That turns "服务起不来" into a fixable
665
+ // report without leaving the panel.
666
+
667
+ const clockTime = (at) => {
668
+ try {
669
+ return new Date(at).toLocaleTimeString('zh-CN', { hour12: false })
670
+ } catch (e) { return '' }
671
+ }
672
+
673
+ const Diagnostics = () => {
674
+ const s = useStore()
675
+ const d = s.diag
676
+ const journal = (d && d.journal) || []
677
+
678
+ const fact = (key, value) => value == null || value === ''
679
+ ? null
680
+ : [
681
+ React.createElement('span', { className: 'hwb-diag-key', key: key + '-k' }, key),
682
+ React.createElement('span', { className: 'hwb-diag-val', key: key + '-v' }, String(value)),
683
+ ]
684
+
685
+ return React.createElement('div', { className: 'hwb-diag' },
686
+ React.createElement('div', { className: 'hwb-diag-head' },
687
+ React.createElement('span', { className: 'hwb-diag-title' }, '服务诊断'),
688
+ React.createElement('span', { className: 'hwb-spacer' }),
689
+ React.createElement('button', {
690
+ type: 'button', className: 'hwb-btn hwb-btn-quiet hwb-btn-sm',
691
+ disabled: s.restarting, onClick: restartService,
692
+ }, s.restarting ? '重启中…' : '重启服务'),
693
+ React.createElement('button', {
694
+ type: 'button', className: 'hwb-icon', title: '收起诊断', 'aria-label': '收起诊断',
695
+ onClick: () => store.set({ diagOpen: false }),
696
+ }, I_CLOSE),
697
+ ),
698
+ d
699
+ ? React.createElement('div', { className: 'hwb-diag-facts' },
700
+ fact('状态', d.running ? '运行中' : (d.processStatus === 'running' ? '启动中' : '未就绪')),
701
+ fact('端口', d.port),
702
+ fact('进程', d.processStatus ? d.processStatus + (d.exitCode == null ? '' : '(exit=' + d.exitCode + ')') : '未由本插件启动'),
703
+ fact('失败原因', d.startError),
704
+ fact('脚本', d.script),
705
+ d.hasShell === false ? fact('shell', '不可用') : null,
706
+ )
707
+ : null,
708
+ React.createElement('div', { className: 'hwb-diag-body' },
709
+ journal.length
710
+ ? journal.map((entry, i) => React.createElement('div', {
711
+ className: 'hwb-diag-row', 'data-level': entry.level, key: String(entry.at) + '-' + i,
712
+ },
713
+ React.createElement('span', { className: 'hwb-diag-time' }, clockTime(entry.at)),
714
+ React.createElement('span', { className: 'hwb-diag-msg' },
715
+ entry.message,
716
+ entry.detail ? React.createElement('span', { className: 'hwb-diag-detail' }, entry.detail) : null,
717
+ ),
718
+ ))
719
+ : React.createElement('div', { className: 'hwb-diag-empty' }, '暂无日志。点「重启服务」可重新拉起并记录完整过程。'),
720
+ ),
721
+ React.createElement('div', { className: 'hwb-diag-hint' },
722
+ '服务自身日志:',
723
+ React.createElement('code', null, (d && d.logDir) || '/tmp/html-workbench-dsh/logs/'),
724
+ ';也可直接访问 ',
725
+ React.createElement('code', null, '/html-workbench/diagnostics'),
726
+ ' 查看原始 JSON。',
727
+ ),
728
+ )
729
+ }
730
+
731
+ const STATE_ICON = { exists: I_CHECK, missing: I_MISSING, invalid: I_WARN, checking: I_LOADING }
732
+
733
+ // ── Resize ───────────────────────────────────────────────────────────────
111
734
  const startResize = (e) => {
735
+ if (e.button !== undefined && e.button !== 0) return
112
736
  e.preventDefault()
737
+ const handle = e.currentTarget
738
+ handle.setAttribute('data-active', '')
113
739
  document.body.setAttribute('data-hwb-dragging', '')
114
- const maxW = Math.max(MIN_WIDTH, window.innerWidth - 60)
740
+ const maxW = () => Math.max(MIN_WIDTH, window.innerWidth - 80)
115
741
  const onMove = (ev) => {
116
- const w = window.innerWidth - ev.clientX
117
- store.set({ panelWidth: Math.max(MIN_WIDTH, Math.min(w, maxW)) })
742
+ const w = Math.round(window.innerWidth - ev.clientX)
743
+ store.set({ panelWidth: Math.max(MIN_WIDTH, Math.min(w, maxW())) })
118
744
  }
119
745
  const onUp = () => {
746
+ handle.removeAttribute('data-active')
120
747
  document.body.removeAttribute('data-hwb-dragging')
121
748
  document.removeEventListener('mousemove', onMove)
122
749
  document.removeEventListener('mouseup', onUp)
750
+ writeWidth(store.panelWidth)
123
751
  }
124
752
  document.addEventListener('mousemove', onMove)
125
753
  document.addEventListener('mouseup', onUp)
126
754
  }
127
755
 
128
- const chevronUp = React.createElement('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' },
129
- React.createElement('path', { d: 'M18 15l-6-6-6 6' }))
130
- const chevronDown = React.createElement('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' },
131
- React.createElement('path', { d: 'M6 9l6 6 6-6' }))
756
+ const nudgeWidth = (delta) => {
757
+ const maxW = Math.max(MIN_WIDTH, window.innerWidth - 80)
758
+ const w = Math.max(MIN_WIDTH, Math.min(store.panelWidth + delta, maxW))
759
+ store.set({ panelWidth: w })
760
+ writeWidth(w)
761
+ }
132
762
 
763
+ // ── Panel ────────────────────────────────────────────────────────────────
133
764
  const Panel = () => {
134
765
  const s = useStore()
766
+ const [menuOpen, setMenuOpen] = React.useState(false)
767
+ const [focused, setFocused] = React.useState(false)
768
+ const fieldRef = React.useRef(null)
769
+ const inputRef = React.useRef(null)
770
+
135
771
  React.useEffect(() => {
136
772
  const root = document.documentElement
137
- root.style.setProperty('--hwb-panel-width', s.open ? (s.panelWidth + 'px') : '0px')
773
+ root.style.setProperty('--hwb-panel-width', s.open ? s.panelWidth + 'px' : '0px')
138
774
  return () => { root.style.setProperty('--hwb-panel-width', '0px') }
139
775
  }, [s.open, s.panelWidth])
776
+
140
777
  React.useEffect(() => {
141
- if (!s.open) return
778
+ if (!s.open) return undefined
142
779
  refresh()
143
- const dispose = ctx.interval(refresh, 3000)
780
+ const dispose = ctx.interval(refresh, 4000)
144
781
  return () => { if (dispose) dispose() }
145
782
  }, [s.open])
783
+
784
+ // The workbench runs in an iframe, so its selections arrive as messages.
785
+ // Bind while the panel is mounted, regardless of which file is open.
786
+ React.useEffect(() => {
787
+ const onMessage = (event) => {
788
+ const data = event.data
789
+ if (!data || data.type !== 'html-workbench:context') return
790
+ if (!data.markdown) return
791
+ receiveContext(data)
792
+ }
793
+ window.addEventListener('message', onMessage)
794
+ return () => window.removeEventListener('message', onMessage)
795
+ }, [])
796
+
797
+ // Drop any in-flight path check when the panel closes.
798
+ React.useEffect(() => () => { if (resolveTimer) { clearTimeout(resolveTimer); resolveTimer = null } }, [])
799
+
800
+ React.useEffect(() => {
801
+ if (!menuOpen) return undefined
802
+ const onDown = (e) => { if (fieldRef.current && !fieldRef.current.contains(e.target)) setMenuOpen(false) }
803
+ const onKey = (e) => { if (e.key === 'Escape') { setMenuOpen(false); if (inputRef.current) inputRef.current.focus() } }
804
+ document.addEventListener('mousedown', onDown)
805
+ document.addEventListener('keydown', onKey)
806
+ return () => { document.removeEventListener('mousedown', onDown); document.removeEventListener('keydown', onKey) }
807
+ }, [menuOpen])
808
+
146
809
  if (!s.open) return null
147
810
 
148
811
  const assets = s.assets || []
149
- const currentPath = s.current && s.current.path ? s.current.path : ''
150
- const opts = assets.map((a) => React.createElement('option', { key: a.id || a.path, value: a.path }, basename(a.path)))
151
- const items = assets.map((a) => {
152
- const active = currentPath === a.path
153
- return React.createElement('div', { key: a.id || a.path, className: 'hwb-item' + (active ? ' active' : '') },
154
- React.createElement('div', { className: 'hwb-item-main' },
155
- React.createElement('div', { className: 'hwb-item-name' }, basename(a.path)),
156
- React.createElement('div', { className: 'hwb-item-path', title: a.path }, a.path),
157
- ),
158
- React.createElement('button', { type: 'button', className: 'hwb-item-btn', onClick: () => openFile(a.path) }, '打开'),
159
- )
160
- })
812
+ const trimmed = (s.pathInput || '').trim()
813
+ const currentPath = s.current ? s.current.path : null
814
+ const submit = () => { if (trimmed) { setMenuOpen(false); openFile(trimmed) } }
815
+ const pick = (p) => { setMenuOpen(false); store.set({ pathInput: p }); openFile(p) }
161
816
 
162
- return React.createElement('div', { className: 'hwb-panel', style: { width: s.panelWidth + 'px' }, role: 'dialog', 'aria-label': 'HTML Workbench' },
163
- React.createElement('div', { className: 'hwb-resize', title: '拖动调整宽度', onMouseDown: startResize }),
164
- React.createElement('div', { className: 'hwb-head' },
165
- React.createElement('span', { className: 'hwb-dot' + (s.running ? ' on' : '') }),
166
- React.createElement('div', { className: 'hwb-titlewrap' },
167
- React.createElement('div', { className: 'hwb-title' }, 'HTML Workbench'),
168
- React.createElement('div', { className: 'hwb-sub' }, s.running ? '服务运行中 · 拖动左边缘调整宽度' : '服务未就绪'),
169
- ),
170
- React.createElement('span', { className: 'hwb-spacer' }),
171
- React.createElement('button', { type: 'button', className: 'hwb-close', title: '关闭', onClick: () => store.set({ open: false }) },
172
- React.createElement('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round' },
173
- React.createElement('path', { d: 'M18 6L6 18' }),
174
- React.createElement('path', { d: 'M6 6l12 12' }),
175
- ),
176
- ),
177
- ),
178
- React.createElement('div', { className: 'hwb-preview' },
179
- s.loading ? React.createElement('div', { className: 'hwb-hint' }, '正在启动 Workbench…')
180
- : s.current && s.current.url ? React.createElement('iframe', { className: 'hwb-frame', src: s.current.url, title: 'HTML Workbench' })
181
- : React.createElement('div', { className: 'hwb-hint' }, '从下方选择一个 HTML 文件开始编辑与预览'),
817
+ const assetRow = (a, inMenu) => React.createElement('button', {
818
+ key: a.id || a.path,
819
+ type: 'button',
820
+ className: 'hwb-item',
821
+ 'data-active': a.path === currentPath ? '' : undefined,
822
+ title: a.path,
823
+ onClick: () => pick(a.path),
824
+ },
825
+ I_FILE,
826
+ React.createElement('span', { className: 'hwb-item-main' },
827
+ React.createElement('span', { className: 'hwb-item-name' }, basename(a.path)),
828
+ React.createElement('span', { className: 'hwb-item-path' }, clipHead(dirname(a.path), 52)),
182
829
  ),
183
- React.createElement('div', { className: 'hwb-dock' },
184
- React.createElement('div', { className: 'hwb-dockbar' },
185
- React.createElement('select', {
186
- className: 'hwb-select',
187
- value: currentPath,
188
- onChange: (e) => { const v = e.target.value; if (v) openFile(v) },
830
+ inMenu && a.kind ? React.createElement('span', { className: 'hwb-tag', 'data-kind': a.kind }, a.kind === 'create' ? '新建' : '编辑') : null,
831
+ )
832
+
833
+ // A dead service makes "填入路径开始编辑" a lie — every open will fail.
834
+ // Say what is actually wrong and offer the two things that help.
835
+ const serviceDown = !s.running && !!s.diag && !s.loading
836
+ const body = s.loading
837
+ ? React.createElement('div', { className: 'hwb-center' },
838
+ React.createElement('div', { className: 'hwb-spinner' }),
839
+ React.createElement('div', { className: 'hwb-blank-desc' }, '正在启动 Workbench 服务…'),
840
+ )
841
+ : s.current && s.current.url
842
+ ? React.createElement('iframe', {
843
+ key: 'frame-' + s.nonce,
844
+ className: 'hwb-frame',
845
+ src: s.current.url,
846
+ title: 'HTML Workbench — ' + basename(s.current.path),
847
+ })
848
+ : serviceDown
849
+ ? React.createElement('div', { className: 'hwb-center' },
850
+ React.createElement('div', { className: 'hwb-blank' }, I_ALERT),
851
+ React.createElement('div', null,
852
+ React.createElement('div', { className: 'hwb-blank-title' }, '本地服务未就绪'),
853
+ React.createElement('div', { className: 'hwb-blank-desc' },
854
+ s.diag.startError || '服务进程没有响应健康检查,暂时无法打开文件。'),
855
+ ),
856
+ React.createElement('div', { style: { display: 'flex', gap: '8px' } },
857
+ React.createElement('button', {
858
+ type: 'button', className: 'hwb-btn hwb-btn-primary hwb-btn-sm',
859
+ disabled: s.restarting, onClick: restartService,
860
+ }, s.restarting ? '重启中…' : '重启服务'),
861
+ React.createElement('button', {
862
+ type: 'button', className: 'hwb-btn hwb-btn-quiet hwb-btn-sm',
863
+ onClick: () => store.set({ diagOpen: true }),
864
+ }, '查看诊断日志'),
865
+ ),
866
+ )
867
+ : React.createElement('div', { className: 'hwb-center' },
868
+ React.createElement('div', { className: 'hwb-blank' }, I_BLANK),
869
+ React.createElement('div', null,
870
+ React.createElement('div', { className: 'hwb-blank-title' }, '还没有打开文件'),
871
+ React.createElement('div', { className: 'hwb-blank-desc' }, assets.length
872
+ ? '在上方地址栏填入 .html 的绝对路径,或从下面的产物里挑一个开始可视化编辑。'
873
+ : '在上方地址栏填入 .html 的绝对路径开始可视化编辑。代理 write / edit 过的 .html 之后也会自动出现在这里。'),
874
+ ),
875
+ assets.length
876
+ ? React.createElement('div', { className: 'hwb-recent' },
877
+ React.createElement('div', { className: 'hwb-recent-label' }, '最近的 HTML 产物'),
878
+ assets.slice(0, 6).map((a) => assetRow(a, false)),
879
+ )
880
+ : null,
881
+ )
882
+
883
+ return React.createElement('div', {
884
+ className: 'hwb-panel',
885
+ style: { width: s.panelWidth + 'px', maxWidth: 'calc(100vw - 24px)' },
886
+ role: 'complementary',
887
+ 'aria-label': 'HTML Workbench',
888
+ },
889
+ React.createElement('div', {
890
+ className: 'hwb-resize',
891
+ role: 'separator',
892
+ 'aria-orientation': 'vertical',
893
+ 'aria-label': '调整面板宽度',
894
+ tabIndex: 0,
895
+ title: '拖动调整宽度(双击复位)',
896
+ onMouseDown: startResize,
897
+ onDoubleClick: () => { store.set({ panelWidth: DEFAULT_WIDTH }); writeWidth(DEFAULT_WIDTH) },
898
+ onKeyDown: (e) => {
899
+ if (e.key === 'ArrowLeft') { e.preventDefault(); nudgeWidth(32) }
900
+ else if (e.key === 'ArrowRight') { e.preventDefault(); nudgeWidth(-32) }
901
+ },
902
+ }),
903
+
904
+ React.createElement('div', { className: 'hwb-chrome' },
905
+ React.createElement('div', { className: 'hwb-idrow' },
906
+ React.createElement('button', {
907
+ type: 'button',
908
+ className: 'hwb-statusbtn',
909
+ 'aria-expanded': !!s.diagOpen,
910
+ title: s.running ? '本地服务运行中 — 点击查看诊断' : '本地服务未就绪 — 点击查看原因',
911
+ onClick: () => store.set({ diagOpen: !s.diagOpen }),
189
912
  },
190
- React.createElement('option', { value: '', disabled: true }, assets.length ? '选择 HTML 文件…' : '暂无 HTML 产物'),
191
- opts,
913
+ React.createElement('span', {
914
+ className: 'hwb-dot',
915
+ 'data-on': s.running ? '' : undefined,
916
+ 'data-off': !s.running ? '' : undefined,
917
+ }),
918
+ React.createElement('span', { className: 'hwb-name' }, 'HTML Workbench'),
192
919
  ),
193
- React.createElement('span', { className: 'hwb-count' }, assets.length + ' 个'),
194
- React.createElement('button', { type: 'button', className: 'hwb-docktoggle', title: s.expanded ? '收起列表' : '展开列表', onClick: () => store.set({ expanded: !s.expanded }) },
195
- s.expanded ? chevronDown : chevronUp,
920
+ currentPath ? React.createElement('span', { className: 'hwb-sep' }) : null,
921
+ currentPath
922
+ ? React.createElement('span', { className: 'hwb-filechip', title: currentPath }, I_FILE, React.createElement('span', null, basename(currentPath)))
923
+ : null,
924
+ React.createElement('span', { className: 'hwb-spacer' }),
925
+ React.createElement('div', { className: 'hwb-actions' },
926
+ React.createElement('button', {
927
+ type: 'button', className: 'hwb-icon', title: '服务诊断',
928
+ 'aria-label': '服务诊断', 'aria-expanded': !!s.diagOpen,
929
+ onClick: () => store.set({ diagOpen: !s.diagOpen }),
930
+ }, I_LOGS),
931
+ React.createElement('button', {
932
+ type: 'button', className: 'hwb-icon', title: '刷新产物列表',
933
+ 'aria-label': '刷新产物列表', 'data-spin': s.refreshing ? '' : undefined,
934
+ onClick: () => refresh(true),
935
+ }, I_REFRESH),
936
+ React.createElement('button', {
937
+ type: 'button', className: 'hwb-icon', title: '在浏览器标签页中打开',
938
+ 'aria-label': '在浏览器标签页中打开', disabled: !(s.current && s.current.url),
939
+ onClick: () => { if (s.current && s.current.url) window.open(s.current.url, '_blank', 'noopener') },
940
+ }, I_EXTERNAL),
941
+ React.createElement('button', {
942
+ type: 'button', className: 'hwb-icon', title: '关闭面板',
943
+ 'aria-label': '关闭面板', onClick: () => store.set({ open: false }),
944
+ }, I_CLOSE),
945
+ ),
946
+ ),
947
+
948
+ React.createElement('div', { className: 'hwb-toolbar' },
949
+ React.createElement('div', { className: 'hwb-fieldwrap', ref: fieldRef },
950
+ React.createElement('div', { className: 'hwb-field', 'data-focus': focused ? '' : undefined },
951
+ React.createElement('input', {
952
+ ref: inputRef,
953
+ className: 'hwb-input',
954
+ type: 'text',
955
+ placeholder: '/absolute/path/page.html',
956
+ value: s.pathInput,
957
+ spellCheck: false,
958
+ autoComplete: 'off',
959
+ 'aria-label': 'HTML 文件绝对路径',
960
+ onChange: (e) => { const v = e.target.value; store.set({ pathInput: v }); checkPath(v) },
961
+ onKeyDown: (e) => {
962
+ if (e.key === 'Enter') submit()
963
+ else if (e.key === 'ArrowDown' && assets.length) { e.preventDefault(); setMenuOpen(true) }
964
+ },
965
+ onFocus: () => { setFocused(true); if (assets.length && !trimmed) setMenuOpen(true) },
966
+ onBlur: () => setFocused(false),
967
+ }),
968
+ s.resolveState !== 'idle'
969
+ ? React.createElement('span', {
970
+ className: 'hwb-state',
971
+ 'data-state': s.resolveState,
972
+ title: STATE_TITLE[s.resolveState] || '',
973
+ }, STATE_ICON[s.resolveState] || null)
974
+ : null,
975
+ React.createElement('button', {
976
+ type: 'button',
977
+ className: 'hwb-caret',
978
+ 'aria-expanded': menuOpen,
979
+ 'aria-haspopup': 'listbox',
980
+ title: '历史 HTML 产物' + (assets.length ? '(' + assets.length + ')' : ''),
981
+ onClick: () => setMenuOpen((v) => !v),
982
+ }, I_CARET),
983
+ ),
984
+ menuOpen
985
+ ? React.createElement('div', { className: 'hwb-menu', role: 'listbox' },
986
+ React.createElement('div', { className: 'hwb-menu-head' },
987
+ React.createElement('span', null, 'HTML 产物'),
988
+ React.createElement('span', null, assets.length ? assets.length + ' 个' : '空'),
989
+ ),
990
+ assets.length
991
+ ? React.createElement('div', { className: 'hwb-menu-body' }, assets.map((a) => assetRow(a, true)))
992
+ : React.createElement('div', { className: 'hwb-menu-empty' }, '暂无产物', React.createElement('br'), '代理 write / edit 过的 .html 会出现在这里'),
993
+ )
994
+ : null,
196
995
  ),
996
+ React.createElement('button', {
997
+ type: 'button', className: 'hwb-btn hwb-btn-primary',
998
+ disabled: !trimmed || s.loading, onClick: submit,
999
+ }, '打开'),
197
1000
  ),
198
- s.expanded ? React.createElement('div', { className: 'hwb-docklist' },
199
- items.length ? items : React.createElement('div', { className: 'hwb-dockempty' }, '暂无 HTML 产物 — 代理 write/edit 的 .html 文件会出现在这里。'),
200
- s.error ? React.createElement('div', { className: 'hwb-error' }, s.error) : null,
201
- ) : null,
202
1001
  ),
1002
+
1003
+ s.error
1004
+ ? React.createElement('div', { className: 'hwb-banner', role: 'alert' },
1005
+ I_ALERT,
1006
+ React.createElement('span', { className: 'hwb-banner-text' }, s.error),
1007
+ React.createElement('button', {
1008
+ type: 'button', className: 'hwb-icon', title: '查看诊断', 'aria-label': '查看诊断',
1009
+ onClick: () => store.set({ diagOpen: true }),
1010
+ }, I_LOGS),
1011
+ React.createElement('button', {
1012
+ type: 'button', className: 'hwb-icon', title: '忽略', 'aria-label': '忽略',
1013
+ onClick: () => store.set({ error: null }),
1014
+ }, I_CLOSE),
1015
+ )
1016
+ : null,
1017
+
1018
+ s.diagOpen ? React.createElement(Diagnostics) : null,
1019
+
1020
+ React.createElement('div', { className: 'hwb-body' }, body),
203
1021
  )
204
1022
  }
205
1023
 
@@ -210,13 +1028,10 @@ body[data-hwb-dragging] { user-select: none; }
210
1028
  type: 'button',
211
1029
  className: 'hwb-trigger',
212
1030
  title: 'HTML Workbench',
213
- 'aria-expanded': s.open,
1031
+ 'aria-label': '打开 HTML Workbench',
1032
+ 'aria-expanded': false,
214
1033
  onClick: () => { store.set({ open: true }); refresh() },
215
- }, React.createElement('svg', { width: 18, height: 18, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' },
216
- React.createElement('rect', { x: 2, y: 4, width: 20, height: 14, rx: 2 }),
217
- React.createElement('path', { d: 'M8 21h8' }),
218
- React.createElement('path', { d: 'M12 18v3' }),
219
- ))
1034
+ }, I_TRIGGER)
220
1035
  }
221
1036
 
222
1037
  slots.inject('shell.overlay', () => slots.register(