@songsid/agend 2.3.5-alpha.5 → 2.3.5-alpha.7
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/THIRD_PARTY_NOTICES.md +0 -1
- package/dist/accounts-profiles.d.ts +96 -0
- package/dist/accounts-profiles.js +178 -0
- package/dist/accounts-profiles.js.map +1 -0
- package/dist/accounts-signout.d.ts +59 -0
- package/dist/accounts-signout.js +184 -0
- package/dist/accounts-signout.js.map +1 -0
- package/dist/accounts-view.d.ts +54 -0
- package/dist/accounts-view.js +55 -11
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-workspace.d.ts +11 -0
- package/dist/agent-workspace.js +28 -0
- package/dist/agent-workspace.js.map +1 -1
- package/dist/auth-api.js +38 -5
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/session-authorizations.d.ts +2 -0
- package/dist/authority/session-authorizations.js +7 -1
- package/dist/authority/session-authorizations.js.map +1 -1
- package/dist/authority/web-authority.d.ts +13 -0
- package/dist/authority/web-authority.js +12 -0
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/claude-code.js +47 -9
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.js +1 -0
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +2 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/bundled-tmux-guard.d.ts +19 -0
- package/dist/bundled-tmux-guard.js +83 -0
- package/dist/bundled-tmux-guard.js.map +1 -0
- package/dist/channel/access-manager.d.ts +1 -6
- package/dist/channel/access-manager.js +4 -94
- package/dist/channel/access-manager.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +0 -2
- package/dist/channel/adapters/discord.js +0 -8
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +0 -3
- package/dist/channel/adapters/telegram.js +1 -30
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/types.d.ts +0 -2
- package/dist/classic-bindings.d.ts +13 -0
- package/dist/classic-bindings.js +28 -2
- package/dist/classic-bindings.js.map +1 -1
- package/dist/classic-channel-manager.d.ts +2 -0
- package/dist/classic-channel-manager.js +5 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/cli.js +117 -30
- package/dist/cli.js.map +1 -1
- package/dist/config-validator.js +11 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +27 -2
- package/dist/daemon.js +107 -6
- package/dist/daemon.js.map +1 -1
- package/dist/doctor.js +3 -4
- package/dist/doctor.js.map +1 -1
- package/dist/e2e-isolation.js +5 -2
- package/dist/e2e-isolation.js.map +1 -1
- package/dist/fleet-control-audit.d.ts +1 -1
- package/dist/fleet-manager.d.ts +188 -1
- package/dist/fleet-manager.js +1059 -79
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +22 -7
- package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
- package/dist/general-knowledge/steering/core-rules.md +6 -4
- package/dist/hub/buttons.js +4 -2
- package/dist/hub/buttons.js.map +1 -1
- package/dist/hub/catalog.d.ts +1 -1
- package/dist/hub/catalog.js +82 -15
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/compose/server.d.ts +4 -1
- package/dist/hub/compose/server.js +30 -3
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +142 -21
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/groups.d.ts +29 -0
- package/dist/hub/directory/groups.js +29 -0
- package/dist/hub/directory/groups.js.map +1 -0
- package/dist/hub/directory/index.d.ts +2 -1
- package/dist/hub/directory/types.d.ts +12 -2
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/admin-context.d.ts +23 -0
- package/dist/hub/group-policy/admin-context.js +52 -0
- package/dist/hub/group-policy/admin-context.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +235 -0
- package/dist/hub/group-policy/admin-dto.js +55 -0
- package/dist/hub/group-policy/admin-dto.js.map +1 -0
- package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
- package/dist/hub/group-policy/admin-inventory.js +72 -0
- package/dist/hub/group-policy/admin-inventory.js.map +1 -0
- package/dist/hub/group-policy/admin-read.d.ts +21 -0
- package/dist/hub/group-policy/admin-read.js +90 -0
- package/dist/hub/group-policy/admin-read.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +43 -0
- package/dist/hub/group-policy/authorization.js +170 -0
- package/dist/hub/group-policy/authorization.js.map +1 -0
- package/dist/hub/group-policy/model.d.ts +56 -0
- package/dist/hub/group-policy/model.js +46 -0
- package/dist/hub/group-policy/model.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +60 -0
- package/dist/hub/group-policy/resources.js +191 -0
- package/dist/hub/group-policy/resources.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +58 -0
- package/dist/hub/group-policy/store.js +155 -0
- package/dist/hub/group-policy/store.js.map +1 -0
- package/dist/hub/http/compose.js +9 -9
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +23 -3
- package/dist/hub/http/core.js +138 -5
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +3 -0
- package/dist/hub/pairing.d.ts +3 -1
- package/dist/hub/pairing.js +6 -3
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/policy.d.ts +3 -1
- package/dist/hub/policy.js +13 -6
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/rooms.d.ts +1 -0
- package/dist/hub/rooms.js +76 -26
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/server.d.ts +2 -0
- package/dist/hub/server.js +12 -2
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sessions.js +2 -1
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/types.d.ts +2 -0
- package/dist/instance-config-impact.js +4 -3
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instance-lifecycle.d.ts +17 -0
- package/dist/instance-lifecycle.js +38 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +45 -18
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +5 -0
- package/dist/login-controller.js +11 -0
- package/dist/login-controller.js.map +1 -1
- package/dist/login-window-lock.d.ts +2 -1
- package/dist/login-window-lock.js.map +1 -1
- package/dist/ls-rows.d.ts +1 -1
- package/dist/ls-rows.js +1 -1
- package/dist/ls-rows.js.map +1 -1
- package/dist/machine-accounts.d.ts +110 -0
- package/dist/machine-accounts.js +229 -0
- package/dist/machine-accounts.js.map +1 -0
- package/dist/machine-signins.d.ts +89 -0
- package/dist/machine-signins.js +182 -0
- package/dist/machine-signins.js.map +1 -0
- package/dist/muse-usage-relay.d.ts +2 -0
- package/dist/muse-usage-relay.js +5 -3
- package/dist/muse-usage-relay.js.map +1 -1
- package/dist/needs-you-hub.d.ts +3 -0
- package/dist/needs-you-hub.js +13 -3
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +35 -2
- package/dist/needs-you.js +19 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/quickstart.js +7 -18
- package/dist/quickstart.js.map +1 -1
- package/dist/quiet-run.d.ts +31 -0
- package/dist/quiet-run.js +50 -0
- package/dist/quiet-run.js.map +1 -0
- package/dist/quota-notice-config.d.ts +22 -0
- package/dist/quota-notice-config.js +41 -0
- package/dist/quota-notice-config.js.map +1 -0
- package/dist/runtime-api.d.ts +13 -0
- package/dist/runtime-api.js +134 -2
- package/dist/runtime-api.js.map +1 -1
- package/dist/runtime-build-info.d.ts +2 -1
- package/dist/runtime-build-info.js +7 -3
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli-install.d.ts +153 -0
- package/dist/runtime-cli-install.js +675 -0
- package/dist/runtime-cli-install.js.map +1 -0
- package/dist/runtime-cli.js +157 -12
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client.d.ts +64 -2
- package/dist/runtime-client.js +277 -20
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +10 -1
- package/dist/runtime-coordinator.js +93 -2
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-credential-profiles.d.ts +11 -2
- package/dist/runtime-credential-profiles.js +28 -4
- package/dist/runtime-credential-profiles.js.map +1 -1
- package/dist/runtime-install.js +9 -6
- package/dist/runtime-install.js.map +1 -1
- package/dist/runtime-pane-link.js +2 -1
- package/dist/runtime-pane-link.js.map +1 -1
- package/dist/runtime-pane-service.js +2 -2
- package/dist/runtime-pane-service.js.map +1 -1
- package/dist/runtime-pane-store.d.ts +10 -0
- package/dist/runtime-pane-store.js +13 -1
- package/dist/runtime-pane-store.js.map +1 -1
- package/dist/runtime-profile-ownership.d.ts +66 -0
- package/dist/runtime-profile-ownership.js +391 -0
- package/dist/runtime-profile-ownership.js.map +1 -0
- package/dist/runtime-protocol.d.ts +88 -2
- package/dist/runtime-protocol.js +40 -0
- package/dist/runtime-protocol.js.map +1 -1
- package/dist/runtime-remote-accounts.d.ts +197 -0
- package/dist/runtime-remote-accounts.js +663 -0
- package/dist/runtime-remote-accounts.js.map +1 -0
- package/dist/runtime-remote-setup.d.ts +105 -0
- package/dist/runtime-remote-setup.js +529 -0
- package/dist/runtime-remote-setup.js.map +1 -0
- package/dist/runtime-signin-transport.d.ts +39 -0
- package/dist/runtime-signin-transport.js +110 -0
- package/dist/runtime-signin-transport.js.map +1 -0
- package/dist/runtime-signin.d.ts +132 -0
- package/dist/runtime-signin.js +289 -0
- package/dist/runtime-signin.js.map +1 -0
- package/dist/runtime-update-attention.d.ts +4 -0
- package/dist/runtime-update-attention.js +11 -0
- package/dist/runtime-update-attention.js.map +1 -0
- package/dist/runtime-update-controller.d.ts +75 -0
- package/dist/runtime-update-controller.js +691 -0
- package/dist/runtime-update-controller.js.map +1 -0
- package/dist/runtime-update-ipc.d.ts +42 -0
- package/dist/runtime-update-ipc.js +144 -0
- package/dist/runtime-update-ipc.js.map +1 -0
- package/dist/runtime-update-journal.d.ts +5 -0
- package/dist/runtime-update-journal.js +7 -0
- package/dist/runtime-update-journal.js.map +1 -1
- package/dist/runtime-update-lock.js +17 -2
- package/dist/runtime-update-lock.js.map +1 -1
- package/dist/runtime-update-status.d.ts +30 -0
- package/dist/runtime-update-status.js +31 -0
- package/dist/runtime-update-status.js.map +1 -0
- package/dist/settings-api.js +6 -2
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +10 -0
- package/dist/settings-change.js +25 -1
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +25 -1
- package/dist/settings-confirmation.js +11 -3
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.js +18 -6
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +21 -0
- package/dist/settings-http-confirmation.js +74 -3
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-instance-patch.js +1 -1
- package/dist/settings-instance-patch.js.map +1 -1
- package/dist/setup-wizard.js +3 -5
- package/dist/setup-wizard.js.map +1 -1
- package/dist/signin-keepalive.d.ts +203 -0
- package/dist/signin-keepalive.js +652 -0
- package/dist/signin-keepalive.js.map +1 -0
- package/dist/structured-signin-transport.js +4 -0
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/structured-signin.d.ts +7 -0
- package/dist/structured-signin.js +4 -2
- package/dist/structured-signin.js.map +1 -1
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/tmux-binary.d.ts +23 -23
- package/dist/tmux-binary.js +35 -46
- package/dist/tmux-binary.js.map +1 -1
- package/dist/tmux-exec-helper.js +3 -3
- package/dist/tmux-exec-helper.js.map +1 -1
- package/dist/tmux-legacy.d.ts +94 -0
- package/dist/tmux-legacy.js +309 -0
- package/dist/tmux-legacy.js.map +1 -0
- package/dist/tmux-manager.d.ts +7 -1
- package/dist/tmux-manager.js +21 -11
- package/dist/tmux-manager.js.map +1 -1
- package/dist/tmux-rollback.d.ts +31 -0
- package/dist/tmux-rollback.js +72 -0
- package/dist/tmux-rollback.js.map +1 -0
- package/dist/tmux-server.d.ts +102 -0
- package/dist/tmux-server.js +248 -0
- package/dist/tmux-server.js.map +1 -0
- package/dist/transcript-monitor.js +43 -5
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-records.d.ts +2 -1
- package/dist/transcript-records.js +3 -0
- package/dist/transcript-records.js.map +1 -1
- package/dist/transcript-sources.js +3 -0
- package/dist/transcript-sources.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/accounts-keepalive.js +113 -0
- package/dist/ui/accounts-manage.js +237 -0
- package/dist/ui/accounts-view.js +191 -36
- package/dist/ui/agent-runtime-settings.js +2 -1
- package/dist/ui/app.html +8 -1
- package/dist/ui/backend-signin.js +12 -3
- package/dist/ui/general-location.js +28 -14
- package/dist/ui/hub-attachments.js +90 -0
- package/dist/ui/hub-chat-store.js +11 -5
- package/dist/ui/hub-client.js +20 -1
- package/dist/ui/hub-grant-strings.js +13 -0
- package/dist/ui/hub-owner-strings.js +6 -2
- package/dist/ui/hub-preview.js +101 -0
- package/dist/ui/hub-strings.js +4 -2
- package/dist/ui/machine-signin.js +56 -0
- package/dist/ui/panel-fleet.js +1 -1
- package/dist/ui/panel-hub.js +194 -54
- package/dist/ui/panel-log.js +2 -2
- package/dist/ui/panel-needs.js +14 -8
- package/dist/ui/panel-notices.js +4 -3
- package/dist/ui/panel-runtimes.js +32 -11
- package/dist/ui/panel-settings.js +18 -24
- package/dist/ui/panel-windows-agent.js +2 -1
- package/dist/ui/preview-pages.js +3 -41
- package/dist/ui/preview-panel-actions.js +3 -161
- package/dist/ui/preview-panel.js +10 -557
- package/dist/ui/preview-versions.js +3 -155
- package/dist/ui/runtime-cli-install.js +134 -0
- package/dist/ui/runtime-update-commands.d.ts +2 -0
- package/dist/ui/runtime-update-commands.js +11 -0
- package/dist/ui/runtime-update-status.js +53 -0
- package/dist/ui/search-dialog.js +3 -2
- package/dist/ui/settings-confirm.js +28 -0
- package/dist/ui/settings-devices.js +6 -10
- package/dist/ui/settings-guests.js +3 -2
- package/dist/ui/settings-hub-browser-certificate.js +2 -0
- package/dist/ui/settings-hub-membership.js +17 -11
- package/dist/ui/settings-hub-retention.js +2 -0
- package/dist/ui/settings-hub-section.js +35 -0
- package/dist/ui/settings-hub.js +17 -5
- package/dist/ui/settings-layout.js +6 -2
- package/dist/ui/settings-named-test.js +2 -2
- package/dist/ui/settings-outside.js +1 -1
- package/dist/ui/settings-quota-notice.js +102 -0
- package/dist/ui/settings-registry.js +4 -0
- package/dist/ui/settings-strings.js +6 -6
- package/dist/ui/settings-web-authority.js +2 -1
- package/dist/ui/shared/accounts-keepalive.css +7 -0
- package/dist/ui/shared/accounts.css +13 -0
- package/dist/ui/shared/app-i18n.js +4 -2
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app-shell.js +111 -8
- package/dist/ui/shared/app-store.js +2 -2
- package/dist/ui/shared/app.css +29 -0
- package/dist/ui/shared/app.js +2 -1
- package/dist/ui/shared/chat-strings.js +8 -8
- package/dist/ui/shared/hub-chat.css +1 -0
- package/dist/ui/shared/hub-owner.css +3 -3
- package/dist/ui/shared/hub-signin.css +24 -0
- package/dist/ui/shared/loading.css +37 -0
- package/dist/ui/shared/preview-pages.js +41 -0
- package/dist/ui/shared/preview-panel-actions.js +168 -0
- package/dist/ui/shared/preview-panel.js +565 -0
- package/dist/ui/shared/preview-versions.js +155 -0
- package/dist/ui/shared/runtime-install.css +4 -0
- package/dist/ui/shared/signin.js +68 -6
- package/dist/ui/shared/ui-states.js +14 -3
- package/dist/ui/shared/view-strings.js +4 -4
- package/dist/ui/shared/workspace-follow.css +19 -0
- package/dist/ui/signin.html +7 -3
- package/dist/ui/structured-signin.js +43 -11
- package/dist/ui/workspace-follow-strings.js +28 -0
- package/dist/ui/workspace-panel.js +225 -36
- package/dist/update-install.d.ts +7 -0
- package/dist/update-install.js +23 -0
- package/dist/update-install.js.map +1 -1
- package/dist/usage/providers.d.ts +6 -0
- package/dist/usage/providers.js +18 -9
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/quota-notices.d.ts +38 -0
- package/dist/usage/quota-notices.js +160 -0
- package/dist/usage/quota-notices.js.map +1 -0
- package/dist/usage/usage-api.d.ts +1 -0
- package/dist/usage/usage-api.js +16 -0
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +38 -0
- package/dist/web-api.js +357 -14
- package/dist/web-api.js.map +1 -1
- package/dist/web-login.d.ts +35 -1
- package/dist/web-login.js +51 -5
- package/dist/web-login.js.map +1 -1
- package/dist/web-remote-access.d.ts +6 -0
- package/dist/web-remote-access.js +10 -1
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-session.d.ts +11 -0
- package/dist/web-session.js +38 -1
- package/dist/web-session.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +1 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-signin-link.d.ts +42 -0
- package/dist/web-signin-link.js +110 -0
- package/dist/web-signin-link.js.map +1 -0
- package/dist/windows-cli-api.d.ts +14 -0
- package/dist/windows-cli-api.js +21 -0
- package/dist/windows-cli-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +3 -1
- package/dist/windows-cli-worker.js +18 -3
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/workspace-follow-parse.d.ts +36 -0
- package/dist/workspace-follow-parse.js +208 -0
- package/dist/workspace-follow-parse.js.map +1 -0
- package/dist/workspace-follow-records.d.ts +17 -0
- package/dist/workspace-follow-records.js +88 -0
- package/dist/workspace-follow-records.js.map +1 -0
- package/dist/workspace-follow.d.ts +41 -0
- package/dist/workspace-follow.js +143 -0
- package/dist/workspace-follow.js.map +1 -0
- package/dist/wsl-detect.d.ts +1 -0
- package/dist/wsl-detect.js +20 -0
- package/dist/wsl-detect.js.map +1 -0
- package/launcher/tmux-bundle.cjs +26 -10
- package/package.json +7 -2
- package/templates/runtime-install/install.ps1 +154 -13
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
// #1481: an agent's HTML preview (#1306) in a panel beside the conversation — a split with a draggable divider on a
|
|
2
|
+
// wide screen, a full-screen sheet on a narrow one. Nothing about the preview itself changes here: the frame is the one
|
|
3
|
+
// preview.js makes (mountPreview: the preview origin, sandbox allow-scripts only), started by AgendPreview.start like a
|
|
4
|
+
// card's, only told to fill the panel. It runs on a person's click, as a card's does — and "Open in panel" is that click:
|
|
5
|
+
// - on an idle card it opens the panel and starts the preview there, as if Preview were clicked in the panel (#1704);
|
|
6
|
+
// a device that has not allowed previews gets the "Allow previews" offer instead, and allowing it starts the run;
|
|
7
|
+
// where previews cannot run (web.preview: false, a public link), the panel opens with nothing running;
|
|
8
|
+
// - on a card whose preview is running, the same button moves that run to the panel (stopped in the card, started in
|
|
9
|
+
// the panel: a moved frame reloads anyway);
|
|
10
|
+
// - nothing runs by itself: not when the page loads, not when the panel is shown again, and a newer version of the
|
|
11
|
+
// block in a later reply is offered, never swapped in, and shown with Preview to click.
|
|
12
|
+
// Closing the panel or leaving the chat stops its frame; one preview per page still holds (start() stops any other).
|
|
13
|
+
import { html, useEffect, useRef, useState } from "/assets/app-html.js";
|
|
14
|
+
import { t } from "/assets/app-i18n.js";
|
|
15
|
+
import { Icon } from "/assets/ui-icons.js";
|
|
16
|
+
import { Skeleton } from "/assets/ui-states.js";
|
|
17
|
+
import "/assets/chat-render.js";
|
|
18
|
+
import "/assets/preview.js";
|
|
19
|
+
import { loadHtmlAttachment } from "/assets/html-attachment.js";
|
|
20
|
+
import { chatTime, onDayChange } from "/assets/chat-time.js";
|
|
21
|
+
import { PanelActions } from "./preview-panel-actions.js";
|
|
22
|
+
import { htmlTitle, versionsOf, lineDiff, diffHunks, DIFF_LIMITS } from "./preview-versions.js";
|
|
23
|
+
import { pagesOf, pageIdOf } from "./preview-pages.js";
|
|
24
|
+
import { drawMarkdown, TEXT_CARD_MAX } from "/assets/chat-thread.js";
|
|
25
|
+
import "/assets/chat-md-strings.js"; // M-2448: the Markdown panel's own words (an older cached chat-strings.js lacks them)
|
|
26
|
+
|
|
27
|
+
export { htmlTitle };
|
|
28
|
+
|
|
29
|
+
const R = () => globalThis.AgendChatRender;
|
|
30
|
+
const P = () => globalThis.AgendPreview;
|
|
31
|
+
|
|
32
|
+
// ── The panel's state, one per page (the chat shows one instance at a time) ──
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* open: { key, instance, msgKey, n | att, code, sender, ts } | null (`att`: an attached .html file, #1306 Q4);
|
|
36
|
+
* run: start it on mount — the card's click, as a token no later open ever reuses (0: nothing to run).
|
|
37
|
+
*/
|
|
38
|
+
let state = { open: null, run: 0 };
|
|
39
|
+
let runs = 0, version = 0, claims = 0;
|
|
40
|
+
const subs = new Set();
|
|
41
|
+
function set(next) { state = next; version++; for (const fn of [...subs]) { try { fn(state); } catch { /* one listener's error stops no other */ } } }
|
|
42
|
+
/**
|
|
43
|
+
* Hub E (#3226): the fleet's Files & changes view (workspace-panel.js) is the fleet's only — never served to the Hub, and
|
|
44
|
+
* never shown to an asker. The fleet registers it (its /ui/js/preview-panel.js); without it a workspace panel shows nothing.
|
|
45
|
+
*/
|
|
46
|
+
let WorkspaceView = null;
|
|
47
|
+
export function setWorkspaceView(component) { WorkspaceView = component || null; }
|
|
48
|
+
export const panelStore = { get: () => state, subscribe(fn) { subs.add(fn); return () => { subs.delete(fn); }; } };
|
|
49
|
+
/** Moves on every open and close, and on every claim: what a card's click compares when its HTML arrives late. */
|
|
50
|
+
export const panelVersion = () => version;
|
|
51
|
+
/** A click that will show something in the panel (an attachment's HTML still to read): from now on it is the newest —
|
|
52
|
+
* any earlier click still reading is dropped when its answer comes. Returns the version the click owns. */
|
|
53
|
+
export function claimPanel() { claims++; return ++version; }
|
|
54
|
+
/** How many clicks have claimed: an inline Preview still reading asks only whether a newer click came (not a close). */
|
|
55
|
+
export const panelClaims = () => claims;
|
|
56
|
+
|
|
57
|
+
/** The frame's key in preview.js: its own, so the card that opened it keeps its own state. */
|
|
58
|
+
export const frameKey = (key) => `panel:${key}`;
|
|
59
|
+
/** Show `spec` in the panel; `run`: start it there (the card's "Open in panel" click). The block shown before stops. */
|
|
60
|
+
function retire(open) {
|
|
61
|
+
if (!open) return;
|
|
62
|
+
if (P()) P().stop(frameKey(open.key), "stopped", "");
|
|
63
|
+
}
|
|
64
|
+
export function openPanel(spec, { run = false } = {}) {
|
|
65
|
+
const old = state.open;
|
|
66
|
+
set({ open: { ...spec, kind: "html" }, run: run ? ++runs : 0 });
|
|
67
|
+
retire(old); // State changes first: cleanup reentry cannot close a newer panel.
|
|
68
|
+
}
|
|
69
|
+
/** #3153 P1: an agent's Files / Changes in the panel — `spec`: { key, instance } (read-only; nothing runs). */
|
|
70
|
+
export function openWorkspace(spec) {
|
|
71
|
+
const old = state.open;
|
|
72
|
+
set({ open: { ...spec, kind: "workspace" }, run: 0 });
|
|
73
|
+
retire(old);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* M-2448: show a Markdown file in the panel — `spec`: { key, instance, msgKey, att: { id, name, size }, sender, ts,
|
|
78
|
+
* text? } (text: what the card's Show already read). Nothing runs: it is rendered by the chat's own Markdown renderer.
|
|
79
|
+
* The block shown before stops, as for any open.
|
|
80
|
+
*/
|
|
81
|
+
export function openMarkdown(spec) {
|
|
82
|
+
const old = state.open;
|
|
83
|
+
set({ open: { ...spec, kind: "md" }, run: 0 });
|
|
84
|
+
retire(old);
|
|
85
|
+
}
|
|
86
|
+
/** Close publishes the empty slot before old-owner callbacks can reenter. */
|
|
87
|
+
export function closePanel() {
|
|
88
|
+
const old = state.open; if (!old) return;
|
|
89
|
+
set({ open: null, run: 0 }); retire(old);
|
|
90
|
+
}
|
|
91
|
+
/** The card key the panel shows, or null. */
|
|
92
|
+
export const shownKey = () => (state.open ? state.open.key : null);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A newer version of the shown block: the last complete ```html block in an agent reply after the one it came from.
|
|
96
|
+
* When the shown block has a <title>, only a block with the same title counts (another page is not a new version);
|
|
97
|
+
* without one, the newest block does. `msgs` in order; `keyOf` makes a message's key.
|
|
98
|
+
*/
|
|
99
|
+
export function newerVersion(open, msgs, keyOf) {
|
|
100
|
+
if (!open || !Array.isArray(msgs)) return null;
|
|
101
|
+
const at = msgs.findIndex(x => keyOf(x) === open.msgKey);
|
|
102
|
+
if (at < 0) return null;
|
|
103
|
+
// An attached file: a later agent reply attaching a file of the same name is its newer version. Its HTML is read
|
|
104
|
+
// when the person picks it (code: null here), as on a card.
|
|
105
|
+
if (open.att) {
|
|
106
|
+
const name = String(open.att.name || "").trim().toLowerCase();
|
|
107
|
+
for (let i = msgs.length - 1; i > at; i--) {
|
|
108
|
+
const x = msgs[i];
|
|
109
|
+
if (x.role !== "agent" || !Array.isArray(x.attachments)) continue;
|
|
110
|
+
for (let k = x.attachments.length - 1; k >= 0; k--) {
|
|
111
|
+
const a = x.attachments[k];
|
|
112
|
+
if (!R().isHtmlAttachment(a) || a.name.trim().toLowerCase() !== name) continue;
|
|
113
|
+
const msgKey = keyOf(x);
|
|
114
|
+
return { key: `${msgKey}:a${a.id}`, instance: open.instance, msgKey, att: { id: a.id, name: a.name, size: a.size }, code: null, sender: x.sender, ts: x.ts };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const title = htmlTitle(open.code);
|
|
120
|
+
for (let i = msgs.length - 1; i > at; i--) {
|
|
121
|
+
const x = msgs[i];
|
|
122
|
+
if (x.role !== "agent") continue;
|
|
123
|
+
const fences = R().htmlFences(x.text);
|
|
124
|
+
for (let n = fences.length - 1; n >= 0; n--) {
|
|
125
|
+
const f = fences[n];
|
|
126
|
+
if (!f.terminated || (title && htmlTitle(f.code) !== title)) continue;
|
|
127
|
+
const msgKey = keyOf(x);
|
|
128
|
+
return { key: `${msgKey}:f${n}`, instance: open.instance, msgKey, n, code: f.code, sender: x.sender, ts: x.ts };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ── The panel's width: this device's choice (a convenience — the panel works without storage) ──
|
|
135
|
+
|
|
136
|
+
const WIDTH_KEY = "agend_preview_panel_w";
|
|
137
|
+
export const MIN_PANEL = 320, MIN_THREAD = 360, STEP = 32;
|
|
138
|
+
function storedWidth() { try { const v = Number(localStorage.getItem(WIDTH_KEY)); return Number.isFinite(v) && v > 0 ? v : null; } catch { return null; } }
|
|
139
|
+
function storeWidth(w) { try { localStorage.setItem(WIDTH_KEY, String(Math.round(w))); } catch { /* this page only */ } }
|
|
140
|
+
/** The width a panel may have in a split `total` px wide: at least MIN_PANEL, leaving the thread MIN_THREAD. */
|
|
141
|
+
export function clampWidth(w, total) {
|
|
142
|
+
const max = Math.max(MIN_PANEL, total - MIN_THREAD - 8);
|
|
143
|
+
return Math.round(Math.min(max, Math.max(MIN_PANEL, w)));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ── #2911 (7): a CDN library the preview blocked (web.preview_cdn off) — the panel says where to allow it ──
|
|
147
|
+
|
|
148
|
+
/** web-preview.ts PREVIEW_CDN_SOURCES (a test keeps the two equal): what web.preview_cdn allows. */
|
|
149
|
+
export const CDN_PREFIXES = ["https://cdnjs.cloudflare.com/ajax/libs/", "https://cdn.jsdelivr.net/npm/"];
|
|
150
|
+
/** The CDN host of the first blocked library in a frame's error log that the setting would allow, or null. */
|
|
151
|
+
export function blockedCdnHost(log) {
|
|
152
|
+
for (const x of (log && log.items) || []) {
|
|
153
|
+
if (x.kind !== "blocked") continue;
|
|
154
|
+
const p = CDN_PREFIXES.find(pre => String(x.message).startsWith(pre));
|
|
155
|
+
if (p) return new URL(p).host;
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ── #2911 (2): the page's width in the panel (a phone, a tablet, or the panel's own), this device's choice ──
|
|
161
|
+
|
|
162
|
+
const DEVICE_KEY = "agend_preview_panel_device";
|
|
163
|
+
/** The widths a preview can be shown at: CSS px, or null for the panel's full width. */
|
|
164
|
+
export const DEVICE_WIDTHS = { full: null, tablet: 768, phone: 390 };
|
|
165
|
+
export function storedDevice() { try { const v = localStorage.getItem(DEVICE_KEY); return Object.hasOwn(DEVICE_WIDTHS, v) ? v : "full"; } catch { return "full"; } }
|
|
166
|
+
function storeDevice(v) { try { localStorage.setItem(DEVICE_KEY, v); } catch { /* this page only */ } }
|
|
167
|
+
/** The element the page has fullscreen (standard, else webkit's), or null. */
|
|
168
|
+
const fullscreenEl = () => { const d = globalThis.document; return (d && (d.fullscreenElement || d.webkitFullscreenElement)) || null; };
|
|
169
|
+
|
|
170
|
+
/** #1770: as the thread shows it — the fleet's zone, with the day when it is not today. */
|
|
171
|
+
const timeOf = (ts) => (ts ? chatTime(ts, { yesterday: (hm) => t("chat.yesterdayAt", hm) }) : "");
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The panel, inside the chat's split (`split`: that element — the divider sets its width there, through CSSOM).
|
|
175
|
+
* props: name (the instance), msgs() → its messages, subscribe(fn) → unsubscribe (the chat store's), keyOf(x),
|
|
176
|
+
* reveal(msgKey) (the thread shows that message), download(code).
|
|
177
|
+
*/
|
|
178
|
+
/** allow(commit): this device's opt-in through the chat's one path (setPreviewOptIn: the confirm, then commit(setOptIn)) → the choice. */
|
|
179
|
+
export function PreviewPanel({ name, split, msgs, subscribe, keyOf, reveal, download, allow }) {
|
|
180
|
+
const [st, setSt] = useState(state);
|
|
181
|
+
const [view, setView] = useState("preview");
|
|
182
|
+
const [run, setRun] = useState({ state: "idle", reason: "" });
|
|
183
|
+
const [newer, setNewer] = useState(null);
|
|
184
|
+
const [newerNote, setNewerNote] = useState("");
|
|
185
|
+
const [vers, setVers] = useState({ list: [], index: -1 }); // #2911 (1): the shown block's versions in the thread
|
|
186
|
+
const [pages, setPages] = useState([]); // #2911 (6): every page in the thread, newest first
|
|
187
|
+
const [cdnHost, setCdnHost] = useState(null); // #2911 (7): a CDN library this page's run was refused
|
|
188
|
+
const [listing, setListing] = useState(false); // the page list is on screen (instead of the page)
|
|
189
|
+
const [changes, setChanges] = useState(null); // the Changes view: { state, from, hunks, shown, total }
|
|
190
|
+
const keepView = useRef(false); // a version step keeps Code / Changes on screen
|
|
191
|
+
const loaded = useRef(new Map()); // an attached version's HTML, read once (key → code)
|
|
192
|
+
const reading = useRef(null); // the newer version whose file is being read (one at a time)
|
|
193
|
+
const pending = useRef(0); // #1704: the card's click, waiting for this device's Allow (the st.run it came with)
|
|
194
|
+
const ownAllow = useRef(0); // while this panel's own Allow commits its choice: the click it answers (not cancelled by it)
|
|
195
|
+
const holder = useRef(null), divider = useRef(null), panel = useRef(null);
|
|
196
|
+
const [device, setDeviceState] = useState(storedDevice); // #2911 (2): the page's width
|
|
197
|
+
const setDevice = (v) => { setDeviceState(v); storeDevice(v); };
|
|
198
|
+
// Full screen: the Fullscreen API on the panel (the dashboard's document — the frame's own policy still denies it),
|
|
199
|
+
// or, where the page may not, the panel over the whole window ("immersive"). Esc leaves it before it closes the panel.
|
|
200
|
+
const [fs, setFs] = useState("");
|
|
201
|
+
const fsTarget = useRef(null); // the element asked to go full screen (the panel may be gone when it is left)
|
|
202
|
+
// #2918 review: each request has a generation; leaving (Esc, the button, a close, the chat unmounting) moves it, so a
|
|
203
|
+
// request still pending answers nobody — a late refusal does not make a later open immersive, and a late success
|
|
204
|
+
// only takes back the full screen it made.
|
|
205
|
+
const fsGen = useRef(0);
|
|
206
|
+
const exitOwn = (el) => {
|
|
207
|
+
const d = globalThis.document;
|
|
208
|
+
if (!d || !el || fullscreenEl() !== el) return;
|
|
209
|
+
const ex = d.exitFullscreen || d.webkitExitFullscreen;
|
|
210
|
+
try { const r = typeof ex === "function" ? ex.call(d) : null; if (r && typeof r.catch === "function") r.catch(() => {}); } catch { /* already out */ }
|
|
211
|
+
};
|
|
212
|
+
const enterFs = () => {
|
|
213
|
+
const el = panel.current, d = globalThis.document; if (!el || fs) return;
|
|
214
|
+
const gen = ++fsGen.current;
|
|
215
|
+
const req = el.requestFullscreen || el.webkitRequestFullscreen;
|
|
216
|
+
const enabled = d ? (d.fullscreenEnabled ?? d.webkitFullscreenEnabled) : false;
|
|
217
|
+
if (typeof req !== "function" || enabled === false) { setFs("immersive"); return; }
|
|
218
|
+
let r;
|
|
219
|
+
fsTarget.current = el;
|
|
220
|
+
try { r = req.call(el); } catch { fsTarget.current = null; setFs("immersive"); return; }
|
|
221
|
+
if (r && typeof r.then === "function") {
|
|
222
|
+
r.then(() => { if (fsGen.current === gen) { if (fullscreenEl() === el) setFs("native"); } else exitOwn(el); },
|
|
223
|
+
() => { if (fsGen.current === gen) { fsTarget.current = null; setFs("immersive"); } });
|
|
224
|
+
} else setFs("native");
|
|
225
|
+
};
|
|
226
|
+
function leaveFs() {
|
|
227
|
+
fsGen.current++;
|
|
228
|
+
const el = fsTarget.current; fsTarget.current = null;
|
|
229
|
+
exitOwn(el);
|
|
230
|
+
setFs("");
|
|
231
|
+
}
|
|
232
|
+
const open = st.open?.instance === name ? st.open : null;
|
|
233
|
+
|
|
234
|
+
useEffect(() => panelStore.subscribe(setSt), []);
|
|
235
|
+
// This device's choice (here or in another tab) decides whether Preview is offered: re-read it when it changes.
|
|
236
|
+
// A click waiting for Allow is cancelled by any other change of that choice (Never, a card's menu, another tab):
|
|
237
|
+
// after it, running needs a new click — only this panel's own Allow runs the click it was offered for.
|
|
238
|
+
const [, choice] = useState(0);
|
|
239
|
+
useEffect(() => (P() ? P().onChange(() => { if (pending.current && ownAllow.current !== pending.current) pending.current = 0; choice(n => n + 1); }) : undefined), []);
|
|
240
|
+
// Leaving the chat (another instance, another panel) closes the panel: its frame stops with the thread's.
|
|
241
|
+
useEffect(() => () => closePanel(), []);
|
|
242
|
+
// Leaving the chat: a pending request answers nobody, and our own full screen is taken back.
|
|
243
|
+
useEffect(() => () => { fsGen.current++; exitOwn(fsTarget.current); fsTarget.current = null; }, []);
|
|
244
|
+
// Full screen ends with the browser's own Esc or its exit control too: follow it.
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
const d = globalThis.document; if (!d || !d.addEventListener) return undefined;
|
|
247
|
+
const sync = () => setFs(f => (f === "native" && fullscreenEl() !== fsTarget.current ? "" : f));
|
|
248
|
+
d.addEventListener("fullscreenchange", sync); d.addEventListener("webkitfullscreenchange", sync);
|
|
249
|
+
return () => { d.removeEventListener("fullscreenchange", sync); d.removeEventListener("webkitfullscreenchange", sync); };
|
|
250
|
+
}, []);
|
|
251
|
+
// #1770: the source and newer-version labels say the day as the thread does — drawn again when the fleet's day
|
|
252
|
+
// changes, while a block is open. A render: the frame and the run are left as they are.
|
|
253
|
+
const [, dayTick] = useState(0);
|
|
254
|
+
useEffect(() => (open ? onDayChange(() => dayTick(n => n + 1)) : undefined), [!!open]);
|
|
255
|
+
|
|
256
|
+
// #2863: "large" — over 8 MB, nothing runs until "Preview anyway" (or the card's, which opened it with `anyway`).
|
|
257
|
+
const ui = { state: (s, reason) => setRun({ state: s === "starting" || s === "running" || s === "large" ? s : "idle", reason: reason || "" }) };
|
|
258
|
+
const start = (anyway) => {
|
|
259
|
+
if (!open || !holder.current) return;
|
|
260
|
+
setView("preview");
|
|
261
|
+
P().start(frameKey(open.key), holder.current, open.code, ui, anyway === true || open.anyway ? { fill: true, anyway: true } : { fill: true });
|
|
262
|
+
};
|
|
263
|
+
const stop = () => { if (open) P().stop(frameKey(open.key), "stopped", ""); };
|
|
264
|
+
// A new block in the panel: what ran before is gone (openPanel stopped it); the card's click starts it here — or,
|
|
265
|
+
// where it cannot run, waits as `pending`: only the Allow below can use it (offered to a device that has not opted
|
|
266
|
+
// in), only while the panel shows what that click opened (st.run is a token no later open reuses), and any other
|
|
267
|
+
// change of this device's choice cancels it.
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
setRun({ state: "idle", reason: "" });
|
|
270
|
+
if (!keepView.current) setView("preview");
|
|
271
|
+
setListing(false); // #2920 review: a new block on screen leaves the page list
|
|
272
|
+
keepView.current = false;
|
|
273
|
+
if (open && st.run) {
|
|
274
|
+
if (P().availability().ok) start();
|
|
275
|
+
else pending.current = st.run;
|
|
276
|
+
}
|
|
277
|
+
// Focus goes to the panel's close control that is on screen (Back on a phone, × beside the thread).
|
|
278
|
+
if (panel.current) { const f = [...panel.current.querySelectorAll(".pv-panel-close")].find(b => b.offsetParent !== null); if (f) f.focus(); }
|
|
279
|
+
}, [open && open.key, st.run]);
|
|
280
|
+
// The panel closing, or showing another instance's block: out of full screen.
|
|
281
|
+
useEffect(() => { if (!open) leaveFs(); }, [!!open]);
|
|
282
|
+
// #2911 (7): the running page's blocked CDN library, read from its error log (preview.js), kept as it changes.
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
const key = open ? frameKey(open.key) : null;
|
|
285
|
+
const read = () => setCdnHost(key && P() && typeof P().errors === "function" ? blockedCdnHost(P().errors(key)) : null);
|
|
286
|
+
read();
|
|
287
|
+
if (!key || !P() || typeof P().onErrors !== "function") return undefined;
|
|
288
|
+
return P().onErrors((k) => { if (k === key) read(); });
|
|
289
|
+
}, [open && open.key]);
|
|
290
|
+
// A later reply with a newer version of this block: offered, not swapped in.
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
setNewerNote(""); reading.current = null;
|
|
293
|
+
if (!open) { setNewer(null); return undefined; }
|
|
294
|
+
const check = () => { const all = msgs() || []; setNewer(newerVersion(open, all, keyOf)); setVers(versionsOf(open, all, keyOf)); setPages(pagesOf(all, keyOf, name)); };
|
|
295
|
+
check();
|
|
296
|
+
return subscribe((instance, kind) => { if (instance === name && kind === "msgs") check(); });
|
|
297
|
+
}, [open && open.key, name]);
|
|
298
|
+
|
|
299
|
+
// The divider: drag, or the arrow keys, Home and End; the width is this device's.
|
|
300
|
+
const widthNow = useRef(MIN_PANEL);
|
|
301
|
+
const applyWidth = (w, save) => {
|
|
302
|
+
const sp = split.current; if (!sp) return;
|
|
303
|
+
const total = sp.clientWidth || 0;
|
|
304
|
+
const v = clampWidth(w, total);
|
|
305
|
+
widthNow.current = v;
|
|
306
|
+
sp.style.setProperty("--pv-w", `${v}px`); // CSSOM: the page's CSP allows no style attribute
|
|
307
|
+
if (divider.current) { divider.current.setAttribute("aria-valuenow", String(v)); divider.current.setAttribute("aria-valuemax", String(clampWidth(Infinity, total))); }
|
|
308
|
+
if (save) storeWidth(v);
|
|
309
|
+
};
|
|
310
|
+
useEffect(() => { if (open) applyWidth(storedWidth() ?? (split.current && split.current.clientWidth || 0) / 2, false); }, [!!open]);
|
|
311
|
+
const width = () => widthNow.current;
|
|
312
|
+
const setWidth = (w) => applyWidth(w, true);
|
|
313
|
+
const onKey = (e) => {
|
|
314
|
+
const k = e.key;
|
|
315
|
+
if (k === "ArrowLeft") setWidth(width() + STEP);
|
|
316
|
+
else if (k === "ArrowRight") setWidth(width() - STEP);
|
|
317
|
+
else if (k === "Home") setWidth(Infinity);
|
|
318
|
+
else if (k === "End") setWidth(0);
|
|
319
|
+
else return;
|
|
320
|
+
e.preventDefault();
|
|
321
|
+
};
|
|
322
|
+
const onDown = (e) => {
|
|
323
|
+
const sp = split.current; if (!sp || e.button !== 0) return;
|
|
324
|
+
e.preventDefault();
|
|
325
|
+
const el = e.currentTarget;
|
|
326
|
+
try { el.setPointerCapture(e.pointerId); } catch { /* the move still works while over the divider */ }
|
|
327
|
+
sp.classList.add("resizing"); // frames take no pointer events meanwhile, or the drag would stop over one
|
|
328
|
+
const right = sp.getBoundingClientRect().right;
|
|
329
|
+
const move = (ev) => applyWidth(right - ev.clientX - 4, false);
|
|
330
|
+
const up = () => { sp.classList.remove("resizing"); storeWidth(widthNow.current); el.removeEventListener("pointermove", move); el.removeEventListener("pointerup", up); el.removeEventListener("pointercancel", up); };
|
|
331
|
+
el.addEventListener("pointermove", move);
|
|
332
|
+
el.addEventListener("pointerup", up);
|
|
333
|
+
el.addEventListener("pointercancel", up);
|
|
334
|
+
};
|
|
335
|
+
// Show another version (the newer one offered, or a step of ‹ ›): an attached file's HTML is read first. A read the
|
|
336
|
+
// panel moved on from is dropped. It is shown as Show it shows one — waiting for Preview, never started by the step.
|
|
337
|
+
const attReason = (r) => t(r.reason === "over" ? "chat.pvAttOver" : r.reason === "gone" ? "chat.pvAttGone" : "chat.pvAttFailed");
|
|
338
|
+
// #2920 review: a newer choice supersedes a read still waiting (it opens, or claims, and so moves the generation the
|
|
339
|
+
// waiting read checks) — it is never ignored because another read is pending.
|
|
340
|
+
const show = async (spec, { keep = false } = {}) => {
|
|
341
|
+
if (!spec) return;
|
|
342
|
+
const cached = spec.code == null ? loaded.current.get(spec.key) : undefined;
|
|
343
|
+
if (spec.code != null || cached != null) { keepView.current = keep; openPanel(cached != null ? { ...spec, code: cached } : spec); return; }
|
|
344
|
+
// #2915 review: the panel's generation, not just the key — a close and reopen of the same block while this read
|
|
345
|
+
// waits moves it, and the read is then dropped (claimPanel also drops any earlier click still reading).
|
|
346
|
+
const gen = claimPanel(), mine = reading.current = spec;
|
|
347
|
+
setNewerNote({ loading: true });
|
|
348
|
+
// A click on a version reads it whatever its size (up to the 50 MB ceiling); over 8 MB the panel then asks.
|
|
349
|
+
const r = await loadHtmlAttachment(spec.att, undefined, { anyway: true });
|
|
350
|
+
if (reading.current === mine) reading.current = null;
|
|
351
|
+
if (panelVersion() !== gen) return;
|
|
352
|
+
if (!r.ok) { setNewerNote(attReason(r)); return; }
|
|
353
|
+
setNewerNote("");
|
|
354
|
+
loaded.current.set(spec.key, r.code);
|
|
355
|
+
keepView.current = keep;
|
|
356
|
+
openPanel({ ...spec, code: r.code });
|
|
357
|
+
};
|
|
358
|
+
const showNewer = () => show(newer);
|
|
359
|
+
/** A view button: that view on screen — the page list, if open, gives way to it (#2920 review). */
|
|
360
|
+
const pickView = (v) => { setListing(false); setView(v); };
|
|
361
|
+
const step = (by) => { const v = vers.list[vers.index + by]; if (vers.index >= 0 && v) show(v, { keep: true }); };
|
|
362
|
+
// Changes: the previous version against this one, a line diff (bounded: DIFF_LIMITS). An attached previous version
|
|
363
|
+
// is read for it, once.
|
|
364
|
+
const prev = vers.index > 0 ? vers.list[vers.index - 1] : null;
|
|
365
|
+
// A step to the first version from Changes: nothing to compare it with, so the page is shown (Changes is kept as the
|
|
366
|
+
// choice, and comes back with the next step that has a previous version).
|
|
367
|
+
const shown = view === "changes" && !prev ? "preview" : view;
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
if (shown !== "changes" || !open) { setChanges(null); return undefined; }
|
|
370
|
+
let live = true;
|
|
371
|
+
const from = vers.index; // "Changes from v{from}" (1-based: the previous one)
|
|
372
|
+
const diff = (before) => {
|
|
373
|
+
const ops = lineDiff(before, open.code);
|
|
374
|
+
if (!ops) return { state: "big", from };
|
|
375
|
+
const hunks = diffHunks(ops);
|
|
376
|
+
let total = 0; for (const h of hunks) total += h.lines.length + 1;
|
|
377
|
+
return { state: "ready", from, hunks, total };
|
|
378
|
+
};
|
|
379
|
+
const known = prev.code != null ? prev.code : loaded.current.get(prev.key);
|
|
380
|
+
if (known != null) setChanges(diff(known));
|
|
381
|
+
else {
|
|
382
|
+
setChanges({ state: "loading", from });
|
|
383
|
+
loadHtmlAttachment(prev.att, undefined, { anyway: true }).then((r) => {
|
|
384
|
+
if (!live) return;
|
|
385
|
+
if (!r.ok) { setChanges({ state: "failed", from, reason: attReason(r) }); return; }
|
|
386
|
+
loaded.current.set(prev.key, r.code);
|
|
387
|
+
setChanges(diff(r.code));
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
return () => { live = false; };
|
|
391
|
+
}, [shown, open && open.key, prev && prev.key]);
|
|
392
|
+
// M-2448: a Markdown file's text (read once per open: the same capped, same-origin read as the chat's card) and
|
|
393
|
+
// which view shows it — rendered (the chat's Markdown renderer, which escapes first) or its source.
|
|
394
|
+
const [md, setMd] = useState(null); // { state: "loading" | "ready" | "failed", text?, reason? }
|
|
395
|
+
const [mdView, setMdView] = useState("rendered");
|
|
396
|
+
const [mdPlain, setMdPlain] = useState(false);
|
|
397
|
+
const mdBody = useRef(null);
|
|
398
|
+
const isMd = !!open && open.kind === "md";
|
|
399
|
+
useEffect(() => {
|
|
400
|
+
if (!isMd) { setMd(null); return undefined; }
|
|
401
|
+
setMdView("rendered");
|
|
402
|
+
if (typeof open.text === "string") { setMd({ state: "ready", text: open.text }); return undefined; }
|
|
403
|
+
let live = true;
|
|
404
|
+
setMd({ state: "loading" });
|
|
405
|
+
loadHtmlAttachment(open.att, undefined, { ask: TEXT_CARD_MAX, max: TEXT_CARD_MAX }).then((r) => {
|
|
406
|
+
if (!live) return;
|
|
407
|
+
setMd(r.ok ? { state: "ready", text: r.code } : { state: "failed", reason: r.reason === "over" ? t("chat.tcOver") : attReason(r) });
|
|
408
|
+
}, () => { if (live) setMd({ state: "failed", reason: t("chat.pvAttFailed") }); });
|
|
409
|
+
return () => { live = false; };
|
|
410
|
+
}, [isMd && open.key]);
|
|
411
|
+
useEffect(() => {
|
|
412
|
+
if (!isMd || !md || md.state !== "ready" || mdView !== "rendered" || !mdBody.current) return;
|
|
413
|
+
setMdPlain(drawMarkdown(mdBody.current, md.text) === "plain");
|
|
414
|
+
}, [isMd && open.key, md, mdView]);
|
|
415
|
+
const fileName = open && open.att ? open.att.name : undefined;
|
|
416
|
+
// The divider between the thread and the panel (both kinds): drag, or the arrow keys, Home and End.
|
|
417
|
+
function divider0() {
|
|
418
|
+
return html`<div data-trust="preview" class="pv-divider" ref=${divider} role="separator" aria-orientation="vertical" tabindex="0" aria-label=${t("chat.pvResize")}
|
|
419
|
+
aria-valuemin=${String(MIN_PANEL)} onKeyDown=${onKey} onPointerDown=${onDown}></div>`;
|
|
420
|
+
}
|
|
421
|
+
// Esc in the panel closes it (and is not the chat's "stop the reply").
|
|
422
|
+
const onPanelKey = (e) => {
|
|
423
|
+
if (e.key !== "Escape" || e.isComposing) return;
|
|
424
|
+
e.preventDefault();
|
|
425
|
+
if (fs) leaveFs(); else closePanel();
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
if (!open) return null;
|
|
429
|
+
if (open.kind === "workspace") return WorkspaceView ? html`${divider0()}
|
|
430
|
+
<${WorkspaceView} open=${open} name=${name} panel=${panel} fs=${fs} enterFs=${enterFs} leaveFs=${leaveFs} onKey=${onPanelKey} subscribe=${subscribe} close=${closePanel} />` : null;
|
|
431
|
+
if (isMd) return html`${divider0()}<${MarkdownPanel} open=${open} name=${name} md=${md} view=${mdView} setView=${setMdView} plain=${mdPlain}
|
|
432
|
+
body=${mdBody} panel=${panel} fs=${fs} enterFs=${enterFs} leaveFs=${leaveFs} onKey=${onPanelKey} reveal=${reveal} />`;
|
|
433
|
+
const going = run.state === "starting" || run.state === "running";
|
|
434
|
+
const a = P().availability();
|
|
435
|
+
// #1554: a device that has not allowed previews is offered the same "Allow previews" here (the same confirm). Allowing
|
|
436
|
+
// runs the block the card's click opened (#1704); otherwise Preview is then enabled — still a click. Why a run stopped
|
|
437
|
+
// (e.g. switched off in another tab) is still said first.
|
|
438
|
+
const askOptIn = !going && !a.ok && a.why === "optin" && typeof allow === "function";
|
|
439
|
+
const note = run.reason || (going ? (run.state === "starting" ? t("chat.pvStarting") : "") : a.ok ? t("chat.pvPanelIdle") : askOptIn ? t("chat.pvWhyOptinPanel") : a.reason);
|
|
440
|
+
// Allowed here: the click that opened the panel runs now — if it is still waiting (no other change of the choice
|
|
441
|
+
// cancelled it, even while the confirm was open: only the change this Allow commits is its own) and the panel still
|
|
442
|
+
// shows what it opened (the confirm is a wait: the panel may have moved on meanwhile).
|
|
443
|
+
const allowHere = async () => {
|
|
444
|
+
const want = pending.current;
|
|
445
|
+
const yes = await allow((apply) => { ownAllow.current = want; try { apply(); } finally { ownAllow.current = 0; } });
|
|
446
|
+
if (!yes) return;
|
|
447
|
+
setRun({ state: "idle", reason: "" });
|
|
448
|
+
if (want && pending.current === want && panelStore.get().run === want) start();
|
|
449
|
+
};
|
|
450
|
+
const source = t("chat.pvSource", open.sender || name, timeOf(open.ts));
|
|
451
|
+
return html`${divider0()}
|
|
452
|
+
<aside data-trust="preview" class=${`pv-panel${fs ? ` pv-fs pv-fs-${fs}` : ""}`} ref=${panel} aria-label=${t("chat.pvPanel")} onKeyDown=${onPanelKey}>
|
|
453
|
+
<div class="pv-panel-head">
|
|
454
|
+
<button type="button" class="icon-btn only-narrow pv-panel-close" title=${t("chat.pvBack")} aria-label=${t("chat.pvBack")} onClick=${closePanel}><${Icon} name="back" size=${18} /></button>
|
|
455
|
+
<div class="pv-panel-title"><strong>${t("chat.pvPanel")}</strong>
|
|
456
|
+
<button type="button" class="pv-source" title=${source} onClick=${() => { if (window.matchMedia && window.matchMedia("(max-width: 899px)").matches) closePanel(); reveal(open.msgKey); }}>${source}</button></div>
|
|
457
|
+
${pages.length > 1 ? html`<button type="button" class=${`btn btn-sm pv-pages-toggle${listing ? " on" : ""}`} aria-pressed=${listing ? "true" : "false"} title=${t("chat.pvPagesTitle")}
|
|
458
|
+
onClick=${() => setListing(v => !v)}><${Icon} name="file" size=${14} />${t("chat.pvPagesCount", pages.length)}</button>` : null}
|
|
459
|
+
<button type="button" class="icon-btn only-wide pv-panel-close" title=${t("chat.pvClose")} aria-label=${t("chat.pvClose")} onClick=${closePanel}><${Icon} name="close" size=${18} /></button>
|
|
460
|
+
</div>
|
|
461
|
+
<div class="pv-panel-bar">
|
|
462
|
+
${vers.list.length > 1 && vers.index >= 0 ? html`<div class="pv-ver" role="group" aria-label=${t("chat.pvVersions")}>
|
|
463
|
+
<button type="button" class="icon-btn pv-ver-prev" title=${t("chat.pvVerPrev")} aria-label=${t("chat.pvVerPrev")} disabled=${vers.index === 0} onClick=${() => step(-1)}><${Icon} name="prev" size=${16} /></button>
|
|
464
|
+
<span class="pv-ver-at" aria-live="polite" title=${t("chat.pvVerLong", vers.index + 1, vers.list.length)} aria-label=${t("chat.pvVerLong", vers.index + 1, vers.list.length)}>${t("chat.pvVer", vers.index + 1, vers.list.length)}</span>
|
|
465
|
+
<button type="button" class="icon-btn pv-ver-next" title=${t("chat.pvVerNext")} aria-label=${t("chat.pvVerNext")} disabled=${vers.index === vers.list.length - 1} onClick=${() => step(1)}><${Icon} name="next" size=${16} /></button>
|
|
466
|
+
</div>` : null}
|
|
467
|
+
<div class="seg-inline" role="group" aria-label=${t("chat.pvPanel")}>
|
|
468
|
+
<button type="button" class=${`btn btn-sm${shown === "preview" ? " on" : ""}`} aria-pressed=${shown === "preview" ? "true" : "false"} title=${t("chat.pvPage")} onClick=${() => pickView("preview")}><${Icon} name="eye" size=${14} /><span class="lbl">${t("chat.pvPage")}</span></button>
|
|
469
|
+
<button type="button" class=${`btn btn-sm${shown === "code" ? " on" : ""}`} aria-pressed=${shown === "code" ? "true" : "false"} title=${t("chat.pvCode")} onClick=${() => pickView("code")}><${Icon} name="code" size=${14} /><span class="lbl">${t("chat.pvCode")}</span></button>
|
|
470
|
+
${prev ? html`<button type="button" class=${`btn btn-sm pv-changes${shown === "changes" ? " on" : ""}`} aria-pressed=${shown === "changes" ? "true" : "false"} title=${t("chat.pvChanges")} onClick=${() => pickView("changes")}><${Icon} name="diff" size=${14} /><span class="lbl">${t("chat.pvChanges")}</span></button>` : null}
|
|
471
|
+
</div>
|
|
472
|
+
<span class="grow"></span>
|
|
473
|
+
${shown === "preview" ? html`<select class="pv-width" aria-label=${t("chat.pvWidth")} title=${t("chat.pvWidth")} value=${device} onChange=${(e) => setDevice(e.currentTarget.value)}>
|
|
474
|
+
<option value="full">${t("chat.pvWidthFull")}</option><option value="tablet">${t("chat.pvWidthTablet")}</option><option value="phone">${t("chat.pvWidthPhone")}</option></select>` : null}
|
|
475
|
+
${going ? html`<button type="button" class="btn btn-sm pv-panel-reload" title=${t("chat.pvReload")} onClick=${() => { stop(); start(true); }}><${Icon} name="restart" size=${14} /><span class="lbl">${t("chat.pvReload")}</span></button>
|
|
476
|
+
<button type="button" class="btn btn-sm pv-panel-stop" title=${t("chat.pvStop")} onClick=${stop}><${Icon} name="stop" size=${14} /><span class="lbl">${t("chat.pvStop")}</span></button>`
|
|
477
|
+
: run.state === "large" ? html`<button type="button" class="btn btn-sm btn-primary pv-panel-anyway" title=${t("chat.pvAnyway")} disabled=${!a.ok} onClick=${() => start(true)}><${Icon} name="play" size=${14} /><span class="lbl">${t("chat.pvAnyway")}</span></button>`
|
|
478
|
+
: html`<button type="button" class="btn btn-sm btn-primary pv-panel-run" title=${t("chat.pvPreview")} disabled=${!a.ok} onClick=${() => start()}><${Icon} name="play" size=${14} /><span class="lbl">${t("chat.pvPreview")}</span></button>`}
|
|
479
|
+
<button type="button" class=${`btn btn-sm only-wide pv-panel-fs${fs ? " on" : ""}`} aria-pressed=${fs ? "true" : "false"} title=${t(fs ? "chat.pvFsExit" : "chat.pvFs")} aria-label=${t(fs ? "chat.pvFsExit" : "chat.pvFs")}
|
|
480
|
+
onClick=${() => (fs ? leaveFs() : enterFs())}><${Icon} name=${fs ? "fullscreenexit" : "fullscreen"} size=${14} /></button>
|
|
481
|
+
<${PanelActions} open=${open} name=${name} run=${run} view=${view} />
|
|
482
|
+
<button type="button" class="btn btn-sm pv-panel-dl" title=${t("chat.pvDownload")} onClick=${() => download(open.code, fileName)}><${Icon} name="download" size=${14} /><span class="lbl">${t("chat.pvDownload")}</span></button>
|
|
483
|
+
</div>
|
|
484
|
+
${newer && newer.key !== open.key ? html`<div class="pv-newer" role="status"><span>${t("chat.pvNewer", timeOf(newer.ts))}</span>
|
|
485
|
+
<button type="button" class="btn btn-sm pv-newer-show" onClick=${showNewer}>${t("chat.pvNewerShow")}</button>${newerNote ? newerNote.loading
|
|
486
|
+
? html`<${Skeleton} variant="inline" lines=${1} label=${t("chat.pvLoading")} />` : html`<span class="pv-newer-note">${newerNote}</span>` : null}</div>` : null}
|
|
487
|
+
${newerNote && !(newer && newer.key !== open.key) ? newerNote.loading ? html`<${Skeleton} lines=${3} label=${t("chat.pvLoading")} />` : html`<div class="pv-note pv-ver-note" role="status">${newerNote}</div>` : null}
|
|
488
|
+
${going && !P().bannerAcked() ? html`<div class="pv-banner"><span class="pv-banner-text">${P().banner()}</span>
|
|
489
|
+
<button type="button" class="btn btn-sm btn-ghost pv-ack" title=${P().bannerAckTitle()} onClick=${() => P().ackBanner()}>${P().bannerAckLabel()}</button></div>` : null}
|
|
490
|
+
${cdnHost && shown === "preview" ? html`<div class="pv-note pv-cdn-note" role="status">${t("chat.pvCdnNote", cdnHost)}</div>` : null}
|
|
491
|
+
${note && shown === "preview" ? html`<div class="pv-note">${note}${askOptIn ? html` <button type="button" class="btn btn-sm pv-panel-allow" onClick=${allowHere}>${t("chat.pvAllowButton")}</button>` : null}</div>` : null}
|
|
492
|
+
<div class=${`pv-panel-body${listing || shown !== "preview" ? " show-code" : ` w-${device}`}`}>
|
|
493
|
+
<div class="pv-holder" ref=${holder}></div>
|
|
494
|
+
${listing ? html`<${PageList} pages=${pages} current=${pageIdOf(open)} pick=${(p) => { setListing(false); if (p.id !== pageIdOf(open)) show(p.latest); }} />` : null}
|
|
495
|
+
${!listing && shown === "code" ? html`<pre class="pv-code"><code>${open.code}</code></pre>` : null}
|
|
496
|
+
${!listing && shown === "changes" ? html`<${Changes} changes=${changes} />` : null}
|
|
497
|
+
</div>
|
|
498
|
+
</aside>`;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* M-2448: a Markdown file in the panel — the HTML preview's frame (head, source, close, full screen; a full-screen
|
|
503
|
+
* sheet on a phone), with Rendered / Source and Download. Nothing in the file runs: Rendered is the chat's Markdown
|
|
504
|
+
* renderer (escaped first, no raw HTML), Source is text.
|
|
505
|
+
*/
|
|
506
|
+
function MarkdownPanel({ open, name, md, view, setView, plain, body, panel, fs, enterFs, leaveFs, onKey, reveal }) {
|
|
507
|
+
const source = t("chat.pvSource", open.sender || name, timeOf(open.ts));
|
|
508
|
+
const ready = md && md.state === "ready";
|
|
509
|
+
return html`<aside data-trust="preview" class=${`pv-panel pv-md-panel${fs ? ` pv-fs pv-fs-${fs}` : ""}`} ref=${panel} aria-label=${t("chat.pvMdPanel")} onKeyDown=${onKey}>
|
|
510
|
+
<div class="pv-panel-head">
|
|
511
|
+
<button type="button" class="icon-btn only-narrow pv-panel-close" title=${t("chat.pvBack")} aria-label=${t("chat.pvBack")} onClick=${closePanel}><${Icon} name="back" size=${18} /></button>
|
|
512
|
+
<div class="pv-panel-title"><strong>${open.att ? open.att.name : t("chat.pvMdPanel")}</strong>
|
|
513
|
+
<button type="button" class="pv-source" title=${source} onClick=${() => { if (window.matchMedia && window.matchMedia("(max-width: 899px)").matches) closePanel(); reveal(open.msgKey); }}>${source}</button></div>
|
|
514
|
+
<button type="button" class="icon-btn only-wide pv-panel-close" title=${t("chat.pvClose")} aria-label=${t("chat.pvClose")} onClick=${closePanel}><${Icon} name="close" size=${18} /></button>
|
|
515
|
+
</div>
|
|
516
|
+
<div class="pv-panel-bar">
|
|
517
|
+
<div class="seg-inline" role="group" aria-label=${t("chat.pvMdPanel")}>
|
|
518
|
+
<button type="button" class=${`btn btn-sm${view === "rendered" ? " on" : ""}`} aria-pressed=${view === "rendered" ? "true" : "false"} title=${t("chat.pvMdRendered")} onClick=${() => setView("rendered")}><${Icon} name="eye" size=${14} /><span class="lbl">${t("chat.pvMdRendered")}</span></button>
|
|
519
|
+
<button type="button" class=${`btn btn-sm${view === "source" ? " on" : ""}`} aria-pressed=${view === "source" ? "true" : "false"} title=${t("chat.pvMdSource")} onClick=${() => setView("source")}><${Icon} name="code" size=${14} /><span class="lbl">${t("chat.pvMdSource")}</span></button>
|
|
520
|
+
</div>
|
|
521
|
+
<span class="grow"></span>
|
|
522
|
+
<button type="button" class=${`btn btn-sm only-wide pv-panel-fs${fs ? " on" : ""}`} aria-pressed=${fs ? "true" : "false"} title=${t(fs ? "chat.pvFsExit" : "chat.pvFs")} aria-label=${t(fs ? "chat.pvFsExit" : "chat.pvFs")}
|
|
523
|
+
onClick=${() => (fs ? leaveFs() : enterFs())}><${Icon} name=${fs ? "fullscreenexit" : "fullscreen"} size=${14} /></button>
|
|
524
|
+
${open.att ? html`<a class="btn btn-sm pv-panel-dl" href=${`/ui/file/${open.att.id}`} download=${open.att.name} title=${t("chat.pvDownload")}><${Icon} name="download" size=${14} /><span class="lbl">${t("chat.pvDownload")}</span></a>` : null}
|
|
525
|
+
</div>
|
|
526
|
+
${md && md.state === "loading" ? html`<${Skeleton} lines=${8} label=${t("chat.pvLoading")} />` : null}
|
|
527
|
+
${md && md.state === "failed" ? html`<div class="pv-note" role="alert">${md.reason}</div>` : null}
|
|
528
|
+
${ready && view === "rendered" && plain ? html`<div class="pv-note" role="status">${t("chat.tcPlain")}</div>` : null}
|
|
529
|
+
<div class="pv-panel-body show-code">
|
|
530
|
+
${ready && view === "rendered" ? html`<div class="pv-code pv-md" ref=${body}></div>` : null}
|
|
531
|
+
${ready && view === "source" ? html`<pre class="pv-code"><code>${md.text}</code></pre>` : null}
|
|
532
|
+
</div>
|
|
533
|
+
</aside>`;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** The Changes view: hunks of the line diff as a unified diff shows them, drawn as text (never as HTML). */
|
|
537
|
+
function Changes({ changes }) {
|
|
538
|
+
if (!changes || changes.state === "loading") return html`<${Skeleton} lines=${8} label=${t("chat.pvLoading")} />`;
|
|
539
|
+
if (changes.state === "failed") return html`<div class="pv-note pv-diff-note">${changes.reason}</div>`;
|
|
540
|
+
if (changes.state === "big") return html`<div class="pv-note pv-diff-note">${t("chat.pvChangesBig")}</div>`;
|
|
541
|
+
if (!changes.hunks.length) return html`<div class="pv-note pv-diff-note">${t("chat.pvChangesNone", changes.from)}</div>`;
|
|
542
|
+
const rows = [];
|
|
543
|
+
let left = DIFF_LIMITS.maxLines;
|
|
544
|
+
for (const h of changes.hunks) {
|
|
545
|
+
if (left <= 0) break;
|
|
546
|
+
rows.push(html`<span class="d-hunk">${`@@ -${h.oldStart},${h.oldLines} +${h.newStart},${h.newLines} @@\n`}</span>`);
|
|
547
|
+
left--;
|
|
548
|
+
for (const l of h.lines) {
|
|
549
|
+
if (left-- <= 0) break;
|
|
550
|
+
rows.push(html`<span class=${l.t === "+" ? "d-add" : l.t === "-" ? "d-del" : "d-ctx"}>${`${l.t} ${l.text}\n`}</span>`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return html`<div class="pv-diff-wrap"><div class="pv-diff-head">${t("chat.pvChangesFrom", changes.from)}${changes.total > DIFF_LIMITS.maxLines ? html` · <span class="pv-diff-cut">${t("chat.pvChangesCut", DIFF_LIMITS.maxLines)}</span>` : null}</div>
|
|
554
|
+
<pre class="pv-code pv-diff"><code>${rows}</code></pre></div>`;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/** #2911 (6): the thread's pages, newest first — one row each, its newest version opened by a click (waiting for Preview). */
|
|
558
|
+
function PageList({ pages, current, pick }) {
|
|
559
|
+
return html`<ul class="pv-pages" aria-label=${t("chat.pvPagesTitle")}>${pages.map(p => html`<li key=${p.id}>
|
|
560
|
+
<button type="button" class=${`pv-page${p.id === current ? " on" : ""}`} aria-current=${p.id === current ? "true" : undefined} onClick=${() => pick(p)}>
|
|
561
|
+
<${Icon} name=${p.kind === "file" ? "attach" : "code"} size=${14} />
|
|
562
|
+
<span class="pv-page-name">${p.label || t("chat.pvPagesUntitled")}</span>
|
|
563
|
+
<span class="pv-page-meta">${p.versions > 1 ? t("chat.pvPagesVersions", p.versions) : ""}${p.versions > 1 ? " · " : ""}${timeOf(p.latest.ts)}</span>
|
|
564
|
+
</button></li>`)}</ul>`;
|
|
565
|
+
}
|