@pellux/goodvibes-agent 0.1.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/.goodvibes/GOODVIBES.md +35 -0
- package/.goodvibes/agents/reviewer.md +48 -0
- package/.goodvibes/skills/add-provider/SKILL.md +199 -0
- package/CHANGELOG.md +25 -0
- package/README.md +74 -0
- package/bin/goodvibes-agent.ts +2 -0
- package/docs/README.md +23 -0
- package/docs/deployment-and-services.md +57 -0
- package/docs/getting-started.md +53 -0
- package/docs/release-and-publishing.md +46 -0
- package/package.json +134 -0
- package/scripts/check-bun.sh +20 -0
- package/src/audio/player.ts +156 -0
- package/src/audio/spoken-turn-controller.ts +203 -0
- package/src/audio/spoken-turn-model-routing.ts +117 -0
- package/src/audio/spoken-turn-wiring.ts +44 -0
- package/src/audio/text-chunker.ts +110 -0
- package/src/cli/bundle-command.ts +227 -0
- package/src/cli/completion.ts +90 -0
- package/src/cli/config-overrides.ts +159 -0
- package/src/cli/endpoints.ts +63 -0
- package/src/cli/entrypoint.ts +172 -0
- package/src/cli/help.ts +299 -0
- package/src/cli/index.ts +11 -0
- package/src/cli/management-commands.ts +426 -0
- package/src/cli/management.ts +744 -0
- package/src/cli/network-posture.ts +46 -0
- package/src/cli/package-verification.ts +123 -0
- package/src/cli/parser.ts +369 -0
- package/src/cli/provider-auth-routes.ts +22 -0
- package/src/cli/provider-classification.ts +107 -0
- package/src/cli/redaction.ts +105 -0
- package/src/cli/service-command.ts +26 -0
- package/src/cli/service-posture.ts +482 -0
- package/src/cli/status.ts +383 -0
- package/src/cli/surface-command.ts +247 -0
- package/src/cli/tui-startup.ts +32 -0
- package/src/cli/types.ts +69 -0
- package/src/cli-flags.ts +21 -0
- package/src/config/goodvibes-home-audit.ts +465 -0
- package/src/config/index.ts +57 -0
- package/src/config/provider-model.ts +23 -0
- package/src/config/secret-config.ts +119 -0
- package/src/config/secrets.ts +71 -0
- package/src/config/surface.ts +1 -0
- package/src/core/composer-state.ts +61 -0
- package/src/core/conversation-rendering.ts +359 -0
- package/src/core/conversation.ts +551 -0
- package/src/core/history.ts +45 -0
- package/src/core/orchestrator.ts +7 -0
- package/src/core/system-message-router.ts +171 -0
- package/src/daemon/cli.ts +55 -0
- package/src/daemon/safe-serve.ts +61 -0
- package/src/input/agent-workspace.ts +428 -0
- package/src/input/autocomplete.ts +96 -0
- package/src/input/bookmark-modal.ts +115 -0
- package/src/input/command-args-hint.ts +36 -0
- package/src/input/command-registry.ts +329 -0
- package/src/input/commands/agent-externalized-tui.ts +73 -0
- package/src/input/commands/agent-workspace-runtime.ts +17 -0
- package/src/input/commands/branch-runtime.ts +72 -0
- package/src/input/commands/cloudflare-runtime.ts +370 -0
- package/src/input/commands/config.ts +18 -0
- package/src/input/commands/control-room-runtime.ts +255 -0
- package/src/input/commands/conversation-runtime.ts +207 -0
- package/src/input/commands/discovery-runtime.ts +52 -0
- package/src/input/commands/eval.ts +204 -0
- package/src/input/commands/experience-runtime.ts +278 -0
- package/src/input/commands/guidance-runtime.ts +106 -0
- package/src/input/commands/health-runtime.ts +434 -0
- package/src/input/commands/hooks-runtime.ts +148 -0
- package/src/input/commands/incident-runtime.ts +95 -0
- package/src/input/commands/integration-runtime.ts +394 -0
- package/src/input/commands/intelligence-runtime.ts +223 -0
- package/src/input/commands/knowledge.ts +531 -0
- package/src/input/commands/local-auth-runtime.ts +105 -0
- package/src/input/commands/local-provider-runtime.ts +170 -0
- package/src/input/commands/local-runtime.ts +392 -0
- package/src/input/commands/local-setup-review.ts +199 -0
- package/src/input/commands/local-setup-transfer.ts +135 -0
- package/src/input/commands/local-setup.ts +282 -0
- package/src/input/commands/managed-runtime.ts +209 -0
- package/src/input/commands/marketplace-runtime.ts +290 -0
- package/src/input/commands/mcp-runtime.ts +432 -0
- package/src/input/commands/memory-product-runtime.ts +111 -0
- package/src/input/commands/memory.ts +151 -0
- package/src/input/commands/notify-runtime.ts +83 -0
- package/src/input/commands/onboarding-runtime.ts +14 -0
- package/src/input/commands/operator-panel-runtime.ts +146 -0
- package/src/input/commands/operator-runtime.ts +392 -0
- package/src/input/commands/planning-runtime.ts +205 -0
- package/src/input/commands/platform-access-runtime.ts +422 -0
- package/src/input/commands/platform-services-runtime.ts +246 -0
- package/src/input/commands/policy-dispatch.ts +339 -0
- package/src/input/commands/policy.ts +17 -0
- package/src/input/commands/product-runtime.ts +351 -0
- package/src/input/commands/profile-sync-runtime.ts +99 -0
- package/src/input/commands/provider-accounts-runtime.ts +113 -0
- package/src/input/commands/provider.ts +363 -0
- package/src/input/commands/qrcode-runtime.ts +20 -0
- package/src/input/commands/quit-shared.ts +162 -0
- package/src/input/commands/recall-bundle.ts +132 -0
- package/src/input/commands/recall-capture.ts +152 -0
- package/src/input/commands/recall-query.ts +229 -0
- package/src/input/commands/recall-review.ts +98 -0
- package/src/input/commands/recall-shared.ts +22 -0
- package/src/input/commands/remote-runtime-pool.ts +106 -0
- package/src/input/commands/remote-runtime-setup.ts +199 -0
- package/src/input/commands/remote-runtime.ts +431 -0
- package/src/input/commands/replay-runtime.ts +18 -0
- package/src/input/commands/runtime-services.ts +291 -0
- package/src/input/commands/schedule-runtime.ts +91 -0
- package/src/input/commands/services-runtime.ts +209 -0
- package/src/input/commands/session-content.ts +408 -0
- package/src/input/commands/session-workflow.ts +464 -0
- package/src/input/commands/session.ts +375 -0
- package/src/input/commands/settings-sync-runtime.ts +174 -0
- package/src/input/commands/share-runtime.ts +119 -0
- package/src/input/commands/shell-core.ts +307 -0
- package/src/input/commands/skills-runtime.ts +221 -0
- package/src/input/commands/subscription-runtime.ts +434 -0
- package/src/input/commands/tasks-runtime.ts +230 -0
- package/src/input/commands/teamwork-runtime.ts +339 -0
- package/src/input/commands/teleport-runtime.ts +57 -0
- package/src/input/commands/tts-runtime.ts +29 -0
- package/src/input/commands/work-plan-runtime.ts +169 -0
- package/src/input/commands.ts +131 -0
- package/src/input/feed-context-factory.ts +254 -0
- package/src/input/file-picker.ts +192 -0
- package/src/input/handler-command-route.ts +180 -0
- package/src/input/handler-content-actions.ts +497 -0
- package/src/input/handler-feed-routes.ts +648 -0
- package/src/input/handler-feed.ts +452 -0
- package/src/input/handler-interactions.ts +281 -0
- package/src/input/handler-modal-routes.ts +418 -0
- package/src/input/handler-modal-stack.ts +263 -0
- package/src/input/handler-modal-token-routes.ts +329 -0
- package/src/input/handler-onboarding-cloudflare.ts +391 -0
- package/src/input/handler-onboarding.ts +620 -0
- package/src/input/handler-picker-routes.ts +472 -0
- package/src/input/handler-prompt-buffer.ts +320 -0
- package/src/input/handler-shortcuts.ts +213 -0
- package/src/input/handler-ui-state.ts +372 -0
- package/src/input/handler.ts +729 -0
- package/src/input/input-history.ts +297 -0
- package/src/input/keybindings.ts +292 -0
- package/src/input/mcp-workspace.ts +554 -0
- package/src/input/model-picker-provider-filter.ts +28 -0
- package/src/input/model-picker-types.ts +137 -0
- package/src/input/model-picker.ts +797 -0
- package/src/input/onboarding/handler-onboarding-routes.ts +125 -0
- package/src/input/onboarding/onboarding-runtime-status.ts +87 -0
- package/src/input/onboarding/onboarding-wizard-apply.ts +277 -0
- package/src/input/onboarding/onboarding-wizard-cloudflare-step.ts +494 -0
- package/src/input/onboarding/onboarding-wizard-cloudflare.ts +204 -0
- package/src/input/onboarding/onboarding-wizard-constants.ts +158 -0
- package/src/input/onboarding/onboarding-wizard-external-surface-extra-specs.ts +130 -0
- package/src/input/onboarding/onboarding-wizard-external-surfaces.ts +762 -0
- package/src/input/onboarding/onboarding-wizard-helpers.ts +167 -0
- package/src/input/onboarding/onboarding-wizard-rules.ts +256 -0
- package/src/input/onboarding/onboarding-wizard-state.ts +365 -0
- package/src/input/onboarding/onboarding-wizard-steps.ts +798 -0
- package/src/input/onboarding/onboarding-wizard-types.ts +195 -0
- package/src/input/onboarding/onboarding-wizard.ts +711 -0
- package/src/input/panel-integration-actions.ts +78 -0
- package/src/input/profile-picker-modal.ts +222 -0
- package/src/input/search.ts +100 -0
- package/src/input/selection-modal.ts +163 -0
- package/src/input/selection.ts +135 -0
- package/src/input/session-picker-modal.ts +136 -0
- package/src/input/settings-modal-behavior.ts +37 -0
- package/src/input/settings-modal-secrets.ts +41 -0
- package/src/input/settings-modal-subscriptions.ts +95 -0
- package/src/input/settings-modal-types.ts +91 -0
- package/src/input/settings-modal.ts +793 -0
- package/src/input/submission-intent.ts +17 -0
- package/src/input/submission-router.ts +59 -0
- package/src/input/tts-settings-actions.ts +100 -0
- package/src/main.ts +792 -0
- package/src/mcp/runtime-reload.ts +81 -0
- package/src/panels/agent-inspector-panel.ts +521 -0
- package/src/panels/agent-inspector-shared.ts +94 -0
- package/src/panels/agent-logs-panel.ts +559 -0
- package/src/panels/agent-logs-shared.ts +129 -0
- package/src/panels/approval-panel.ts +150 -0
- package/src/panels/automation-control-panel.ts +212 -0
- package/src/panels/base-panel.ts +254 -0
- package/src/panels/builtin/agent.ts +117 -0
- package/src/panels/builtin/development.ts +31 -0
- package/src/panels/builtin/knowledge.ts +26 -0
- package/src/panels/builtin/operations.ts +349 -0
- package/src/panels/builtin/session.ts +129 -0
- package/src/panels/builtin/shared.ts +274 -0
- package/src/panels/builtin-panels.ts +23 -0
- package/src/panels/cockpit-panel.ts +183 -0
- package/src/panels/communication-panel.ts +153 -0
- package/src/panels/confirm-state.ts +61 -0
- package/src/panels/context-visualizer-panel.ts +204 -0
- package/src/panels/control-plane-panel.ts +211 -0
- package/src/panels/cost-tracker-panel.ts +444 -0
- package/src/panels/debug-panel.ts +432 -0
- package/src/panels/diff-panel.ts +520 -0
- package/src/panels/docs-panel.ts +283 -0
- package/src/panels/eval-panel.ts +399 -0
- package/src/panels/file-explorer-panel.ts +584 -0
- package/src/panels/file-preview-panel.ts +434 -0
- package/src/panels/forensics-panel.ts +364 -0
- package/src/panels/git-panel.ts +638 -0
- package/src/panels/hooks-panel.ts +239 -0
- package/src/panels/incident-review-panel.ts +197 -0
- package/src/panels/index.ts +46 -0
- package/src/panels/intelligence-panel.ts +176 -0
- package/src/panels/knowledge-panel.ts +345 -0
- package/src/panels/local-auth-panel.ts +130 -0
- package/src/panels/marketplace-panel.ts +212 -0
- package/src/panels/memory-panel.ts +225 -0
- package/src/panels/ops-control-panel.ts +150 -0
- package/src/panels/ops-strategy-panel.ts +235 -0
- package/src/panels/orchestration-panel.ts +273 -0
- package/src/panels/panel-list-panel.ts +509 -0
- package/src/panels/panel-manager.ts +570 -0
- package/src/panels/panel-picker.ts +106 -0
- package/src/panels/plan-dashboard-panel.ts +274 -0
- package/src/panels/plugins-panel.ts +178 -0
- package/src/panels/policy-panel.ts +308 -0
- package/src/panels/polish.ts +717 -0
- package/src/panels/project-planning-panel.ts +711 -0
- package/src/panels/provider-account-snapshot.ts +259 -0
- package/src/panels/provider-accounts-panel.ts +218 -0
- package/src/panels/provider-health-domains.ts +215 -0
- package/src/panels/provider-health-panel.ts +727 -0
- package/src/panels/provider-health-tracker.ts +115 -0
- package/src/panels/provider-stats-panel.ts +366 -0
- package/src/panels/qr-panel.ts +182 -0
- package/src/panels/remote-panel.ts +449 -0
- package/src/panels/routes-panel.ts +178 -0
- package/src/panels/sandbox-panel.ts +283 -0
- package/src/panels/schedule-panel.ts +329 -0
- package/src/panels/scrollable-list-panel.ts +491 -0
- package/src/panels/search-focus.ts +32 -0
- package/src/panels/security-panel.ts +295 -0
- package/src/panels/services-panel.ts +231 -0
- package/src/panels/session-browser-panel.ts +400 -0
- package/src/panels/session-maintenance.ts +125 -0
- package/src/panels/settings-sync-panel.ts +120 -0
- package/src/panels/skills-panel.ts +431 -0
- package/src/panels/subscription-panel.ts +263 -0
- package/src/panels/symbol-outline-panel.ts +486 -0
- package/src/panels/system-messages-panel.ts +230 -0
- package/src/panels/tasks-panel.ts +399 -0
- package/src/panels/thinking-panel.ts +304 -0
- package/src/panels/token-budget-panel.ts +475 -0
- package/src/panels/tool-inspector-panel.ts +429 -0
- package/src/panels/types.ts +54 -0
- package/src/panels/watchers-panel.ts +193 -0
- package/src/panels/work-plan-panel.ts +175 -0
- package/src/panels/worktree-panel.ts +182 -0
- package/src/panels/wrfc-panel.ts +609 -0
- package/src/permissions/prompt.ts +165 -0
- package/src/planning/project-planning-coordinator.ts +543 -0
- package/src/plugins/loader.ts +15 -0
- package/src/renderer/agent-detail-modal.ts +331 -0
- package/src/renderer/agent-workspace.ts +238 -0
- package/src/renderer/ansi-sanitize.ts +76 -0
- package/src/renderer/autocomplete-overlay.ts +154 -0
- package/src/renderer/block-actions.ts +76 -0
- package/src/renderer/bookmark-modal.ts +101 -0
- package/src/renderer/bottom-bar.ts +58 -0
- package/src/renderer/buffer.ts +113 -0
- package/src/renderer/code-block.ts +373 -0
- package/src/renderer/compositor.ts +283 -0
- package/src/renderer/context-inspector.ts +219 -0
- package/src/renderer/conversation-layout.ts +67 -0
- package/src/renderer/conversation-overlays.ts +140 -0
- package/src/renderer/conversation-surface.ts +260 -0
- package/src/renderer/diff-view.ts +132 -0
- package/src/renderer/diff.ts +130 -0
- package/src/renderer/file-picker-overlay.ts +101 -0
- package/src/renderer/file-tree.ts +153 -0
- package/src/renderer/fullscreen-primitives.ts +130 -0
- package/src/renderer/fullscreen-workspace.ts +199 -0
- package/src/renderer/git-status.ts +89 -0
- package/src/renderer/help-overlay.ts +267 -0
- package/src/renderer/history-search-overlay.ts +73 -0
- package/src/renderer/layout-engine.ts +97 -0
- package/src/renderer/layout.ts +32 -0
- package/src/renderer/live-tail-modal.ts +156 -0
- package/src/renderer/markdown.ts +635 -0
- package/src/renderer/mcp-workspace.ts +237 -0
- package/src/renderer/modal-factory.ts +467 -0
- package/src/renderer/modal-utils.ts +24 -0
- package/src/renderer/model-picker-overlay.ts +473 -0
- package/src/renderer/model-workspace.ts +488 -0
- package/src/renderer/onboarding/onboarding-wizard.ts +615 -0
- package/src/renderer/overlay-box.ts +146 -0
- package/src/renderer/overlay-viewport.ts +104 -0
- package/src/renderer/panel-composite.ts +158 -0
- package/src/renderer/panel-picker-overlay.ts +202 -0
- package/src/renderer/panel-tab-bar.ts +69 -0
- package/src/renderer/panel-workspace-bar.ts +42 -0
- package/src/renderer/process-indicator.ts +96 -0
- package/src/renderer/process-modal.ts +656 -0
- package/src/renderer/process-summary.ts +67 -0
- package/src/renderer/profile-picker-modal.ts +129 -0
- package/src/renderer/progress.ts +98 -0
- package/src/renderer/qr-renderer.ts +120 -0
- package/src/renderer/search-overlay.ts +54 -0
- package/src/renderer/selection-modal-overlay.ts +214 -0
- package/src/renderer/semantic-diff.ts +369 -0
- package/src/renderer/session-picker-modal.ts +127 -0
- package/src/renderer/settings-modal-helpers.ts +193 -0
- package/src/renderer/settings-modal.ts +537 -0
- package/src/renderer/shell-surface.ts +88 -0
- package/src/renderer/status-glyphs.ts +21 -0
- package/src/renderer/status-token.ts +67 -0
- package/src/renderer/surface-layout.ts +101 -0
- package/src/renderer/syntax-highlighter.ts +542 -0
- package/src/renderer/system-message.ts +83 -0
- package/src/renderer/tab-strip.ts +108 -0
- package/src/renderer/text-layout.ts +31 -0
- package/src/renderer/thinking.ts +17 -0
- package/src/renderer/tool-call.ts +234 -0
- package/src/renderer/ui-factory.ts +524 -0
- package/src/renderer/ui-primitives.ts +96 -0
- package/src/runtime/bootstrap-command-context.ts +278 -0
- package/src/runtime/bootstrap-command-parts.ts +386 -0
- package/src/runtime/bootstrap-core.ts +540 -0
- package/src/runtime/bootstrap-hook-bridge.ts +112 -0
- package/src/runtime/bootstrap-shell.ts +283 -0
- package/src/runtime/bootstrap.ts +575 -0
- package/src/runtime/cloudflare-control-plane.ts +349 -0
- package/src/runtime/context.ts +142 -0
- package/src/runtime/diagnostics/panels/index.ts +24 -0
- package/src/runtime/diagnostics/panels/ops.ts +156 -0
- package/src/runtime/diagnostics/panels/panel-resources.ts +118 -0
- package/src/runtime/diagnostics/panels/policy.ts +177 -0
- package/src/runtime/index.ts +662 -0
- package/src/runtime/onboarding/apply.ts +642 -0
- package/src/runtime/onboarding/derivation.ts +534 -0
- package/src/runtime/onboarding/index.ts +7 -0
- package/src/runtime/onboarding/markers.ts +148 -0
- package/src/runtime/onboarding/snapshot.ts +406 -0
- package/src/runtime/onboarding/state.ts +141 -0
- package/src/runtime/onboarding/types.ts +404 -0
- package/src/runtime/onboarding/verify.ts +171 -0
- package/src/runtime/operator-token-cleanup.ts +27 -0
- package/src/runtime/perf/panel-contracts.ts +32 -0
- package/src/runtime/perf/panel-health-monitor.ts +18 -0
- package/src/runtime/sandbox-public-gaps.ts +358 -0
- package/src/runtime/services.ts +670 -0
- package/src/runtime/store/domains/domain-read-matrix.ts +15 -0
- package/src/runtime/store/domains/index.ts +222 -0
- package/src/runtime/store/domains/panels.ts +117 -0
- package/src/runtime/store/domains/ui-perf.ts +103 -0
- package/src/runtime/store/index.ts +305 -0
- package/src/runtime/store/selectors/index.ts +359 -0
- package/src/runtime/store/state.ts +145 -0
- package/src/runtime/surface-feature-flags.ts +65 -0
- package/src/runtime/terminal-output-guard.ts +228 -0
- package/src/runtime/ui/index.ts +39 -0
- package/src/runtime/ui/model-picker/data-provider.ts +182 -0
- package/src/runtime/ui/model-picker/health-enrichment.ts +228 -0
- package/src/runtime/ui/model-picker/index.ts +59 -0
- package/src/runtime/ui/model-picker/types.ts +149 -0
- package/src/runtime/ui/provider-health/data-provider.ts +244 -0
- package/src/runtime/ui/provider-health/fallback-visualizer.ts +71 -0
- package/src/runtime/ui/provider-health/index.ts +46 -0
- package/src/runtime/ui/provider-health/types.ts +146 -0
- package/src/runtime/ui-events.ts +1 -0
- package/src/runtime/ui-read-model-helpers.ts +1 -0
- package/src/runtime/ui-read-models-observability-maintenance.ts +1 -0
- package/src/runtime/ui-read-models-observability-options.ts +1 -0
- package/src/runtime/ui-read-models-observability-remote.ts +1 -0
- package/src/runtime/ui-read-models-observability-security.ts +1 -0
- package/src/runtime/ui-read-models-observability-system.ts +1 -0
- package/src/runtime/ui-read-models-observability.ts +1 -0
- package/src/runtime/ui-read-models.ts +61 -0
- package/src/runtime/ui-service-queries.ts +1 -0
- package/src/runtime/ui-services.ts +190 -0
- package/src/scripts/process-messages.ts +42 -0
- package/src/shell/blocking-input.ts +98 -0
- package/src/shell/service-settings-sync.ts +273 -0
- package/src/shell/ui-openers.ts +352 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/wrfc-agent-guard.ts +49 -0
- package/src/types/grid.ts +48 -0
- package/src/types/sql-js.d.ts +15 -0
- package/src/utils/clipboard.ts +22 -0
- package/src/utils/splash-lines.ts +46 -0
- package/src/utils/terminal-width.ts +185 -0
- package/src/verification/live-verifier.ts +430 -0
- package/src/verification/verification-ledger.ts +242 -0
- package/src/version.ts +17 -0
- package/src/widget/index.ts +2 -0
- package/src/widget/types.ts +9 -0
- package/src/widget/widget.ts +8 -0
- package/src/work-plans/work-plan-store.ts +374 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import type { Line, Cell } from '../types/grid.ts';
|
|
2
|
+
import { createStyledCell } from '../types/grid.ts';
|
|
3
|
+
import { fitDisplay, getDisplayWidth, truncateDisplay, wrapText } from '../utils/terminal-width.ts';
|
|
4
|
+
import {
|
|
5
|
+
createOverlayBorderLine,
|
|
6
|
+
createOverlayBoxLayout,
|
|
7
|
+
createOverlayContentLine,
|
|
8
|
+
putOverlayText,
|
|
9
|
+
} from './overlay-box.ts';
|
|
10
|
+
import { getOverlayMaxWidth } from './overlay-viewport.ts';
|
|
11
|
+
import { GLYPHS, UI_TONES } from './ui-primitives.ts';
|
|
12
|
+
|
|
13
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Truncate a string to fit within maxWidth display columns.
|
|
17
|
+
* Handles wide characters (CJK, emoji) correctly via getDisplayWidth.
|
|
18
|
+
*/
|
|
19
|
+
function truncateToWidth(text: string, maxWidth: number): string {
|
|
20
|
+
return truncateDisplay(text, maxWidth, '');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ── Types ────────────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
export interface ModalSectionStyle {
|
|
26
|
+
fg?: string;
|
|
27
|
+
bg?: string;
|
|
28
|
+
bold?: boolean;
|
|
29
|
+
dim?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ModalSection {
|
|
33
|
+
type: 'text' | 'list' | 'input' | 'separator' | 'title' | 'spacer';
|
|
34
|
+
/** Text content for 'text' and 'input' types. */
|
|
35
|
+
content?: string;
|
|
36
|
+
/** Items for 'list' type. Each item: { label, selected?, style? } */
|
|
37
|
+
items?: ModalListItem[];
|
|
38
|
+
style?: ModalSectionStyle;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ModalListItem {
|
|
42
|
+
label: string;
|
|
43
|
+
selected?: boolean;
|
|
44
|
+
style?: ModalSectionStyle;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ModalStyle {
|
|
48
|
+
titleFg?: string;
|
|
49
|
+
borderFg?: string;
|
|
50
|
+
hintFg?: string;
|
|
51
|
+
selectedFg?: string;
|
|
52
|
+
selectedBg?: string;
|
|
53
|
+
textFg?: string;
|
|
54
|
+
accentFg?: string;
|
|
55
|
+
titleRowFg?: string;
|
|
56
|
+
titleBg?: string;
|
|
57
|
+
sectionBg?: string;
|
|
58
|
+
inputBg?: string;
|
|
59
|
+
surfaceBg?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ModalTab {
|
|
63
|
+
label: string;
|
|
64
|
+
active?: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ModalHelperRow {
|
|
68
|
+
label?: string;
|
|
69
|
+
content: string;
|
|
70
|
+
accent?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ModalConfig {
|
|
74
|
+
title: string;
|
|
75
|
+
/** Box width including borders. Default: 72. */
|
|
76
|
+
width?: number;
|
|
77
|
+
/** Horizontal margin (spaces on left). Default: 4. */
|
|
78
|
+
margin?: number;
|
|
79
|
+
tabs?: ModalTab[];
|
|
80
|
+
search?: string;
|
|
81
|
+
sections: ModalSection[];
|
|
82
|
+
targetContentRows?: number;
|
|
83
|
+
helpers?: ModalHelperRow[];
|
|
84
|
+
/** Footer hint string. If omitted, no bottom hint text is inlined. */
|
|
85
|
+
footer?: string;
|
|
86
|
+
/** Keyboard hint strings to join with spaces in the footer border. */
|
|
87
|
+
hints?: string[];
|
|
88
|
+
style?: ModalStyle;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ── Defaults ─────────────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
const DEFAULT_STYLE: Required<ModalStyle> = {
|
|
94
|
+
titleFg: UI_TONES.fg.primary,
|
|
95
|
+
borderFg: UI_TONES.fg.dim,
|
|
96
|
+
hintFg: UI_TONES.fg.muted,
|
|
97
|
+
selectedFg: UI_TONES.fg.primary,
|
|
98
|
+
selectedBg: UI_TONES.bg.selected,
|
|
99
|
+
textFg: UI_TONES.fg.primary,
|
|
100
|
+
accentFg: UI_TONES.state.info,
|
|
101
|
+
titleRowFg: UI_TONES.fg.secondary,
|
|
102
|
+
titleBg: UI_TONES.bg.title,
|
|
103
|
+
sectionBg: UI_TONES.bg.section,
|
|
104
|
+
inputBg: UI_TONES.bg.input,
|
|
105
|
+
surfaceBg: UI_TONES.bg.surface,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// ── ModalFactory ─────────────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* ModalFactory — unified modal rendering for goodvibes-agent.
|
|
112
|
+
*
|
|
113
|
+
* Renders modals as Line[] (Cell arrays) consistent with the compositor
|
|
114
|
+
* overlay pipeline. All existing modals (file-picker, model-picker,
|
|
115
|
+
* selection-modal) can be expressed via createModal().
|
|
116
|
+
*
|
|
117
|
+
* Helper methods are also exported so callers can compose custom modals
|
|
118
|
+
* without going through the full config object.
|
|
119
|
+
*/
|
|
120
|
+
export class ModalFactory {
|
|
121
|
+
/**
|
|
122
|
+
* Render a complete modal box as Line[].
|
|
123
|
+
*
|
|
124
|
+
* @param config Modal configuration.
|
|
125
|
+
* @param terminalWidth Full terminal width (used to size/pad output lines).
|
|
126
|
+
*/
|
|
127
|
+
static createModal(config: ModalConfig, terminalWidth: number): Line[] {
|
|
128
|
+
const margin = config.margin ?? 4;
|
|
129
|
+
const maxBoxW = config.width ?? 72;
|
|
130
|
+
const boxW = Math.max(24, getOverlayMaxWidth(terminalWidth, margin, maxBoxW));
|
|
131
|
+
const style = { ...DEFAULT_STYLE, ...(config.style ?? {}) };
|
|
132
|
+
const lines: Line[] = [];
|
|
133
|
+
|
|
134
|
+
// Title bar
|
|
135
|
+
lines.push(ModalFactory.renderTitle(boxW, margin, config.title, terminalWidth, style));
|
|
136
|
+
|
|
137
|
+
// Sections
|
|
138
|
+
const sectionLines: Line[] = [];
|
|
139
|
+
if (config.tabs && config.tabs.length > 0) {
|
|
140
|
+
lines.push(ModalFactory._renderTabsRow(boxW, margin, terminalWidth, config.tabs, style));
|
|
141
|
+
}
|
|
142
|
+
if (typeof config.search === 'string') {
|
|
143
|
+
lines.push(...ModalFactory._renderInputSection({ type: 'input', content: config.search }, boxW, margin, terminalWidth, style));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
for (const section of config.sections) {
|
|
147
|
+
switch (section.type) {
|
|
148
|
+
case 'text':
|
|
149
|
+
sectionLines.push(...ModalFactory._renderTextSection(section, boxW, margin, terminalWidth, style));
|
|
150
|
+
break;
|
|
151
|
+
case 'list':
|
|
152
|
+
sectionLines.push(...ModalFactory._renderListSection(section, boxW, margin, terminalWidth, style));
|
|
153
|
+
break;
|
|
154
|
+
case 'input':
|
|
155
|
+
sectionLines.push(...ModalFactory._renderInputSection(section, boxW, margin, terminalWidth, style));
|
|
156
|
+
break;
|
|
157
|
+
case 'separator':
|
|
158
|
+
sectionLines.push(ModalFactory._renderSeparatorLine(boxW, margin, terminalWidth, style));
|
|
159
|
+
break;
|
|
160
|
+
case 'title':
|
|
161
|
+
sectionLines.push(ModalFactory._renderSectionTitle(section, boxW, margin, terminalWidth, style));
|
|
162
|
+
break;
|
|
163
|
+
case 'spacer':
|
|
164
|
+
sectionLines.push(ModalFactory._renderEmptyRow(boxW, margin, terminalWidth, style));
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (typeof config.targetContentRows === 'number' && config.targetContentRows > 0) {
|
|
170
|
+
const bounded = sectionLines.slice(0, config.targetContentRows);
|
|
171
|
+
while (bounded.length < config.targetContentRows) {
|
|
172
|
+
bounded.push(ModalFactory._renderEmptyRow(boxW, margin, terminalWidth, style));
|
|
173
|
+
}
|
|
174
|
+
lines.push(...bounded);
|
|
175
|
+
} else {
|
|
176
|
+
lines.push(...sectionLines);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (config.helpers && config.helpers.length > 0) {
|
|
180
|
+
for (const helper of config.helpers) {
|
|
181
|
+
lines.push(ModalFactory._renderHelperRow(boxW, margin, terminalWidth, helper, style));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Footer / hint bar
|
|
186
|
+
const hintStr = config.hints
|
|
187
|
+
? config.hints.join(' ')
|
|
188
|
+
: (config.footer ?? '');
|
|
189
|
+
lines.push(ModalFactory.renderHints(boxW, margin, hintStr, terminalWidth, style));
|
|
190
|
+
|
|
191
|
+
return lines;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ── Public helpers ──────────────────────────────────────────────────────────
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Wrap content lines in a top/bottom border box.
|
|
198
|
+
* Content lines are expected to already be full-width Lines.
|
|
199
|
+
*/
|
|
200
|
+
static renderBox(
|
|
201
|
+
boxW: number,
|
|
202
|
+
margin: number,
|
|
203
|
+
content: Line[],
|
|
204
|
+
terminalWidth: number,
|
|
205
|
+
style: Partial<ModalStyle> = {},
|
|
206
|
+
): Line[] {
|
|
207
|
+
const s = { ...DEFAULT_STYLE, ...style };
|
|
208
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
209
|
+
return [
|
|
210
|
+
createOverlayBorderLine(terminalWidth, layout, '┌', '─', '┐', s.borderFg),
|
|
211
|
+
...content,
|
|
212
|
+
createOverlayBorderLine(terminalWidth, layout, '└', '─', '┘', s.borderFg),
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Render a title bar line: ┌─ Title ─────┐
|
|
218
|
+
*/
|
|
219
|
+
static renderTitle(
|
|
220
|
+
boxW: number,
|
|
221
|
+
margin: number,
|
|
222
|
+
title: string,
|
|
223
|
+
terminalWidth: number,
|
|
224
|
+
style: Partial<ModalStyle> = {},
|
|
225
|
+
): Line {
|
|
226
|
+
const s = { ...DEFAULT_STYLE, ...style };
|
|
227
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
228
|
+
const line = createOverlayBorderLine(terminalWidth, layout, GLYPHS.frame.topLeft, GLYPHS.frame.horizontal, GLYPHS.frame.topRight, s.borderFg);
|
|
229
|
+
for (let x = layout.margin + 1; x < layout.margin + layout.width - 1; x++) {
|
|
230
|
+
line[x] = createStyledCell(GLYPHS.frame.horizontal, { fg: s.borderFg, bg: s.titleBg });
|
|
231
|
+
}
|
|
232
|
+
putOverlayText(line, layout.margin + 2, layout.width - 4, title, { fg: s.titleFg, bg: s.titleBg, bold: true });
|
|
233
|
+
return line;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Render a bottom border line with optional keyboard hints inlined.
|
|
238
|
+
* ┘ side chars fill remaining width.
|
|
239
|
+
*/
|
|
240
|
+
static renderHints(
|
|
241
|
+
boxW: number,
|
|
242
|
+
margin: number,
|
|
243
|
+
hints: string,
|
|
244
|
+
terminalWidth: number,
|
|
245
|
+
style: Partial<ModalStyle> = {},
|
|
246
|
+
): Line {
|
|
247
|
+
const s = { ...DEFAULT_STYLE, ...style };
|
|
248
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
249
|
+
const line = createOverlayBorderLine(terminalWidth, layout, GLYPHS.frame.bottomLeft, GLYPHS.frame.horizontal, GLYPHS.frame.bottomRight, s.borderFg);
|
|
250
|
+
if (hints.length > 0) {
|
|
251
|
+
putOverlayText(line, layout.margin + 2, layout.width - 4, truncateDisplay(hints, layout.width - 4), {
|
|
252
|
+
fg: s.hintFg,
|
|
253
|
+
dim: true,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return line;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Render a single selectable list item row.
|
|
261
|
+
* ┤ text ├ — bordered left/right, with optional selection highlight.
|
|
262
|
+
*/
|
|
263
|
+
static renderListItem(
|
|
264
|
+
boxW: number,
|
|
265
|
+
margin: number,
|
|
266
|
+
text: string,
|
|
267
|
+
selected: boolean,
|
|
268
|
+
terminalWidth: number,
|
|
269
|
+
style: Partial<ModalStyle> = {},
|
|
270
|
+
): Line {
|
|
271
|
+
const s = { ...DEFAULT_STYLE, ...style };
|
|
272
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
273
|
+
const contentW = layout.innerWidth;
|
|
274
|
+
const indicator = selected ? '▸ ' : ' ';
|
|
275
|
+
const displayText = getDisplayWidth(text) > contentW - 2
|
|
276
|
+
? truncateDisplay(text, contentW - 2)
|
|
277
|
+
: text;
|
|
278
|
+
const padded = fitDisplay(displayText, contentW - 2);
|
|
279
|
+
const row = createOverlayContentLine(terminalWidth, layout, s.borderFg, selected ? s.selectedBg : s.surfaceBg);
|
|
280
|
+
const cellStyle: Partial<Cell> = selected ? { fg: s.selectedFg, bg: s.selectedBg, bold: true } : { fg: s.textFg };
|
|
281
|
+
putOverlayText(row, layout.margin + 2, contentW, indicator + padded, {
|
|
282
|
+
fg: cellStyle.fg ?? s.textFg,
|
|
283
|
+
bg: cellStyle.bg ?? s.surfaceBg,
|
|
284
|
+
bold: cellStyle.bold ?? false,
|
|
285
|
+
});
|
|
286
|
+
return row;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// ── Private section renderers ────────────────────────────────────────────────
|
|
290
|
+
|
|
291
|
+
private static _renderTextSection(
|
|
292
|
+
section: ModalSection,
|
|
293
|
+
boxW: number,
|
|
294
|
+
margin: number,
|
|
295
|
+
terminalWidth: number,
|
|
296
|
+
style: Required<ModalStyle>,
|
|
297
|
+
): Line[] {
|
|
298
|
+
const contentW = boxW - 4;
|
|
299
|
+
const text = section.content ?? '';
|
|
300
|
+
const fg = section.style?.fg ?? style.textFg;
|
|
301
|
+
const bg = section.style?.bg ?? '';
|
|
302
|
+
const bold = section.style?.bold ?? false;
|
|
303
|
+
const dim = section.style?.dim ?? false;
|
|
304
|
+
|
|
305
|
+
const wrappedLines = wrapText(text, Math.max(8, contentW));
|
|
306
|
+
return wrappedLines.map((wrappedLine) => {
|
|
307
|
+
const truncated = getDisplayWidth(wrappedLine) > contentW
|
|
308
|
+
? truncateDisplay(wrappedLine, contentW)
|
|
309
|
+
: wrappedLine;
|
|
310
|
+
const padded = fitDisplay(truncated, contentW);
|
|
311
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
312
|
+
const row = createOverlayContentLine(terminalWidth, layout, style.borderFg, bg || style.surfaceBg);
|
|
313
|
+
putOverlayText(row, layout.margin + 2, contentW, padded, { fg, bg, bold, dim });
|
|
314
|
+
return row;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private static _renderListSection(
|
|
319
|
+
section: ModalSection,
|
|
320
|
+
boxW: number,
|
|
321
|
+
margin: number,
|
|
322
|
+
terminalWidth: number,
|
|
323
|
+
style: Required<ModalStyle>,
|
|
324
|
+
): Line[] {
|
|
325
|
+
const items = section.items ?? [];
|
|
326
|
+
if (items.length === 0) {
|
|
327
|
+
return [ModalFactory._renderEmptyRow(boxW, margin, terminalWidth, style)];
|
|
328
|
+
}
|
|
329
|
+
const contentW = boxW - 4;
|
|
330
|
+
const rows: Line[] = [];
|
|
331
|
+
for (const item of items) {
|
|
332
|
+
const itemStyle = {
|
|
333
|
+
...style,
|
|
334
|
+
...(item.style ? {
|
|
335
|
+
selectedFg: item.style.fg ?? style.selectedFg,
|
|
336
|
+
textFg: item.style.fg ?? style.textFg,
|
|
337
|
+
} : {}),
|
|
338
|
+
};
|
|
339
|
+
const wrapped = wrapText(item.label, Math.max(8, contentW - 2));
|
|
340
|
+
const displayLines = wrapped.length > 0 ? wrapped : [''];
|
|
341
|
+
for (let i = 0; i < displayLines.length; i++) {
|
|
342
|
+
const isFirst = i === 0;
|
|
343
|
+
const indicator = isFirst
|
|
344
|
+
? (item.selected ? `${GLYPHS.navigation.selected} ` : ' ')
|
|
345
|
+
: ' ';
|
|
346
|
+
const row = createOverlayContentLine(
|
|
347
|
+
terminalWidth,
|
|
348
|
+
createOverlayBoxLayout(terminalWidth, margin, boxW),
|
|
349
|
+
itemStyle.borderFg,
|
|
350
|
+
item.selected ? itemStyle.selectedBg : itemStyle.surfaceBg,
|
|
351
|
+
);
|
|
352
|
+
const padded = fitDisplay(truncateToWidth(`${indicator}${displayLines[i] ?? ''}`, contentW), contentW);
|
|
353
|
+
putOverlayText(row, margin + 2, contentW, padded, {
|
|
354
|
+
fg: item.selected ? itemStyle.selectedFg : itemStyle.textFg,
|
|
355
|
+
bg: item.selected ? itemStyle.selectedBg : itemStyle.surfaceBg,
|
|
356
|
+
bold: item.selected && isFirst,
|
|
357
|
+
});
|
|
358
|
+
rows.push(row);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return rows;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private static _renderInputSection(
|
|
365
|
+
section: ModalSection,
|
|
366
|
+
boxW: number,
|
|
367
|
+
margin: number,
|
|
368
|
+
terminalWidth: number,
|
|
369
|
+
style: Required<ModalStyle>,
|
|
370
|
+
): Line[] {
|
|
371
|
+
const contentW = boxW - 4;
|
|
372
|
+
const query = section.content ?? '';
|
|
373
|
+
const cursor = GLYPHS.surface.cursor;
|
|
374
|
+
const displayQuery = getDisplayWidth(query) > contentW - 4
|
|
375
|
+
? truncateDisplay(query, contentW - 4)
|
|
376
|
+
: query;
|
|
377
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
378
|
+
const row = createOverlayContentLine(terminalWidth, layout, style.borderFg, style.inputBg);
|
|
379
|
+
const text = fitDisplay(`/ ${displayQuery}${cursor}`, contentW);
|
|
380
|
+
putOverlayText(row, layout.margin + 2, contentW, text, { fg: style.textFg, bg: style.inputBg, bold: true });
|
|
381
|
+
return [row];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
private static _renderTabsRow(
|
|
385
|
+
boxW: number,
|
|
386
|
+
margin: number,
|
|
387
|
+
terminalWidth: number,
|
|
388
|
+
tabs: readonly ModalTab[],
|
|
389
|
+
style: Required<ModalStyle>,
|
|
390
|
+
): Line {
|
|
391
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
392
|
+
const row = createOverlayContentLine(terminalWidth, layout, style.borderFg, style.sectionBg);
|
|
393
|
+
const active = tabs.find((tab) => tab.active);
|
|
394
|
+
const inactive = tabs.filter((tab) => !tab.active);
|
|
395
|
+
const text = [
|
|
396
|
+
...(active ? [`[${active.label.toUpperCase()}]`] : []),
|
|
397
|
+
...inactive.map((tab) => tab.label),
|
|
398
|
+
].join(' ');
|
|
399
|
+
putOverlayText(row, layout.margin + 2, layout.innerWidth, fitDisplay(text, layout.innerWidth), {
|
|
400
|
+
fg: style.accentFg,
|
|
401
|
+
bg: style.sectionBg,
|
|
402
|
+
bold: true,
|
|
403
|
+
});
|
|
404
|
+
return row;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private static _renderSectionTitle(
|
|
408
|
+
section: ModalSection,
|
|
409
|
+
boxW: number,
|
|
410
|
+
margin: number,
|
|
411
|
+
terminalWidth: number,
|
|
412
|
+
style: Required<ModalStyle>,
|
|
413
|
+
): Line {
|
|
414
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
415
|
+
const row = createOverlayContentLine(terminalWidth, layout, style.borderFg, section.style?.bg ?? style.sectionBg);
|
|
416
|
+
const text = fitDisplay(truncateToWidth(section.content ?? '', layout.innerWidth), layout.innerWidth);
|
|
417
|
+
putOverlayText(row, layout.margin + 2, layout.innerWidth, text, {
|
|
418
|
+
fg: section.style?.fg ?? style.titleRowFg,
|
|
419
|
+
bg: section.style?.bg ?? style.sectionBg,
|
|
420
|
+
bold: section.style?.bold ?? true,
|
|
421
|
+
dim: section.style?.dim ?? false,
|
|
422
|
+
});
|
|
423
|
+
return row;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private static _renderHelperRow(
|
|
427
|
+
boxW: number,
|
|
428
|
+
margin: number,
|
|
429
|
+
terminalWidth: number,
|
|
430
|
+
helper: ModalHelperRow,
|
|
431
|
+
style: Required<ModalStyle>,
|
|
432
|
+
): Line {
|
|
433
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
434
|
+
const row = createOverlayContentLine(terminalWidth, layout, style.borderFg, style.surfaceBg);
|
|
435
|
+
const prefix = helper.label ? `${helper.label} ` : '';
|
|
436
|
+
const helperText = fitDisplay(`${prefix}${helper.content}`, layout.innerWidth);
|
|
437
|
+
putOverlayText(row, layout.margin + 2, layout.innerWidth, helperText, {
|
|
438
|
+
fg: helper.accent ? style.accentFg : style.hintFg,
|
|
439
|
+
dim: !helper.accent,
|
|
440
|
+
});
|
|
441
|
+
return row;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private static _renderSeparatorLine(
|
|
445
|
+
boxW: number,
|
|
446
|
+
margin: number,
|
|
447
|
+
terminalWidth: number,
|
|
448
|
+
style: Required<ModalStyle>,
|
|
449
|
+
): Line {
|
|
450
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
451
|
+
const line = createOverlayBorderLine(terminalWidth, layout, GLYPHS.frame.teeLeft, GLYPHS.frame.horizontal, GLYPHS.frame.teeRight, style.borderFg);
|
|
452
|
+
for (let x = layout.margin + 1; x < layout.margin + layout.width - 1; x++) {
|
|
453
|
+
line[x] = createStyledCell(GLYPHS.frame.horizontal, { fg: style.borderFg, bg: style.sectionBg });
|
|
454
|
+
}
|
|
455
|
+
return line;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
private static _renderEmptyRow(
|
|
459
|
+
boxW: number,
|
|
460
|
+
margin: number,
|
|
461
|
+
terminalWidth: number,
|
|
462
|
+
style: Required<ModalStyle>,
|
|
463
|
+
): Line {
|
|
464
|
+
const layout = createOverlayBoxLayout(terminalWidth, margin, boxW);
|
|
465
|
+
return createOverlayContentLine(terminalWidth, layout, style.borderFg, style.surfaceBg);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared rendering utilities for modal components.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Format elapsed milliseconds as a compact duration string. */
|
|
6
|
+
export function formatDuration(ms: number): string {
|
|
7
|
+
if (ms < 1000) return `${ms}ms`;
|
|
8
|
+
const secs = Math.floor(ms / 1000);
|
|
9
|
+
if (secs < 60) return `${secs}s`;
|
|
10
|
+
const mins = Math.floor(secs / 60);
|
|
11
|
+
const remSecs = secs % 60;
|
|
12
|
+
return `${mins}m${remSecs}s`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Format a Unix millisecond timestamp as YYYY-MM-DD HH:MM.
|
|
17
|
+
* Returns '(unknown)' for falsy timestamps.
|
|
18
|
+
*/
|
|
19
|
+
export function formatTimestamp(ts: number): string {
|
|
20
|
+
if (!ts) return '(unknown)';
|
|
21
|
+
const d = new Date(ts);
|
|
22
|
+
const pad = (n: number) => String(n).padStart(2, '0');
|
|
23
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
24
|
+
}
|