gsd-pi 2.77.0-dev.c9c8932c6 → 2.77.0-dev.eaa4973bc
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/dist/cli-web-branch.d.ts +1 -0
- package/dist/cli-web-branch.js +3 -0
- package/dist/cli.js +24 -2
- package/dist/provider-migrations.d.ts +18 -0
- package/dist/provider-migrations.js +14 -0
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +14 -10
- package/dist/resources/extensions/gsd/abandon-detect.js +44 -0
- package/dist/resources/extensions/gsd/auto/resolve.js +24 -0
- package/dist/resources/extensions/gsd/auto/run-unit.js +10 -2
- package/dist/resources/extensions/gsd/auto/turn-epoch.js +95 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +24 -0
- package/dist/resources/extensions/gsd/auto-loop.js +1 -1
- package/dist/resources/extensions/gsd/auto-post-unit.js +31 -0
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +11 -5
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +11 -2
- package/dist/resources/extensions/gsd/auto-worktree.js +58 -8
- package/dist/resources/extensions/gsd/auto.js +4 -0
- package/dist/resources/extensions/gsd/bootstrap/provider-error-resume.js +4 -2
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +31 -4
- package/dist/resources/extensions/gsd/file-lock.js +49 -9
- package/dist/resources/extensions/gsd/git-service.js +1 -0
- package/dist/resources/extensions/gsd/gitignore.js +1 -0
- package/dist/resources/extensions/gsd/guided-flow-queue.js +4 -1
- package/dist/resources/extensions/gsd/journal.js +17 -2
- package/dist/resources/extensions/gsd/milestone-actions.js +15 -0
- package/dist/resources/extensions/gsd/reports.js +5 -4
- package/dist/resources/extensions/gsd/tools/complete-slice.js +21 -0
- package/dist/resources/extensions/gsd/tools/complete-task.js +31 -0
- package/dist/resources/extensions/gsd/uok/audit.js +18 -2
- package/dist/resources/extensions/gsd/workflow-logger.js +10 -2
- package/dist/resources/extensions/gsd/worktree-manager.js +1 -0
- package/dist/resources/extensions/mcp-client/auth.js +10 -1
- package/dist/resources/extensions/mcp-client/index.js +118 -9
- package/dist/resources/skills/create-skill/SKILL.md +2 -2
- package/dist/resources/skills/create-skill/references/gsd-skill-ecosystem.md +4 -4
- package/dist/resources/skills/create-skill/workflows/audit-skill.md +4 -4
- package/dist/resources/skills/create-skill/workflows/create-new-skill.md +5 -5
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- package/dist/web/standalone/.next/build-manifest.json +3 -3
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/react-loadable-manifest.json +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/boot/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/captures/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/cleanup/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/doctor/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/export-data/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/forensics/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/hooks/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/inspect/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/knowledge/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/live-state/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/notifications/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/recovery/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/browser/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/command/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/events/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/session/manage/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/settings-data/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/skill-health/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/steer/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/switch-root/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/undo/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/visualizer/route.js.nft.json +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
- package/dist/web/standalone/.next/server/chunks/1926.js +1 -0
- package/dist/web/standalone/.next/server/chunks/6897.js +1 -1
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web/standalone/.next/static/chunks/2826.e9f5195e91f9cad2.js +11 -0
- package/dist/web/standalone/.next/static/chunks/{webpack-1832629448831fdc.js → webpack-2e68521d7c82f7c2.js} +1 -1
- package/package.json +3 -3
- package/packages/mcp-server/README.md +3 -3
- package/packages/mcp-server/dist/env-writer.d.ts +1 -0
- package/packages/mcp-server/dist/env-writer.d.ts.map +1 -1
- package/packages/mcp-server/dist/env-writer.js +74 -6
- package/packages/mcp-server/dist/env-writer.js.map +1 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +25 -2
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/src/env-writer.test.ts +79 -1
- package/packages/mcp-server/src/env-writer.ts +76 -6
- package/packages/mcp-server/src/server.ts +29 -2
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +21 -16
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.test.js +130 -0
- package/packages/pi-coding-agent/dist/core/compaction-orchestrator.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts +1 -0
- package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.js +4 -1
- package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/sdk.test.js +19 -1
- package/packages/pi-coding-agent/dist/core/sdk.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/provider-display-name.test.js +15 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/__tests__/provider-display-name.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +14 -5
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +7 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js +31 -9
- package/packages/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.test.ts +154 -0
- package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +24 -17
- package/packages/pi-coding-agent/src/core/sdk.test.ts +25 -1
- package/packages/pi-coding-agent/src/core/sdk.ts +10 -3
- package/packages/pi-coding-agent/src/modes/interactive/components/__tests__/provider-display-name.test.ts +17 -7
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +14 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/model-selector.ts +45 -11
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
- package/packages/pi-tui/dist/__tests__/stdin-buffer.test.js +19 -0
- package/packages/pi-tui/dist/__tests__/stdin-buffer.test.js.map +1 -1
- package/packages/pi-tui/dist/stdin-buffer.d.ts +7 -0
- package/packages/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
- package/packages/pi-tui/dist/stdin-buffer.js +20 -0
- package/packages/pi-tui/dist/stdin-buffer.js.map +1 -1
- package/packages/pi-tui/src/__tests__/stdin-buffer.test.ts +25 -0
- package/packages/pi-tui/src/stdin-buffer.ts +26 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +14 -10
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +22 -16
- package/src/resources/extensions/gsd/abandon-detect.ts +62 -0
- package/src/resources/extensions/gsd/auto/resolve.ts +29 -0
- package/src/resources/extensions/gsd/auto/run-unit.ts +16 -2
- package/src/resources/extensions/gsd/auto/turn-epoch.ts +108 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +20 -0
- package/src/resources/extensions/gsd/auto-loop.ts +1 -1
- package/src/resources/extensions/gsd/auto-post-unit.ts +30 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +12 -5
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +14 -3
- package/src/resources/extensions/gsd/auto-worktree.ts +60 -5
- package/src/resources/extensions/gsd/auto.ts +5 -0
- package/src/resources/extensions/gsd/bootstrap/provider-error-resume.ts +6 -2
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +27 -8
- package/src/resources/extensions/gsd/file-lock.ts +84 -11
- package/src/resources/extensions/gsd/git-service.ts +1 -0
- package/src/resources/extensions/gsd/gitignore.ts +1 -0
- package/src/resources/extensions/gsd/guided-flow-queue.ts +4 -1
- package/src/resources/extensions/gsd/journal.ts +27 -2
- package/src/resources/extensions/gsd/milestone-actions.ts +18 -0
- package/src/resources/extensions/gsd/reports.ts +5 -4
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +11 -2
- package/src/resources/extensions/gsd/tests/auto-mode-guards.test.ts +79 -0
- package/src/resources/extensions/gsd/tests/file-lock.test.ts +86 -12
- package/src/resources/extensions/gsd/tests/integration/auto-worktree-milestone-merge.test.ts +30 -0
- package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/mcp-client-security.test.ts +76 -0
- package/src/resources/extensions/gsd/tests/provider-errors.test.ts +39 -25
- package/src/resources/extensions/gsd/tests/queue-auto-guard.test.ts +181 -0
- package/src/resources/extensions/gsd/tests/quick-auto-guard.test.ts +13 -7
- package/src/resources/extensions/gsd/tests/require-slice-discussion-dispatch.test.ts +170 -0
- package/src/resources/extensions/gsd/tests/rewrite-docs-abandon-detect.test.ts +195 -0
- package/src/resources/extensions/gsd/tests/stuck-detection-coverage.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/triage-resolution.test.ts +50 -2
- package/src/resources/extensions/gsd/tests/turn-epoch.test.ts +162 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +38 -0
- package/src/resources/extensions/gsd/tools/complete-task.ts +49 -0
- package/src/resources/extensions/gsd/uok/audit.ts +20 -2
- package/src/resources/extensions/gsd/workflow-logger.ts +22 -3
- package/src/resources/extensions/gsd/worktree-manager.ts +1 -0
- package/src/resources/extensions/mcp-client/auth.ts +12 -1
- package/src/resources/extensions/mcp-client/index.ts +129 -10
- package/src/resources/skills/create-skill/SKILL.md +2 -2
- package/src/resources/skills/create-skill/references/gsd-skill-ecosystem.md +4 -4
- package/src/resources/skills/create-skill/workflows/audit-skill.md +4 -4
- package/src/resources/skills/create-skill/workflows/create-new-skill.md +5 -5
- package/dist/web/standalone/.next/server/chunks/7461.js +0 -1
- package/dist/web/standalone/.next/static/chunks/2826.d445fb428ef41fa1.js +0 -9
- /package/dist/web/standalone/.next/static/{H51SzzS_EEgdBsDVhrLBv → 5wbu35_C2_MQ3Jj1lEVDx}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{H51SzzS_EEgdBsDVhrLBv → 5wbu35_C2_MQ3Jj1lEVDx}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACvC,qFAAqF;IACrF,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;SACzB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACV,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,KAAa;IAClC,IAAI,KAAK,G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,CAAC;QACjE,MAAM,aAAa,GAClB,iBAAiB,CAAC,IAAI,GAAG,CAAC;YACzB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;iBACtC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;iBACtC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;iBAC3C,IAAI,CAAC,GAAG,CAAC;YACZ,CAAC,CAAC,EAAE,CAAC;QAEP,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,OAAe,CAAC;QACpB,IAAI,aAAa,IAAI,QAAQ,GAAG,CAAC,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;YACvD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;YACxD,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,GAAG,aAAa,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@gsd/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { providerDisplayName } from \"./model-selector.js\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts (similar to web-ui)\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\n/**\n * Format a cost value for compact display.\n * Uses fewer decimal places for larger amounts.\n * @internal Exported for testing only.\n */\nexport function formatPromptCost(cost: number): string {\n\tif (cost < 0.001) return `$${cost.toFixed(4)}`;\n\tif (cost < 0.01) return `$${cost.toFixed(3)}`;\n\tif (cost < 1) return `$${cost.toFixed(3)}`;\n\treturn `$${cost.toFixed(2)}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\n\tconstructor(\n\t\tprivate session: AgentSession,\n\t\tprivate footerData: ReadonlyFooterDataProvider,\n\t) {}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\n\t\tconst usageTotals = this.session.sessionManager.getUsageTotals();\n\t\tconst totalInput = usageTotals.input;\n\t\tconst totalOutput = usageTotals.output;\n\t\tconst totalCacheRead = usageTotals.cacheRead;\n\t\tconst totalCacheWrite = usageTotals.cacheWrite;\n\t\tconst totalCost = usageTotals.cost;\n\n\t\t// Use activeInferenceModel during streaming to show the model actually\n\t\t// being used, not the configured model which may have been switched mid-turn.\n\t\tconst displayModel = state.activeInferenceModel ?? state.model;\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = this.session.getContextUsage();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? displayModel?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = process.cwd();\n\t\tconst home = process.env.HOME || process.env.USERPROFILE;\n\t\tif (home && pwd.startsWith(home)) {\n\t\t\tpwd = `~${pwd.slice(home.length)}`;\n\t\t}\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line as separate groups joined by a dim middle-dot separator\n\t\tconst sep = ` ${theme.fg(\"dim\", \"\\u00B7\")} `;\n\n\t\t// Group 1: total tokens.\n\t\tconst tokenGroup: string[] = [];\n\t\tconst totalTokens = totalInput + totalOutput + totalCacheRead + totalCacheWrite;\n\t\tif (totalTokens > 0) tokenGroup.push(formatTokens(totalTokens));\n\n\t\t// Group 2: cache efficiency — cacheRead / all input-side tokens.\n\t\t// Collapses the old cr/cw pair into a single \"how much was served\n\t\t// from cache\" signal. cr/cw breakdown moved to `/stats`.\n\t\tconst cacheGroup: string[] = [];\n\t\tconst inputSide = totalInput + totalCacheRead + totalCacheWrite;\n\t\tif (totalCacheRead > 0 && inputSide > 0) {\n\t\t\tconst cachedPct = Math.round((totalCacheRead / inputSide) * 100);\n\t\t\tcacheGroup.push(`${cachedPct}% cached`);\n\t\t}\n\n\t\t// Group 3: cost\n\t\tconst costGroup: string[] = [];\n\t\tconst usingSubscription = displayModel ? this.session.modelRegistry.isUsingOAuth(displayModel) : false;\n\t\tif (totalCost || usingSubscription) {\n\t\t\tconst costStr = `$${totalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tcostGroup.push(costStr);\n\t\t}\n\n\t\t// Per-prompt cost annotation (opt-in via show_token_cost preference, #1515)\n\t\tif (process.env.GSD_SHOW_TOKEN_COST === \"1\") {\n\t\t\tconst lastTurnCost = this.session.getLastTurnCost();\n\t\t\tif (lastTurnCost > 0) {\n\t\t\t\tcostGroup.push(`(last: ${formatPromptCost(lastTurnCost)})`);\n\t\t\t}\n\t\t}\n\n\t\t// Group 4: context bar + percentage (mirrors /gsd auto dashboard style).\n\t\t// Bar colors track the same thresholds as the percent text.\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst barColor: \"error\" | \"warning\" | \"success\" =\n\t\t\tcontextPercentValue > 90 ? \"error\" : contextPercentValue > 70 ? \"warning\" : \"success\";\n\t\tconst BAR_WIDTH = 8;\n\t\tconst filled = contextUsage?.percent !== null\n\t\t\t? Math.max(0, Math.min(BAR_WIDTH, Math.round((contextPercentValue / 100) * BAR_WIDTH)))\n\t\t\t: 0;\n\t\tconst bar =\n\t\t\ttheme.fg(barColor, \"━\".repeat(filled)) +\n\t\t\ttheme.fg(\"dim\", \"─\".repeat(Math.max(0, BAR_WIDTH - filled)));\n\t\tconst pctText = contextPercent === \"?\" ? \"?\" : `${contextPercent}%`;\n\t\tconst suffix = `/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tconst colorizedPct =\n\t\t\tcontextPercentValue > 90\n\t\t\t\t? theme.fg(\"error\", pctText)\n\t\t\t\t: contextPercentValue > 70\n\t\t\t\t\t? theme.fg(\"warning\", pctText)\n\t\t\t\t\t: pctText;\n\t\tconst contextPercentStr = `${bar} ${colorizedPct}${suffix}`;\n\n\t\t// Assemble groups: items within a group are space-separated,\n\t\t// groups are separated by a dim middle-dot\n\t\tconst groups: string[] = [];\n\t\tif (tokenGroup.length > 0) groups.push(tokenGroup.join(\" \"));\n\t\tif (cacheGroup.length > 0) groups.push(cacheGroup.join(\" \"));\n\t\tif (costGroup.length > 0) groups.push(costGroup.join(\" \"));\n\t\tgroups.push(contextPercentStr);\n\n\t\tlet statsLeft = groups.join(sep);\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = displayModel?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (displayModel?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && displayModel) {\n\t\t\trightSide = `(${providerDisplayName(displayModel.provider)}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide, fall back\n\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\t// Extension statuses right-aligned on the pwd line (sorted by key).\n\t\t// Keeps the footer compact by avoiding a dedicated row when the content\n\t\t// fits alongside pwd. Falls back to pwd-only if the combined line would\n\t\t// exceed width.\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tconst extStatusText =\n\t\t\textensionStatuses.size > 0\n\t\t\t\t? Array.from(extensionStatuses.entries())\n\t\t\t\t\t\t.sort(([a], [b]) => a.localeCompare(b))\n\t\t\t\t\t\t.map(([, text]) => sanitizeStatusText(text))\n\t\t\t\t\t\t.join(\" \")\n\t\t\t\t: \"\";\n\n\t\tconst pwdWidth = visibleWidth(pwd);\n\t\tconst extWidth = visibleWidth(extStatusText);\n\t\tlet pwdLine: string;\n\t\tif (extStatusText && pwdWidth + 2 + extWidth <= width) {\n\t\t\tconst padding = \" \".repeat(width - pwdWidth - extWidth);\n\t\t\tpwdLine = theme.fg(\"dim\", pwd + padding + extStatusText);\n\t\t} else {\n\t\t\tpwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\t}\n\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG5E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE7E;;;GAGG;AACH,SAAS,kBAAkB,CAAC,IAAY;IACvC,qFAAqF;IACrF,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;SACzB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACV,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,KAAa;IAClC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1C,IAAI,KAAK,GAAG,KAAK;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,IAAI,KAAK,GAAG,OAAO;QAAE,OAAO,GAAG,IAAI,CAAC,KA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AC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;QAErD,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@gsd/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { providerAuthBadge, providerDisplayName } from \"./model-selector.js\";\n\n/**\n * Sanitize text for display in a single-line status.\n * Removes newlines, tabs, carriage returns, and other control characters.\n */\nfunction sanitizeStatusText(text: string): string {\n\t// Replace newlines, tabs, carriage returns with space, then collapse multiple spaces\n\treturn text\n\t\t.replace(/[\\r\\n\\t]/g, \" \")\n\t\t.replace(/ +/g, \" \")\n\t\t.trim();\n}\n\n/**\n * Format token counts (similar to web-ui)\n */\nfunction formatTokens(count: number): string {\n\tif (count < 1000) return count.toString();\n\tif (count < 10000) return `${(count / 1000).toFixed(1)}k`;\n\tif (count < 1000000) return `${Math.round(count / 1000)}k`;\n\tif (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;\n\treturn `${Math.round(count / 1000000)}M`;\n}\n\n/**\n * Format a cost value for compact display.\n * Uses fewer decimal places for larger amounts.\n * @internal Exported for testing only.\n */\nexport function formatPromptCost(cost: number): string {\n\tif (cost < 0.001) return `$${cost.toFixed(4)}`;\n\tif (cost < 0.01) return `$${cost.toFixed(3)}`;\n\tif (cost < 1) return `$${cost.toFixed(3)}`;\n\treturn `$${cost.toFixed(2)}`;\n}\n\n/**\n * Footer component that shows pwd, token stats, and context usage.\n * Computes token/context stats from session, gets git branch and extension statuses from provider.\n */\nexport class FooterComponent implements Component {\n\tprivate autoCompactEnabled = true;\n\n\tconstructor(\n\t\tprivate session: AgentSession,\n\t\tprivate footerData: ReadonlyFooterDataProvider,\n\t) {}\n\n\tsetAutoCompactEnabled(enabled: boolean): void {\n\t\tthis.autoCompactEnabled = enabled;\n\t}\n\n\t/**\n\t * No-op: git branch caching now handled by provider.\n\t * Kept for compatibility with existing call sites in interactive-mode.\n\t */\n\tinvalidate(): void {\n\t\t// No-op: git branch is cached/invalidated by provider\n\t}\n\n\t/**\n\t * Clean up resources.\n\t * Git watcher cleanup now handled by provider.\n\t */\n\tdispose(): void {\n\t\t// Git watcher cleanup handled by provider\n\t}\n\n\trender(width: number): string[] {\n\t\tconst state = this.session.state;\n\n\t\tconst usageTotals = this.session.sessionManager.getUsageTotals();\n\t\tconst totalInput = usageTotals.input;\n\t\tconst totalOutput = usageTotals.output;\n\t\tconst totalCacheRead = usageTotals.cacheRead;\n\t\tconst totalCacheWrite = usageTotals.cacheWrite;\n\t\tconst totalCost = usageTotals.cost;\n\n\t\t// Use activeInferenceModel during streaming to show the model actually\n\t\t// being used, not the configured model which may have been switched mid-turn.\n\t\tconst displayModel = state.activeInferenceModel ?? state.model;\n\n\t\t// Calculate context usage from session (handles compaction correctly).\n\t\t// After compaction, tokens are unknown until the next LLM response.\n\t\tconst contextUsage = this.session.getContextUsage();\n\t\tconst contextWindow = contextUsage?.contextWindow ?? displayModel?.contextWindow ?? 0;\n\t\tconst contextPercentValue = contextUsage?.percent ?? 0;\n\t\tconst contextPercent = contextUsage?.percent !== null ? contextPercentValue.toFixed(1) : \"?\";\n\n\t\t// Replace home directory with ~\n\t\tlet pwd = process.cwd();\n\t\tconst home = process.env.HOME || process.env.USERPROFILE;\n\t\tif (home && pwd.startsWith(home)) {\n\t\t\tpwd = `~${pwd.slice(home.length)}`;\n\t\t}\n\n\t\t// Add git branch if available\n\t\tconst branch = this.footerData.getGitBranch();\n\t\tif (branch) {\n\t\t\tpwd = `${pwd} (${branch})`;\n\t\t}\n\n\t\t// Add session name if set\n\t\tconst sessionName = this.session.sessionManager.getSessionName();\n\t\tif (sessionName) {\n\t\t\tpwd = `${pwd} • ${sessionName}`;\n\t\t}\n\n\t\t// Build stats line as separate groups joined by a dim middle-dot separator\n\t\tconst sep = ` ${theme.fg(\"dim\", \"\\u00B7\")} `;\n\n\t\t// Group 1: total tokens.\n\t\tconst tokenGroup: string[] = [];\n\t\tconst totalTokens = totalInput + totalOutput + totalCacheRead + totalCacheWrite;\n\t\tif (totalTokens > 0) tokenGroup.push(formatTokens(totalTokens));\n\n\t\t// Group 2: cache efficiency — cacheRead / all input-side tokens.\n\t\t// Collapses the old cr/cw pair into a single \"how much was served\n\t\t// from cache\" signal. cr/cw breakdown moved to `/stats`.\n\t\tconst cacheGroup: string[] = [];\n\t\tconst inputSide = totalInput + totalCacheRead + totalCacheWrite;\n\t\tif (totalCacheRead > 0 && inputSide > 0) {\n\t\t\tconst cachedPct = Math.round((totalCacheRead / inputSide) * 100);\n\t\t\tcacheGroup.push(`${cachedPct}% cached`);\n\t\t}\n\n\t\t// Group 3: cost\n\t\tconst costGroup: string[] = [];\n\t\tconst usingSubscription = displayModel ? this.session.modelRegistry.isUsingOAuth(displayModel) : false;\n\t\tif (totalCost || usingSubscription) {\n\t\t\tconst costStr = `$${totalCost.toFixed(3)}${usingSubscription ? \" (sub)\" : \"\"}`;\n\t\t\tcostGroup.push(costStr);\n\t\t}\n\n\t\t// Per-prompt cost annotation (opt-in via show_token_cost preference, #1515)\n\t\tif (process.env.GSD_SHOW_TOKEN_COST === \"1\") {\n\t\t\tconst lastTurnCost = this.session.getLastTurnCost();\n\t\t\tif (lastTurnCost > 0) {\n\t\t\t\tcostGroup.push(`(last: ${formatPromptCost(lastTurnCost)})`);\n\t\t\t}\n\t\t}\n\n\t\t// Group 4: context bar + percentage (mirrors /gsd auto dashboard style).\n\t\t// Bar colors track the same thresholds as the percent text.\n\t\tconst autoIndicator = this.autoCompactEnabled ? \" (auto)\" : \"\";\n\t\tconst barColor: \"error\" | \"warning\" | \"success\" =\n\t\t\tcontextPercentValue > 90 ? \"error\" : contextPercentValue > 70 ? \"warning\" : \"success\";\n\t\tconst BAR_WIDTH = 8;\n\t\tconst filled = contextUsage?.percent !== null\n\t\t\t? Math.max(0, Math.min(BAR_WIDTH, Math.round((contextPercentValue / 100) * BAR_WIDTH)))\n\t\t\t: 0;\n\t\tconst bar =\n\t\t\ttheme.fg(barColor, \"━\".repeat(filled)) +\n\t\t\ttheme.fg(\"dim\", \"─\".repeat(Math.max(0, BAR_WIDTH - filled)));\n\t\tconst pctText = contextPercent === \"?\" ? \"?\" : `${contextPercent}%`;\n\t\tconst suffix = `/${formatTokens(contextWindow)}${autoIndicator}`;\n\t\tconst colorizedPct =\n\t\t\tcontextPercentValue > 90\n\t\t\t\t? theme.fg(\"error\", pctText)\n\t\t\t\t: contextPercentValue > 70\n\t\t\t\t\t? theme.fg(\"warning\", pctText)\n\t\t\t\t\t: pctText;\n\t\tconst contextPercentStr = `${bar} ${colorizedPct}${suffix}`;\n\n\t\t// Assemble groups: items within a group are space-separated,\n\t\t// groups are separated by a dim middle-dot\n\t\tconst groups: string[] = [];\n\t\tif (tokenGroup.length > 0) groups.push(tokenGroup.join(\" \"));\n\t\tif (cacheGroup.length > 0) groups.push(cacheGroup.join(\" \"));\n\t\tif (costGroup.length > 0) groups.push(costGroup.join(\" \"));\n\t\tgroups.push(contextPercentStr);\n\n\t\tlet statsLeft = groups.join(sep);\n\n\t\t// Add model name on the right side, plus thinking level if model supports it\n\t\tconst modelName = displayModel?.id || \"no-model\";\n\n\t\tlet statsLeftWidth = visibleWidth(statsLeft);\n\n\t\t// If statsLeft is too wide, truncate it\n\t\tif (statsLeftWidth > width) {\n\t\t\tstatsLeft = truncateToWidth(statsLeft, width, \"...\");\n\t\t\tstatsLeftWidth = visibleWidth(statsLeft);\n\t\t}\n\n\t\t// Calculate available space for padding (minimum 2 spaces between stats and model)\n\t\tconst minPadding = 2;\n\n\t\t// Add thinking level indicator if model supports reasoning\n\t\tlet rightSideWithoutProvider = modelName;\n\t\tif (displayModel?.reasoning) {\n\t\t\tconst thinkingLevel = state.thinkingLevel || \"off\";\n\t\t\trightSideWithoutProvider =\n\t\t\t\tthinkingLevel === \"off\" ? `${modelName} • thinking off` : `${modelName} • ${thinkingLevel}`;\n\t\t}\n\n\t\t// Prepend the provider in parentheses if there are multiple providers and there's enough room.\n\t\t// Include the auth mode so users can tell at a glance whether the active model is\n\t\t// API-key-backed, OAuth-backed, or delegated to a third-party CLI.\n\t\tlet rightSide = rightSideWithoutProvider;\n\t\tif (this.footerData.getAvailableProviderCount() > 1 && displayModel) {\n\t\t\tconst authMode = this.session.modelRegistry.getProviderAuthMode(displayModel.provider);\n\t\t\tconst authLabel = providerAuthBadge(authMode);\n\t\t\tconst providerLabel = providerDisplayName(displayModel.provider);\n\t\t\tconst parenthetical = authLabel ? `${providerLabel} · ${authLabel}` : providerLabel;\n\t\t\trightSide = `(${parenthetical}) ${rightSideWithoutProvider}`;\n\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t// Too wide: drop the auth suffix first, then fall back to no parenthetical.\n\t\t\t\trightSide = `(${providerLabel}) ${rightSideWithoutProvider}`;\n\t\t\t\tif (statsLeftWidth + minPadding + visibleWidth(rightSide) > width) {\n\t\t\t\t\trightSide = rightSideWithoutProvider;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst rightSideWidth = visibleWidth(rightSide);\n\t\tconst totalNeeded = statsLeftWidth + minPadding + rightSideWidth;\n\n\t\tlet statsLine: string;\n\t\tif (totalNeeded <= width) {\n\t\t\t// Both fit - add padding to right-align model\n\t\t\tconst padding = \" \".repeat(width - statsLeftWidth - rightSideWidth);\n\t\t\tstatsLine = statsLeft + padding + rightSide;\n\t\t} else {\n\t\t\t// Need to truncate right side\n\t\t\tconst availableForRight = width - statsLeftWidth - minPadding;\n\t\t\tif (availableForRight > 0) {\n\t\t\t\tconst truncatedRight = truncateToWidth(rightSide, availableForRight, \"\");\n\t\t\t\tconst truncatedRightWidth = visibleWidth(truncatedRight);\n\t\t\t\tconst padding = \" \".repeat(Math.max(0, width - statsLeftWidth - truncatedRightWidth));\n\t\t\t\tstatsLine = statsLeft + padding + truncatedRight;\n\t\t\t} else {\n\t\t\t\t// Not enough space for right side at all\n\t\t\t\tstatsLine = statsLeft;\n\t\t\t}\n\t\t}\n\n\t\t// Apply dim to each part separately. statsLeft may contain color codes (for context %)\n\t\t// that end with a reset, which would clear an outer dim wrapper. So we dim the parts\n\t\t// before and after the colored section independently.\n\t\tconst dimStatsLeft = theme.fg(\"dim\", statsLeft);\n\t\tconst remainder = statsLine.slice(statsLeft.length); // padding + rightSide\n\t\tconst dimRemainder = theme.fg(\"dim\", remainder);\n\n\t\t// Extension statuses right-aligned on the pwd line (sorted by key).\n\t\t// Keeps the footer compact by avoiding a dedicated row when the content\n\t\t// fits alongside pwd. Falls back to pwd-only if the combined line would\n\t\t// exceed width.\n\t\tconst extensionStatuses = this.footerData.getExtensionStatuses();\n\t\tconst extStatusText =\n\t\t\textensionStatuses.size > 0\n\t\t\t\t? Array.from(extensionStatuses.entries())\n\t\t\t\t\t\t.sort(([a], [b]) => a.localeCompare(b))\n\t\t\t\t\t\t.map(([, text]) => sanitizeStatusText(text))\n\t\t\t\t\t\t.join(\" \")\n\t\t\t\t: \"\";\n\n\t\tconst pwdWidth = visibleWidth(pwd);\n\t\tconst extWidth = visibleWidth(extStatusText);\n\t\tlet pwdLine: string;\n\t\tif (extStatusText && pwdWidth + 2 + extWidth <= width) {\n\t\t\tconst padding = \" \".repeat(width - pwdWidth - extWidth);\n\t\t\tpwdLine = theme.fg(\"dim\", pwd + padding + extStatusText);\n\t\t} else {\n\t\t\tpwdLine = truncateToWidth(theme.fg(\"dim\", pwd), width, theme.fg(\"dim\", \"...\"));\n\t\t}\n\n\t\tconst lines = [pwdLine, dimStatsLeft + dimRemainder];\n\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type Model } from "@gsd/pi-ai";
|
|
2
2
|
import { Container, type Focusable, Input, type TUI } from "@gsd/pi-tui";
|
|
3
|
-
import type { ModelRegistry } from "../../../core/model-registry.js";
|
|
3
|
+
import type { ModelRegistry, ProviderAuthMode } from "../../../core/model-registry.js";
|
|
4
4
|
import type { SettingsManager } from "../../../core/settings-manager.js";
|
|
5
5
|
export declare function providerDisplayName(provider: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Short, user-facing label for a provider's auth mode. Returned strings are
|
|
8
|
+
* suitable for use as a suffix/badge alongside the provider name.
|
|
9
|
+
* Returns an empty string for modes that don't need a badge (e.g. "none").
|
|
10
|
+
*/
|
|
11
|
+
export declare function providerAuthBadge(authMode?: ProviderAuthMode): string;
|
|
6
12
|
interface ScopedModelItem {
|
|
7
13
|
model: Model<any>;
|
|
8
14
|
thinkingLevel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAkB,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,SAAS,EACT,KAAK,SAAS,EAGd,KAAK,EAGL,KAAK,GAAG,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"model-selector.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAkB,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,SAAS,EACT,KAAK,SAAS,EAGd,KAAK,EAGL,KAAK,GAAG,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAKzE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GA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E,aAAa,CAAC,eAAe,CAAC,EAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EACrC,QAAQ,EAAE,MAAM,IAAI,EACpB,kBAAkB,CAAC,EAAE,MAAM;YA8Ed,UAAU;IA+CxB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAehC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAoCxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmB1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,UAAU;IAkBlB,4DAA4D;IAC5D,OAAO,CAAC,cAAc;IA2DtB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAqFzB,OAAO,CAAC,eAAe;IAYvB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAiElC,0DAA0D;IAC1D,OAAO,CAAC,MAAM;IA2Bd,4DAA4D;IAC5D,OAAO,CAAC,QAAQ;IA2BhB,OAAO,CAAC,YAAY;IAMpB,cAAc,IAAI,KAAK;CAGvB"}
|
|
@@ -3,12 +3,25 @@ import { Container, fuzzyFilter, getEditorKeybindings, Input, Spacer, Text, } fr
|
|
|
3
3
|
import { theme } from "../theme/theme.js";
|
|
4
4
|
import { DynamicBorder } from "./dynamic-border.js";
|
|
5
5
|
import { keyHint } from "./keybinding-hints.js";
|
|
6
|
-
/** Display names for providers in the model selector UI. */
|
|
7
|
-
const PROVIDER_DISPLAY_NAMES = {
|
|
8
|
-
anthropic: "anthropic-api",
|
|
9
|
-
};
|
|
10
6
|
export function providerDisplayName(provider) {
|
|
11
|
-
return
|
|
7
|
+
return provider;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Short, user-facing label for a provider's auth mode. Returned strings are
|
|
11
|
+
* suitable for use as a suffix/badge alongside the provider name.
|
|
12
|
+
* Returns an empty string for modes that don't need a badge (e.g. "none").
|
|
13
|
+
*/
|
|
14
|
+
export function providerAuthBadge(authMode) {
|
|
15
|
+
switch (authMode) {
|
|
16
|
+
case "apiKey":
|
|
17
|
+
return "API key";
|
|
18
|
+
case "oauth":
|
|
19
|
+
return "OAuth";
|
|
20
|
+
case "externalCli":
|
|
21
|
+
return "CLI";
|
|
22
|
+
default:
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
26
|
function formatTokenCount(count) {
|
|
14
27
|
if (count >= 1_000_000) {
|
|
@@ -75,7 +88,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
75
88
|
this.addChild(this.scopeHintText);
|
|
76
89
|
}
|
|
77
90
|
else {
|
|
78
|
-
const hintText = "Only showing models with configured API
|
|
91
|
+
const hintText = "Only showing models with configured credentials (API key, OAuth, or CLI). See README for details.";
|
|
79
92
|
this.addChild(new Text(theme.fg("warning", hintText), 0, 0));
|
|
80
93
|
}
|
|
81
94
|
this.addChild(new Spacer(1));
|
|
@@ -315,7 +328,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
315
328
|
const isCurrent = modelsAreEqual(this.currentModel, item.model);
|
|
316
329
|
const ctx = formatTokenCount(item.model.contextWindow);
|
|
317
330
|
const ctxBadge = theme.fg("muted", `${ctx}`);
|
|
318
|
-
const
|
|
331
|
+
const authMode = this.modelRegistry.getProviderAuthMode(item.provider);
|
|
332
|
+
const authLabel = providerAuthBadge(authMode);
|
|
333
|
+
const providerBadgeText = authLabel
|
|
334
|
+
? `[${providerDisplayName(item.provider)} · ${authLabel}]`
|
|
335
|
+
: `[${providerDisplayName(item.provider)}]`;
|
|
336
|
+
const providerBadge = theme.fg("muted", providerBadgeText);
|
|
319
337
|
const checkmark = isCurrent ? theme.fg("success", " ✓") : "";
|
|
320
338
|
let line;
|
|
321
339
|
if (isSelected) {
|
|
@@ -344,7 +362,8 @@ export class ModelSelectorComponent extends Container {
|
|
|
344
362
|
renderGroupedList() {
|
|
345
363
|
const maxVisible = 12;
|
|
346
364
|
if (this.groupedRows.length === 0) {
|
|
347
|
-
this.listContainer.addChild(new Text(theme.fg("muted", " No
|
|
365
|
+
this.listContainer.addChild(new Text(theme.fg("muted", " No providers configured."), 0, 0));
|
|
366
|
+
this.listContainer.addChild(new Text(theme.fg("muted", " Run /login (OAuth), set an API key, or install a CLI provider. See README."), 0, 0));
|
|
348
367
|
return;
|
|
349
368
|
}
|
|
350
369
|
// Window around selectedGroupIndex
|
|
@@ -358,11 +377,14 @@ export class ModelSelectorComponent extends Container {
|
|
|
358
377
|
// Provider group header — always unselectable
|
|
359
378
|
const providerLabel = theme.fg("borderAccent", providerDisplayName(row.provider));
|
|
360
379
|
const count = theme.fg("muted", ` (${row.count})`);
|
|
380
|
+
const authMode = this.modelRegistry.getProviderAuthMode(row.provider);
|
|
381
|
+
const authLabel = providerAuthBadge(authMode);
|
|
382
|
+
const authText = authLabel ? theme.fg("muted", ` · via ${authLabel}`) : "";
|
|
361
383
|
// Add blank line before header if not the very first visible row
|
|
362
384
|
if (i > startIndex) {
|
|
363
385
|
this.listContainer.addChild(new Text("", 0, 0));
|
|
364
386
|
}
|
|
365
|
-
this.listContainer.addChild(new Text(` ${providerLabel}${count}`, 0, 0));
|
|
387
|
+
this.listContainer.addChild(new Text(` ${providerLabel}${count}${authText}`, 0, 0));
|
|
366
388
|
}
|
|
367
389
|
else {
|
|
368
390
|
// Model row
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,SAAS,EAET,WAAW,EACX,oBAAoB,EACpB,KAAK,EACL,MAAM,EACN,IAAI,GAEJ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,C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gsd/pi-ai\";\nimport {\n\tContainer,\n\ttype Focusable,\n\tfuzzyFilter,\n\tgetEditorKeybindings,\n\tInput,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@gsd/pi-tui\";\nimport type { ModelRegistry } from \"../../../core/model-registry.js\";\nimport type { SettingsManager } from \"../../../core/settings-manager.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyHint } from \"./keybinding-hints.js\";\n\n/** Display names for providers in the model selector UI. */\nconst PROVIDER_DISPLAY_NAMES: Record<string, string> = {\n\tanthropic: \"anthropic-api\",\n};\n\nexport function providerDisplayName(provider: string): string {\n\treturn PROVIDER_DISPLAY_NAMES[provider] ?? provider;\n}\n\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\ninterface ModelItem {\n\tprovider: string;\n\tid: string;\n\tmodel: Model<any>;\n}\n\ninterface ScopedModelItem {\n\tmodel: Model<any>;\n\tthinkingLevel?: string;\n}\n\n/**\n * A navigable row — either a provider group header or a selectable model entry.\n */\ntype ListRow =\n\t| { kind: \"header\"; provider: string; count: number }\n\t| { kind: \"model\"; item: ModelItem };\n\ntype ModelScope = \"all\" | \"scoped\";\n\n/**\n * Component that renders a grouped model selector with search.\n *\n * Browsing (no search): models are grouped under provider headers.\n * - Current model's provider is shown first; remaining providers sorted alphabetically.\n * - Arrow keys navigate all rows; headers are skipped during selection.\n * Searching: reverts to a flat fuzzy-filtered list (same as before), with [provider] badges.\n */\nexport class ModelSelectorComponent extends Container implements Focusable {\n\tprivate searchInput: Input;\n\n\t// Focusable implementation - propagate to searchInput for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\tprivate listContainer: Container;\n\tprivate allModels: ModelItem[] = [];\n\tprivate scopedModelItems: ModelItem[] = [];\n\tprivate activeModels: ModelItem[] = [];\n\n\t// Grouped (browse) state\n\tprivate groupedRows: ListRow[] = [];\n\tprivate modelRowIndices: number[] = []; // indices into groupedRows that are \"model\" kind\n\tprivate selectedGroupIndex: number = 0; // index into groupedRows (can be model or header)\n\n\t// Search (flat) state\n\tprivate filteredModels: ModelItem[] = [];\n\tprivate selectedFlatIndex: number = 0;\n\n\tprivate isSearching: boolean = false;\n\tprivate currentModel?: Model<any>;\n\tprivate settingsManager: SettingsManager;\n\tprivate modelRegistry: ModelRegistry;\n\tprivate onSelectCallback: (model: Model<any>) => void;\n\tprivate onCancelCallback: () => void;\n\tprivate errorMessage?: string;\n\tprivate tui: TUI;\n\tprivate scopedModels: ReadonlyArray<ScopedModelItem>;\n\tprivate scope: ModelScope = \"all\";\n\tprivate scopeText?: Text;\n\tprivate scopeHintText?: Text;\n\n\tconstructor(\n\t\ttui: TUI,\n\t\tcurrentModel: Model<any> | undefined,\n\t\tsettingsManager: SettingsManager,\n\t\tmodelRegistry: ModelRegistry,\n\t\tscopedModels: ReadonlyArray<ScopedModelItem>,\n\t\tonSelect: (model: Model<any>) => void,\n\t\tonCancel: () => void,\n\t\tinitialSearchInput?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.tui = tui;\n\t\tthis.currentModel = currentModel;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.modelRegistry = modelRegistry;\n\t\tthis.scopedModels = scopedModels;\n\t\t// Only land in \"scoped\" view when at least one scoped model has working\n\t\t// auth — otherwise the user would see an empty picker (#unconfigured-models).\n\t\tconst hasReadyScopedModel = scopedModels.some((scoped) =>\n\t\t\tmodelRegistry.isProviderRequestReady(scoped.model.provider),\n\t\t);\n\t\tthis.scope = hasReadyScopedModel ? \"scoped\" : \"all\";\n\t\tthis.onSelectCallback = onSelect;\n\t\tthis.onCancelCallback = onCancel;\n\n\t\t// Add top border\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add hint about model filtering\n\t\tif (scopedModels.length > 0) {\n\t\t\tthis.scopeText = new Text(this.getScopeText(), 0, 0);\n\t\t\tthis.addChild(this.scopeText);\n\t\t\tthis.scopeHintText = new Text(this.getScopeHintText(), 0, 0);\n\t\t\tthis.addChild(this.scopeHintText);\n\t\t} else {\n\t\t\tconst hintText = \"Only showing models with configured API keys (see README for details)\";\n\t\t\tthis.addChild(new Text(theme.fg(\"warning\", hintText), 0, 0));\n\t\t}\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create search input\n\t\tthis.searchInput = new Input();\n\t\tif (initialSearchInput) {\n\t\t\tthis.searchInput.setValue(initialSearchInput);\n\t\t}\n\t\tthis.searchInput.onSubmit = () => {\n\t\t\tif (this.isSearching) {\n\t\t\t\tif (this.filteredModels[this.selectedFlatIndex]) {\n\t\t\t\t\tthis.handleSelect(this.filteredModels[this.selectedFlatIndex].model);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst model = this.getSelectedModel();\n\t\t\t\tif (model) this.handleSelect(model);\n\t\t\t}\n\t\t};\n\t\tthis.addChild(this.searchInput);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create list container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add bottom border\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Load models and do initial render\n\t\tthis.loadModels().then(() => {\n\t\t\tif (initialSearchInput) {\n\t\t\t\tthis.isSearching = true;\n\t\t\t\tthis.filterModels(initialSearchInput);\n\t\t\t} else {\n\t\t\t\tthis.buildGroupedRows();\n\t\t\t\tthis.jumpToCurrentModel();\n\t\t\t\tthis.updateList();\n\t\t\t}\n\t\t\t// Request re-render after models are loaded\n\t\t\tthis.tui.requestRender();\n\t\t});\n\t}\n\n\tprivate async loadModels(): Promise<void> {\n\t\tlet models: ModelItem[];\n\n\t\t// Refresh to pick up any changes to models.json\n\t\tthis.modelRegistry.refresh();\n\n\t\t// Check for models.json errors\n\t\tconst loadError = this.modelRegistry.getError();\n\t\tif (loadError) {\n\t\t\tthis.errorMessage = loadError;\n\t\t}\n\n\t\t// Load available models (built-in models still work even if models.json failed)\n\t\ttry {\n\t\t\tconst availableModels = this.modelRegistry.getAvailable();\n\t\t\tmodels = availableModels.map((model: Model<any>) => ({\n\t\t\t\tprovider: model.provider,\n\t\t\t\tid: model.id,\n\t\t\t\tmodel,\n\t\t\t}));\n\t\t} catch (error) {\n\t\t\tthis.allModels = [];\n\t\t\tthis.scopedModelItems = [];\n\t\t\tthis.activeModels = [];\n\t\t\tthis.filteredModels = [];\n\t\t\tthis.groupedRows = [];\n\t\t\tthis.modelRowIndices = [];\n\t\t\tthis.errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.allModels = this.sortModelsWithinProvider(models);\n\t\t// Scoped models must also be filtered by provider readiness so users\n\t\t// can't pick a scoped model whose provider has no API key / OAuth.\n\t\tthis.scopedModelItems = this.sortModelsWithinProvider(\n\t\t\tthis.scopedModels\n\t\t\t\t.filter((scoped) => this.modelRegistry.isProviderRequestReady(scoped.model.provider))\n\t\t\t\t.map((scoped) => ({\n\t\t\t\t\tprovider: scoped.model.provider,\n\t\t\t\t\tid: scoped.model.id,\n\t\t\t\t\tmodel: scoped.model,\n\t\t\t\t})),\n\t\t);\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t\tthis.filteredModels = this.activeModels;\n\t}\n\n\t/**\n\t * Sort models within each provider: current model first, then by name desc.\n\t * Provider ordering is handled separately in buildGroupedRows().\n\t */\n\tprivate sortModelsWithinProvider(models: ModelItem[]): ModelItem[] {\n\t\tconst sorted = [...models];\n\t\tsorted.sort((a, b) => {\n\t\t\tconst aIsCurrent = modelsAreEqual(this.currentModel, a.model);\n\t\t\tconst bIsCurrent = modelsAreEqual(this.currentModel, b.model);\n\t\t\tif (aIsCurrent && !bIsCurrent) return -1;\n\t\t\tif (!aIsCurrent && bIsCurrent) return 1;\n\t\t\t// Within provider: newest/largest model name first\n\t\t\tconst nameCmp = b.model.name.localeCompare(a.model.name);\n\t\t\tif (nameCmp !== 0) return nameCmp;\n\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t});\n\t\treturn sorted;\n\t}\n\n\t/**\n\t * Build the grouped rows array for browse mode.\n\t * Current model's provider comes first; remaining providers sorted alphabetically.\n\t */\n\tprivate buildGroupedRows(): void {\n\t\t// Group models by provider\n\t\tconst byProvider = new Map<string, ModelItem[]>();\n\t\tfor (const item of this.activeModels) {\n\t\t\tlet group = byProvider.get(item.provider);\n\t\t\tif (!group) {\n\t\t\t\tgroup = [];\n\t\t\t\tbyProvider.set(item.provider, group);\n\t\t\t}\n\t\t\tgroup.push(item);\n\t\t}\n\n\t\t// Determine provider order: current model's provider first, rest alphabetically\n\t\tconst currentProvider = this.currentModel?.provider;\n\t\tconst providers = Array.from(byProvider.keys()).sort((a, b) => {\n\t\t\tif (a === currentProvider) return -1;\n\t\t\tif (b === currentProvider) return 1;\n\t\t\treturn a.localeCompare(b);\n\t\t});\n\n\t\tconst rows: ListRow[] = [];\n\t\tconst modelIndices: number[] = [];\n\n\t\tfor (const provider of providers) {\n\t\t\tconst items = byProvider.get(provider)!;\n\t\t\trows.push({ kind: \"header\", provider, count: items.length });\n\t\t\tfor (const item of items) {\n\t\t\t\tmodelIndices.push(rows.length);\n\t\t\t\trows.push({ kind: \"model\", item });\n\t\t\t}\n\t\t}\n\n\t\tthis.groupedRows = rows;\n\t\tthis.modelRowIndices = modelIndices;\n\t}\n\n\t/**\n\t * Move selectedGroupIndex to point at the current model (or first model).\n\t */\n\tprivate jumpToCurrentModel(): void {\n\t\tif (this.groupedRows.length === 0) {\n\t\t\tthis.selectedGroupIndex = 0;\n\t\t\treturn;\n\t\t}\n\t\t// Find the current model in grouped rows\n\t\tfor (let i = 0; i < this.groupedRows.length; i++) {\n\t\t\tconst row = this.groupedRows[i];\n\t\t\tif (row.kind === \"model\" && modelsAreEqual(this.currentModel, row.item.model)) {\n\t\t\t\tthis.selectedGroupIndex = i;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// Fall back to first model row\n\t\tif (this.modelRowIndices.length > 0) {\n\t\t\tthis.selectedGroupIndex = this.modelRowIndices[0];\n\t\t}\n\t}\n\n\t/**\n\t * Get the currently selected model from grouped or flat state.\n\t */\n\tprivate getSelectedModel(): Model<any> | undefined {\n\t\tif (this.isSearching) {\n\t\t\treturn this.filteredModels[this.selectedFlatIndex]?.model;\n\t\t}\n\t\tconst row = this.groupedRows[this.selectedGroupIndex];\n\t\treturn row?.kind === \"model\" ? row.item.model : undefined;\n\t}\n\n\tprivate getScopeText(): string {\n\t\tconst allText = this.scope === \"all\" ? theme.fg(\"accent\", \"all\") : theme.fg(\"muted\", \"all\");\n\t\tconst scopedText = this.scope === \"scoped\" ? theme.fg(\"accent\", \"scoped\") : theme.fg(\"muted\", \"scoped\");\n\t\treturn `${theme.fg(\"muted\", \"Scope: \")}${allText}${theme.fg(\"muted\", \" | \")}${scopedText}`;\n\t}\n\n\tprivate getScopeHintText(): string {\n\t\treturn keyHint(\"tab\", \"scope\") + theme.fg(\"muted\", \" (all/scoped)\");\n\t}\n\n\tprivate setScope(scope: ModelScope): void {\n\t\tif (this.scope === scope) return;\n\t\tthis.scope = scope;\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\n\t\tif (this.isSearching) {\n\t\t\tthis.selectedFlatIndex = 0;\n\t\t\tthis.filterModels(this.searchInput.getValue());\n\t\t} else {\n\t\t\tthis.buildGroupedRows();\n\t\t\tthis.jumpToCurrentModel();\n\t\t\tthis.updateList();\n\t\t}\n\n\t\tif (this.scopeText) {\n\t\t\tthis.scopeText.setText(this.getScopeText());\n\t\t}\n\t}\n\n\tprivate filterModels(query: string): void {\n\t\tthis.filteredModels = query\n\t\t\t? fuzzyFilter(this.activeModels, query, ({ id, provider }) => `${id} ${provider}`)\n\t\t\t: this.activeModels;\n\t\tthis.selectedFlatIndex = Math.min(this.selectedFlatIndex, Math.max(0, this.filteredModels.length - 1));\n\t\tthis.updateList();\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tif (this.errorMessage) {\n\t\t\tconst errorLines = this.errorMessage.split(\"\\n\");\n\t\t\tfor (const line of errorLines) {\n\t\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"error\", line), 0, 0));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isSearching) {\n\t\t\tthis.renderFlatList();\n\t\t} else {\n\t\t\tthis.renderGroupedList();\n\t\t}\n\t}\n\n\t/** Flat fuzzy-search results, same as original behaviour */\n\tprivate renderFlatList(): void {\n\t\tconst maxVisible = 10;\n\n\t\tif (this.filteredModels.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No matching models\"), 0, 0));\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selectedFlatIndex - Math.floor(maxVisible / 2),\n\t\t\t\tthis.filteredModels.length - maxVisible,\n\t\t\t),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + maxVisible, this.filteredModels.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.filteredModels[i];\n\t\t\tif (!item) continue;\n\n\t\t\tconst isSelected = i === this.selectedFlatIndex;\n\t\t\tconst isCurrent = modelsAreEqual(this.currentModel, item.model);\n\n\t\t\tconst ctx = formatTokenCount(item.model.contextWindow);\n\t\t\tconst ctxBadge = theme.fg(\"muted\", `${ctx}`);\n\t\t\tconst providerBadge = theme.fg(\"muted\", `[${providerDisplayName(item.provider)}]`);\n\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\n\t\t\tlet line: string;\n\t\t\tif (isSelected) {\n\t\t\t\tconst prefix = theme.fg(\"accent\", \"→ \");\n\t\t\t\tline = `${prefix}${theme.fg(\"accent\", item.id)} ${ctxBadge} ${providerBadge}${checkmark}`;\n\t\t\t} else {\n\t\t\t\tline = ` ${item.id} ${ctxBadge} ${providerBadge}${checkmark}`;\n\t\t\t}\n\n\t\t\tthis.listContainer.addChild(new Text(line, 0, 0));\n\t\t}\n\n\t\tif (startIndex > 0 || endIndex < this.filteredModels.length) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${this.selectedFlatIndex + 1}/${this.filteredModels.length})`), 0, 0),\n\t\t\t);\n\t\t}\n\n\t\t// Detail line for selected model\n\t\tconst selected = this.filteredModels[this.selectedFlatIndex];\n\t\tif (selected) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", ` ${this.modelDetailLine(selected.model)}`), 0, 0));\n\t\t}\n\t}\n\n\t/**\n\t * Grouped browse view: provider headers + model rows, windowed around selection.\n\t * Shows enough rows to fill ~10 visible lines; headers count as one line each.\n\t */\n\tprivate renderGroupedList(): void {\n\t\tconst maxVisible = 12;\n\n\t\tif (this.groupedRows.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No models available\"), 0, 0));\n\t\t\treturn;\n\t\t}\n\n\t\t// Window around selectedGroupIndex\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selectedGroupIndex - Math.floor(maxVisible / 2),\n\t\t\t\tthis.groupedRows.length - maxVisible,\n\t\t\t),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + maxVisible, this.groupedRows.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst row = this.groupedRows[i];\n\t\t\tif (!row) continue;\n\n\t\t\tif (row.kind === \"header\") {\n\t\t\t\t// Provider group header — always unselectable\n\t\t\t\tconst providerLabel = theme.fg(\"borderAccent\", providerDisplayName(row.provider));\n\t\t\t\tconst count = theme.fg(\"muted\", ` (${row.count})`);\n\t\t\t\t// Add blank line before header if not the very first visible row\n\t\t\t\tif (i > startIndex) {\n\t\t\t\t\tthis.listContainer.addChild(new Text(\"\", 0, 0));\n\t\t\t\t}\n\t\t\t\tthis.listContainer.addChild(new Text(` ${providerLabel}${count}`, 0, 0));\n\t\t\t} else {\n\t\t\t\t// Model row\n\t\t\t\tconst isSelected = i === this.selectedGroupIndex;\n\t\t\t\tconst isCurrent = modelsAreEqual(this.currentModel, row.item.model);\n\n\t\t\t\tconst ctx = formatTokenCount(row.item.model.contextWindow);\n\t\t\t\tconst ctxBadge = theme.fg(\"muted\", ` ${ctx}`);\n\t\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\n\t\t\t\tlet line: string;\n\t\t\t\tif (isSelected) {\n\t\t\t\t\tline = ` ${theme.fg(\"accent\", \"→\")} ${theme.fg(\"accent\", row.item.id)}${ctxBadge}${checkmark}`;\n\t\t\t\t} else {\n\t\t\t\t\tline = ` ${row.item.id}${ctxBadge}${checkmark}`;\n\t\t\t\t}\n\n\t\t\t\tthis.listContainer.addChild(new Text(line, 0, 0));\n\t\t\t}\n\t\t}\n\n\t\t// Scroll indicator\n\t\tif (startIndex > 0 || endIndex < this.groupedRows.length) {\n\t\t\tconst modelPos = this.modelRowIndices.indexOf(this.selectedGroupIndex) + 1;\n\t\t\tconst totalModels = this.modelRowIndices.length;\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${modelPos}/${totalModels})`), 0, 0),\n\t\t\t);\n\t\t}\n\n\t\t// Detail line for selected model\n\t\tconst selectedModel = this.getSelectedModel();\n\t\tif (selectedModel) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` ${this.modelDetailLine(selectedModel)}`), 0, 0),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate modelDetailLine(m: Model<any>): string {\n\t\treturn [\n\t\t\tm.name,\n\t\t\t`ctx: ${formatTokenCount(m.contextWindow)}`,\n\t\t\t`out: ${formatTokenCount(m.maxTokens)}`,\n\t\t\tm.reasoning ? \"thinking\" : \"\",\n\t\t\tm.input.includes(\"image\") ? \"vision\" : \"\",\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" · \");\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getEditorKeybindings();\n\n\t\t// Tab: scope toggle\n\t\tif (kb.matches(keyData, \"tab\")) {\n\t\t\tif (this.scopedModelItems.length > 0) {\n\t\t\t\tconst nextScope: ModelScope = this.scope === \"all\" ? \"scoped\" : \"all\";\n\t\t\t\tthis.setScope(nextScope);\n\t\t\t\tif (this.scopeHintText) {\n\t\t\t\t\tthis.scopeHintText.setText(this.getScopeHintText());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Navigation keys\n\t\tif (kb.matches(keyData, \"selectUp\")) {\n\t\t\tthis.moveUp();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(keyData, \"selectDown\")) {\n\t\t\tthis.moveDown();\n\t\t\treturn;\n\t\t}\n\n\t\t// Confirm\n\t\tif (kb.matches(keyData, \"selectConfirm\")) {\n\t\t\tconst model = this.getSelectedModel();\n\t\t\tif (model) this.handleSelect(model);\n\t\t\treturn;\n\t\t}\n\n\t\t// Cancel\n\t\tif (kb.matches(keyData, \"selectCancel\")) {\n\t\t\tthis.onCancelCallback();\n\t\t\treturn;\n\t\t}\n\n\t\t// Everything else: feed to search input\n\t\tconst prevQuery = this.searchInput.getValue();\n\t\tthis.searchInput.handleInput(keyData);\n\t\tconst newQuery = this.searchInput.getValue();\n\n\t\tif (newQuery !== prevQuery) {\n\t\t\tconst entering = !prevQuery && !!newQuery;\n\t\t\tconst leaving = !!prevQuery && !newQuery;\n\n\t\t\tif (entering) {\n\t\t\t\t// Entering search mode: remember current model position\n\t\t\t\tthis.isSearching = true;\n\t\t\t\tthis.selectedFlatIndex = 0;\n\t\t\t} else if (leaving) {\n\t\t\t\t// Leaving search mode: return to grouped view, restore position\n\t\t\t\tthis.isSearching = false;\n\t\t\t\tthis.buildGroupedRows();\n\t\t\t\tthis.jumpToCurrentModel();\n\t\t\t}\n\t\t\tif (this.isSearching) {\n\t\t\t\tthis.filterModels(newQuery);\n\t\t\t} else {\n\t\t\t\tthis.updateList();\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Move selection up, skipping headers in grouped mode */\n\tprivate moveUp(): void {\n\t\tif (this.isSearching) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedFlatIndex =\n\t\t\t\tthis.selectedFlatIndex === 0\n\t\t\t\t\t? this.filteredModels.length - 1\n\t\t\t\t\t: this.selectedFlatIndex - 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.groupedRows.length === 0) return;\n\t\tlet next = this.selectedGroupIndex - 1;\n\t\t// Wrap\n\t\tif (next < 0) next = this.groupedRows.length - 1;\n\t\t// Skip headers\n\t\twhile (next > 0 && this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext--;\n\t\t}\n\t\t// If landed on header at 0, wrap to bottom\n\t\tif (this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext = this.groupedRows.length - 1;\n\t\t}\n\t\tthis.selectedGroupIndex = next;\n\t\tthis.updateList();\n\t}\n\n\t/** Move selection down, skipping headers in grouped mode */\n\tprivate moveDown(): void {\n\t\tif (this.isSearching) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedFlatIndex =\n\t\t\t\tthis.selectedFlatIndex === this.filteredModels.length - 1\n\t\t\t\t\t? 0\n\t\t\t\t\t: this.selectedFlatIndex + 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.groupedRows.length === 0) return;\n\t\tlet next = this.selectedGroupIndex + 1;\n\t\t// Wrap\n\t\tif (next >= this.groupedRows.length) next = 0;\n\t\t// Skip headers\n\t\twhile (next < this.groupedRows.length - 1 && this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext++;\n\t\t}\n\t\t// If landed on header at end, wrap to first model\n\t\tif (this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext = this.modelRowIndices[0] ?? 0;\n\t\t}\n\t\tthis.selectedGroupIndex = next;\n\t\tthis.updateList();\n\t}\n\n\tprivate handleSelect(model: Model<any>): void {\n\t\t// Save as new default\n\t\tthis.settingsManager.setDefaultModelAndProvider(model.provider, model.id);\n\t\tthis.onSelectCallback(model);\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/model-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,SAAS,EAET,WAAW,EACX,oBAAoB,EACpB,KAAK,EACL,MAAM,EACN,IAAI,GAEJ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA2B;IAC5D,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,QAAQ;YACZ,OAAO,SAAS,CAAC;QAClB,KAAK,OAAO;YACX,OAAO,OAAO,C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AClD,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/C,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAEO,YAAY,CAAC,KAAiB;QACrC,sBAAsB;QACtB,IAAI,CAAC,eAAe,CAAC,0BAA0B,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,cAAc;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;CACD","sourcesContent":["import { type Model, modelsAreEqual } from \"@gsd/pi-ai\";\nimport {\n\tContainer,\n\ttype Focusable,\n\tfuzzyFilter,\n\tgetEditorKeybindings,\n\tInput,\n\tSpacer,\n\tText,\n\ttype TUI,\n} from \"@gsd/pi-tui\";\nimport type { ModelRegistry, ProviderAuthMode } from \"../../../core/model-registry.js\";\nimport type { SettingsManager } from \"../../../core/settings-manager.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.js\";\nimport { keyHint } from \"./keybinding-hints.js\";\n\nexport function providerDisplayName(provider: string): string {\n\treturn provider;\n}\n\n/**\n * Short, user-facing label for a provider's auth mode. Returned strings are\n * suitable for use as a suffix/badge alongside the provider name.\n * Returns an empty string for modes that don't need a badge (e.g. \"none\").\n */\nexport function providerAuthBadge(authMode?: ProviderAuthMode): string {\n\tswitch (authMode) {\n\t\tcase \"apiKey\":\n\t\t\treturn \"API key\";\n\t\tcase \"oauth\":\n\t\t\treturn \"OAuth\";\n\t\tcase \"externalCli\":\n\t\t\treturn \"CLI\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\ninterface ModelItem {\n\tprovider: string;\n\tid: string;\n\tmodel: Model<any>;\n}\n\ninterface ScopedModelItem {\n\tmodel: Model<any>;\n\tthinkingLevel?: string;\n}\n\n/**\n * A navigable row — either a provider group header or a selectable model entry.\n */\ntype ListRow =\n\t| { kind: \"header\"; provider: string; count: number }\n\t| { kind: \"model\"; item: ModelItem };\n\ntype ModelScope = \"all\" | \"scoped\";\n\n/**\n * Component that renders a grouped model selector with search.\n *\n * Browsing (no search): models are grouped under provider headers.\n * - Current model's provider is shown first; remaining providers sorted alphabetically.\n * - Arrow keys navigate all rows; headers are skipped during selection.\n * Searching: reverts to a flat fuzzy-filtered list (same as before), with [provider] badges.\n */\nexport class ModelSelectorComponent extends Container implements Focusable {\n\tprivate searchInput: Input;\n\n\t// Focusable implementation - propagate to searchInput for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.searchInput.focused = value;\n\t}\n\tprivate listContainer: Container;\n\tprivate allModels: ModelItem[] = [];\n\tprivate scopedModelItems: ModelItem[] = [];\n\tprivate activeModels: ModelItem[] = [];\n\n\t// Grouped (browse) state\n\tprivate groupedRows: ListRow[] = [];\n\tprivate modelRowIndices: number[] = []; // indices into groupedRows that are \"model\" kind\n\tprivate selectedGroupIndex: number = 0; // index into groupedRows (can be model or header)\n\n\t// Search (flat) state\n\tprivate filteredModels: ModelItem[] = [];\n\tprivate selectedFlatIndex: number = 0;\n\n\tprivate isSearching: boolean = false;\n\tprivate currentModel?: Model<any>;\n\tprivate settingsManager: SettingsManager;\n\tprivate modelRegistry: ModelRegistry;\n\tprivate onSelectCallback: (model: Model<any>) => void;\n\tprivate onCancelCallback: () => void;\n\tprivate errorMessage?: string;\n\tprivate tui: TUI;\n\tprivate scopedModels: ReadonlyArray<ScopedModelItem>;\n\tprivate scope: ModelScope = \"all\";\n\tprivate scopeText?: Text;\n\tprivate scopeHintText?: Text;\n\n\tconstructor(\n\t\ttui: TUI,\n\t\tcurrentModel: Model<any> | undefined,\n\t\tsettingsManager: SettingsManager,\n\t\tmodelRegistry: ModelRegistry,\n\t\tscopedModels: ReadonlyArray<ScopedModelItem>,\n\t\tonSelect: (model: Model<any>) => void,\n\t\tonCancel: () => void,\n\t\tinitialSearchInput?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.tui = tui;\n\t\tthis.currentModel = currentModel;\n\t\tthis.settingsManager = settingsManager;\n\t\tthis.modelRegistry = modelRegistry;\n\t\tthis.scopedModels = scopedModels;\n\t\t// Only land in \"scoped\" view when at least one scoped model has working\n\t\t// auth — otherwise the user would see an empty picker (#unconfigured-models).\n\t\tconst hasReadyScopedModel = scopedModels.some((scoped) =>\n\t\t\tmodelRegistry.isProviderRequestReady(scoped.model.provider),\n\t\t);\n\t\tthis.scope = hasReadyScopedModel ? \"scoped\" : \"all\";\n\t\tthis.onSelectCallback = onSelect;\n\t\tthis.onCancelCallback = onCancel;\n\n\t\t// Add top border\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add hint about model filtering\n\t\tif (scopedModels.length > 0) {\n\t\t\tthis.scopeText = new Text(this.getScopeText(), 0, 0);\n\t\t\tthis.addChild(this.scopeText);\n\t\t\tthis.scopeHintText = new Text(this.getScopeHintText(), 0, 0);\n\t\t\tthis.addChild(this.scopeHintText);\n\t\t} else {\n\t\t\tconst hintText =\n\t\t\t\t\"Only showing models with configured credentials (API key, OAuth, or CLI). See README for details.\";\n\t\t\tthis.addChild(new Text(theme.fg(\"warning\", hintText), 0, 0));\n\t\t}\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create search input\n\t\tthis.searchInput = new Input();\n\t\tif (initialSearchInput) {\n\t\t\tthis.searchInput.setValue(initialSearchInput);\n\t\t}\n\t\tthis.searchInput.onSubmit = () => {\n\t\t\tif (this.isSearching) {\n\t\t\t\tif (this.filteredModels[this.selectedFlatIndex]) {\n\t\t\t\t\tthis.handleSelect(this.filteredModels[this.selectedFlatIndex].model);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst model = this.getSelectedModel();\n\t\t\t\tif (model) this.handleSelect(model);\n\t\t\t}\n\t\t};\n\t\tthis.addChild(this.searchInput);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Create list container\n\t\tthis.listContainer = new Container();\n\t\tthis.addChild(this.listContainer);\n\n\t\tthis.addChild(new Spacer(1));\n\n\t\t// Add bottom border\n\t\tthis.addChild(new DynamicBorder());\n\n\t\t// Load models and do initial render\n\t\tthis.loadModels().then(() => {\n\t\t\tif (initialSearchInput) {\n\t\t\t\tthis.isSearching = true;\n\t\t\t\tthis.filterModels(initialSearchInput);\n\t\t\t} else {\n\t\t\t\tthis.buildGroupedRows();\n\t\t\t\tthis.jumpToCurrentModel();\n\t\t\t\tthis.updateList();\n\t\t\t}\n\t\t\t// Request re-render after models are loaded\n\t\t\tthis.tui.requestRender();\n\t\t});\n\t}\n\n\tprivate async loadModels(): Promise<void> {\n\t\tlet models: ModelItem[];\n\n\t\t// Refresh to pick up any changes to models.json\n\t\tthis.modelRegistry.refresh();\n\n\t\t// Check for models.json errors\n\t\tconst loadError = this.modelRegistry.getError();\n\t\tif (loadError) {\n\t\t\tthis.errorMessage = loadError;\n\t\t}\n\n\t\t// Load available models (built-in models still work even if models.json failed)\n\t\ttry {\n\t\t\tconst availableModels = this.modelRegistry.getAvailable();\n\t\t\tmodels = availableModels.map((model: Model<any>) => ({\n\t\t\t\tprovider: model.provider,\n\t\t\t\tid: model.id,\n\t\t\t\tmodel,\n\t\t\t}));\n\t\t} catch (error) {\n\t\t\tthis.allModels = [];\n\t\t\tthis.scopedModelItems = [];\n\t\t\tthis.activeModels = [];\n\t\t\tthis.filteredModels = [];\n\t\t\tthis.groupedRows = [];\n\t\t\tthis.modelRowIndices = [];\n\t\t\tthis.errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.allModels = this.sortModelsWithinProvider(models);\n\t\t// Scoped models must also be filtered by provider readiness so users\n\t\t// can't pick a scoped model whose provider has no API key / OAuth.\n\t\tthis.scopedModelItems = this.sortModelsWithinProvider(\n\t\t\tthis.scopedModels\n\t\t\t\t.filter((scoped) => this.modelRegistry.isProviderRequestReady(scoped.model.provider))\n\t\t\t\t.map((scoped) => ({\n\t\t\t\t\tprovider: scoped.model.provider,\n\t\t\t\t\tid: scoped.model.id,\n\t\t\t\t\tmodel: scoped.model,\n\t\t\t\t})),\n\t\t);\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\t\tthis.filteredModels = this.activeModels;\n\t}\n\n\t/**\n\t * Sort models within each provider: current model first, then by name desc.\n\t * Provider ordering is handled separately in buildGroupedRows().\n\t */\n\tprivate sortModelsWithinProvider(models: ModelItem[]): ModelItem[] {\n\t\tconst sorted = [...models];\n\t\tsorted.sort((a, b) => {\n\t\t\tconst aIsCurrent = modelsAreEqual(this.currentModel, a.model);\n\t\t\tconst bIsCurrent = modelsAreEqual(this.currentModel, b.model);\n\t\t\tif (aIsCurrent && !bIsCurrent) return -1;\n\t\t\tif (!aIsCurrent && bIsCurrent) return 1;\n\t\t\t// Within provider: newest/largest model name first\n\t\t\tconst nameCmp = b.model.name.localeCompare(a.model.name);\n\t\t\tif (nameCmp !== 0) return nameCmp;\n\t\t\treturn a.provider.localeCompare(b.provider);\n\t\t});\n\t\treturn sorted;\n\t}\n\n\t/**\n\t * Build the grouped rows array for browse mode.\n\t * Current model's provider comes first; remaining providers sorted alphabetically.\n\t */\n\tprivate buildGroupedRows(): void {\n\t\t// Group models by provider\n\t\tconst byProvider = new Map<string, ModelItem[]>();\n\t\tfor (const item of this.activeModels) {\n\t\t\tlet group = byProvider.get(item.provider);\n\t\t\tif (!group) {\n\t\t\t\tgroup = [];\n\t\t\t\tbyProvider.set(item.provider, group);\n\t\t\t}\n\t\t\tgroup.push(item);\n\t\t}\n\n\t\t// Determine provider order: current model's provider first, rest alphabetically\n\t\tconst currentProvider = this.currentModel?.provider;\n\t\tconst providers = Array.from(byProvider.keys()).sort((a, b) => {\n\t\t\tif (a === currentProvider) return -1;\n\t\t\tif (b === currentProvider) return 1;\n\t\t\treturn a.localeCompare(b);\n\t\t});\n\n\t\tconst rows: ListRow[] = [];\n\t\tconst modelIndices: number[] = [];\n\n\t\tfor (const provider of providers) {\n\t\t\tconst items = byProvider.get(provider)!;\n\t\t\trows.push({ kind: \"header\", provider, count: items.length });\n\t\t\tfor (const item of items) {\n\t\t\t\tmodelIndices.push(rows.length);\n\t\t\t\trows.push({ kind: \"model\", item });\n\t\t\t}\n\t\t}\n\n\t\tthis.groupedRows = rows;\n\t\tthis.modelRowIndices = modelIndices;\n\t}\n\n\t/**\n\t * Move selectedGroupIndex to point at the current model (or first model).\n\t */\n\tprivate jumpToCurrentModel(): void {\n\t\tif (this.groupedRows.length === 0) {\n\t\t\tthis.selectedGroupIndex = 0;\n\t\t\treturn;\n\t\t}\n\t\t// Find the current model in grouped rows\n\t\tfor (let i = 0; i < this.groupedRows.length; i++) {\n\t\t\tconst row = this.groupedRows[i];\n\t\t\tif (row.kind === \"model\" && modelsAreEqual(this.currentModel, row.item.model)) {\n\t\t\t\tthis.selectedGroupIndex = i;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// Fall back to first model row\n\t\tif (this.modelRowIndices.length > 0) {\n\t\t\tthis.selectedGroupIndex = this.modelRowIndices[0];\n\t\t}\n\t}\n\n\t/**\n\t * Get the currently selected model from grouped or flat state.\n\t */\n\tprivate getSelectedModel(): Model<any> | undefined {\n\t\tif (this.isSearching) {\n\t\t\treturn this.filteredModels[this.selectedFlatIndex]?.model;\n\t\t}\n\t\tconst row = this.groupedRows[this.selectedGroupIndex];\n\t\treturn row?.kind === \"model\" ? row.item.model : undefined;\n\t}\n\n\tprivate getScopeText(): string {\n\t\tconst allText = this.scope === \"all\" ? theme.fg(\"accent\", \"all\") : theme.fg(\"muted\", \"all\");\n\t\tconst scopedText = this.scope === \"scoped\" ? theme.fg(\"accent\", \"scoped\") : theme.fg(\"muted\", \"scoped\");\n\t\treturn `${theme.fg(\"muted\", \"Scope: \")}${allText}${theme.fg(\"muted\", \" | \")}${scopedText}`;\n\t}\n\n\tprivate getScopeHintText(): string {\n\t\treturn keyHint(\"tab\", \"scope\") + theme.fg(\"muted\", \" (all/scoped)\");\n\t}\n\n\tprivate setScope(scope: ModelScope): void {\n\t\tif (this.scope === scope) return;\n\t\tthis.scope = scope;\n\t\tthis.activeModels = this.scope === \"scoped\" ? this.scopedModelItems : this.allModels;\n\n\t\tif (this.isSearching) {\n\t\t\tthis.selectedFlatIndex = 0;\n\t\t\tthis.filterModels(this.searchInput.getValue());\n\t\t} else {\n\t\t\tthis.buildGroupedRows();\n\t\t\tthis.jumpToCurrentModel();\n\t\t\tthis.updateList();\n\t\t}\n\n\t\tif (this.scopeText) {\n\t\t\tthis.scopeText.setText(this.getScopeText());\n\t\t}\n\t}\n\n\tprivate filterModels(query: string): void {\n\t\tthis.filteredModels = query\n\t\t\t? fuzzyFilter(this.activeModels, query, ({ id, provider }) => `${id} ${provider}`)\n\t\t\t: this.activeModels;\n\t\tthis.selectedFlatIndex = Math.min(this.selectedFlatIndex, Math.max(0, this.filteredModels.length - 1));\n\t\tthis.updateList();\n\t}\n\n\tprivate updateList(): void {\n\t\tthis.listContainer.clear();\n\n\t\tif (this.errorMessage) {\n\t\t\tconst errorLines = this.errorMessage.split(\"\\n\");\n\t\t\tfor (const line of errorLines) {\n\t\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"error\", line), 0, 0));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isSearching) {\n\t\t\tthis.renderFlatList();\n\t\t} else {\n\t\t\tthis.renderGroupedList();\n\t\t}\n\t}\n\n\t/** Flat fuzzy-search results, same as original behaviour */\n\tprivate renderFlatList(): void {\n\t\tconst maxVisible = 10;\n\n\t\tif (this.filteredModels.length === 0) {\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", \" No matching models\"), 0, 0));\n\t\t\treturn;\n\t\t}\n\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selectedFlatIndex - Math.floor(maxVisible / 2),\n\t\t\t\tthis.filteredModels.length - maxVisible,\n\t\t\t),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + maxVisible, this.filteredModels.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.filteredModels[i];\n\t\t\tif (!item) continue;\n\n\t\t\tconst isSelected = i === this.selectedFlatIndex;\n\t\t\tconst isCurrent = modelsAreEqual(this.currentModel, item.model);\n\n\t\t\tconst ctx = formatTokenCount(item.model.contextWindow);\n\t\t\tconst ctxBadge = theme.fg(\"muted\", `${ctx}`);\n\t\t\tconst authMode = this.modelRegistry.getProviderAuthMode(item.provider);\n\t\t\tconst authLabel = providerAuthBadge(authMode);\n\t\t\tconst providerBadgeText = authLabel\n\t\t\t\t? `[${providerDisplayName(item.provider)} · ${authLabel}]`\n\t\t\t\t: `[${providerDisplayName(item.provider)}]`;\n\t\t\tconst providerBadge = theme.fg(\"muted\", providerBadgeText);\n\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\n\t\t\tlet line: string;\n\t\t\tif (isSelected) {\n\t\t\t\tconst prefix = theme.fg(\"accent\", \"→ \");\n\t\t\t\tline = `${prefix}${theme.fg(\"accent\", item.id)} ${ctxBadge} ${providerBadge}${checkmark}`;\n\t\t\t} else {\n\t\t\t\tline = ` ${item.id} ${ctxBadge} ${providerBadge}${checkmark}`;\n\t\t\t}\n\n\t\t\tthis.listContainer.addChild(new Text(line, 0, 0));\n\t\t}\n\n\t\tif (startIndex > 0 || endIndex < this.filteredModels.length) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${this.selectedFlatIndex + 1}/${this.filteredModels.length})`), 0, 0),\n\t\t\t);\n\t\t}\n\n\t\t// Detail line for selected model\n\t\tconst selected = this.filteredModels[this.selectedFlatIndex];\n\t\tif (selected) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(new Text(theme.fg(\"muted\", ` ${this.modelDetailLine(selected.model)}`), 0, 0));\n\t\t}\n\t}\n\n\t/**\n\t * Grouped browse view: provider headers + model rows, windowed around selection.\n\t * Shows enough rows to fill ~10 visible lines; headers count as one line each.\n\t */\n\tprivate renderGroupedList(): void {\n\t\tconst maxVisible = 12;\n\n\t\tif (this.groupedRows.length === 0) {\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", \" No providers configured.\"), 0, 0),\n\t\t\t);\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"muted\",\n\t\t\t\t\t\t\" Run /login (OAuth), set an API key, or install a CLI provider. See README.\",\n\t\t\t\t\t),\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Window around selectedGroupIndex\n\t\tconst startIndex = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selectedGroupIndex - Math.floor(maxVisible / 2),\n\t\t\t\tthis.groupedRows.length - maxVisible,\n\t\t\t),\n\t\t);\n\t\tconst endIndex = Math.min(startIndex + maxVisible, this.groupedRows.length);\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst row = this.groupedRows[i];\n\t\t\tif (!row) continue;\n\n\t\t\tif (row.kind === \"header\") {\n\t\t\t\t// Provider group header — always unselectable\n\t\t\t\tconst providerLabel = theme.fg(\"borderAccent\", providerDisplayName(row.provider));\n\t\t\t\tconst count = theme.fg(\"muted\", ` (${row.count})`);\n\t\t\t\tconst authMode = this.modelRegistry.getProviderAuthMode(row.provider);\n\t\t\t\tconst authLabel = providerAuthBadge(authMode);\n\t\t\t\tconst authText = authLabel ? theme.fg(\"muted\", ` · via ${authLabel}`) : \"\";\n\t\t\t\t// Add blank line before header if not the very first visible row\n\t\t\t\tif (i > startIndex) {\n\t\t\t\t\tthis.listContainer.addChild(new Text(\"\", 0, 0));\n\t\t\t\t}\n\t\t\t\tthis.listContainer.addChild(new Text(` ${providerLabel}${count}${authText}`, 0, 0));\n\t\t\t} else {\n\t\t\t\t// Model row\n\t\t\t\tconst isSelected = i === this.selectedGroupIndex;\n\t\t\t\tconst isCurrent = modelsAreEqual(this.currentModel, row.item.model);\n\n\t\t\t\tconst ctx = formatTokenCount(row.item.model.contextWindow);\n\t\t\t\tconst ctxBadge = theme.fg(\"muted\", ` ${ctx}`);\n\t\t\t\tconst checkmark = isCurrent ? theme.fg(\"success\", \" ✓\") : \"\";\n\n\t\t\t\tlet line: string;\n\t\t\t\tif (isSelected) {\n\t\t\t\t\tline = ` ${theme.fg(\"accent\", \"→\")} ${theme.fg(\"accent\", row.item.id)}${ctxBadge}${checkmark}`;\n\t\t\t\t} else {\n\t\t\t\t\tline = ` ${row.item.id}${ctxBadge}${checkmark}`;\n\t\t\t\t}\n\n\t\t\t\tthis.listContainer.addChild(new Text(line, 0, 0));\n\t\t\t}\n\t\t}\n\n\t\t// Scroll indicator\n\t\tif (startIndex > 0 || endIndex < this.groupedRows.length) {\n\t\t\tconst modelPos = this.modelRowIndices.indexOf(this.selectedGroupIndex) + 1;\n\t\t\tconst totalModels = this.modelRowIndices.length;\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` (${modelPos}/${totalModels})`), 0, 0),\n\t\t\t);\n\t\t}\n\n\t\t// Detail line for selected model\n\t\tconst selectedModel = this.getSelectedModel();\n\t\tif (selectedModel) {\n\t\t\tthis.listContainer.addChild(new Spacer(1));\n\t\t\tthis.listContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"muted\", ` ${this.modelDetailLine(selectedModel)}`), 0, 0),\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate modelDetailLine(m: Model<any>): string {\n\t\treturn [\n\t\t\tm.name,\n\t\t\t`ctx: ${formatTokenCount(m.contextWindow)}`,\n\t\t\t`out: ${formatTokenCount(m.maxTokens)}`,\n\t\t\tm.reasoning ? \"thinking\" : \"\",\n\t\t\tm.input.includes(\"image\") ? \"vision\" : \"\",\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" · \");\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getEditorKeybindings();\n\n\t\t// Tab: scope toggle\n\t\tif (kb.matches(keyData, \"tab\")) {\n\t\t\tif (this.scopedModelItems.length > 0) {\n\t\t\t\tconst nextScope: ModelScope = this.scope === \"all\" ? \"scoped\" : \"all\";\n\t\t\t\tthis.setScope(nextScope);\n\t\t\t\tif (this.scopeHintText) {\n\t\t\t\t\tthis.scopeHintText.setText(this.getScopeHintText());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Navigation keys\n\t\tif (kb.matches(keyData, \"selectUp\")) {\n\t\t\tthis.moveUp();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(keyData, \"selectDown\")) {\n\t\t\tthis.moveDown();\n\t\t\treturn;\n\t\t}\n\n\t\t// Confirm\n\t\tif (kb.matches(keyData, \"selectConfirm\")) {\n\t\t\tconst model = this.getSelectedModel();\n\t\t\tif (model) this.handleSelect(model);\n\t\t\treturn;\n\t\t}\n\n\t\t// Cancel\n\t\tif (kb.matches(keyData, \"selectCancel\")) {\n\t\t\tthis.onCancelCallback();\n\t\t\treturn;\n\t\t}\n\n\t\t// Everything else: feed to search input\n\t\tconst prevQuery = this.searchInput.getValue();\n\t\tthis.searchInput.handleInput(keyData);\n\t\tconst newQuery = this.searchInput.getValue();\n\n\t\tif (newQuery !== prevQuery) {\n\t\t\tconst entering = !prevQuery && !!newQuery;\n\t\t\tconst leaving = !!prevQuery && !newQuery;\n\n\t\t\tif (entering) {\n\t\t\t\t// Entering search mode: remember current model position\n\t\t\t\tthis.isSearching = true;\n\t\t\t\tthis.selectedFlatIndex = 0;\n\t\t\t} else if (leaving) {\n\t\t\t\t// Leaving search mode: return to grouped view, restore position\n\t\t\t\tthis.isSearching = false;\n\t\t\t\tthis.buildGroupedRows();\n\t\t\t\tthis.jumpToCurrentModel();\n\t\t\t}\n\t\t\tif (this.isSearching) {\n\t\t\t\tthis.filterModels(newQuery);\n\t\t\t} else {\n\t\t\t\tthis.updateList();\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Move selection up, skipping headers in grouped mode */\n\tprivate moveUp(): void {\n\t\tif (this.isSearching) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedFlatIndex =\n\t\t\t\tthis.selectedFlatIndex === 0\n\t\t\t\t\t? this.filteredModels.length - 1\n\t\t\t\t\t: this.selectedFlatIndex - 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.groupedRows.length === 0) return;\n\t\tlet next = this.selectedGroupIndex - 1;\n\t\t// Wrap\n\t\tif (next < 0) next = this.groupedRows.length - 1;\n\t\t// Skip headers\n\t\twhile (next > 0 && this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext--;\n\t\t}\n\t\t// If landed on header at 0, wrap to bottom\n\t\tif (this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext = this.groupedRows.length - 1;\n\t\t}\n\t\tthis.selectedGroupIndex = next;\n\t\tthis.updateList();\n\t}\n\n\t/** Move selection down, skipping headers in grouped mode */\n\tprivate moveDown(): void {\n\t\tif (this.isSearching) {\n\t\t\tif (this.filteredModels.length === 0) return;\n\t\t\tthis.selectedFlatIndex =\n\t\t\t\tthis.selectedFlatIndex === this.filteredModels.length - 1\n\t\t\t\t\t? 0\n\t\t\t\t\t: this.selectedFlatIndex + 1;\n\t\t\tthis.updateList();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.groupedRows.length === 0) return;\n\t\tlet next = this.selectedGroupIndex + 1;\n\t\t// Wrap\n\t\tif (next >= this.groupedRows.length) next = 0;\n\t\t// Skip headers\n\t\twhile (next < this.groupedRows.length - 1 && this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext++;\n\t\t}\n\t\t// If landed on header at end, wrap to first model\n\t\tif (this.groupedRows[next]?.kind === \"header\") {\n\t\t\tnext = this.modelRowIndices[0] ?? 0;\n\t\t}\n\t\tthis.selectedGroupIndex = next;\n\t\tthis.updateList();\n\t}\n\n\tprivate handleSelect(model: Model<any>): void {\n\t\t// Save as new default\n\t\tthis.settingsManager.setDefaultModelAndProvider(model.provider, model.id);\n\t\tthis.onSelectCallback(model);\n\t}\n\n\tgetSearchInput(): Input {\n\t\treturn this.searchInput;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { describe, it, mock, type Mock } from "node:test";
|
|
6
|
+
|
|
7
|
+
import type { Agent } from "@gsd/pi-agent-core";
|
|
8
|
+
import type { Api, AssistantMessage, Model } from "@gsd/pi-ai";
|
|
9
|
+
|
|
10
|
+
import { CompactionOrchestrator, type CompactionOrchestratorDeps } from "./compaction-orchestrator.js";
|
|
11
|
+
import { SessionManager } from "./session-manager.js";
|
|
12
|
+
|
|
13
|
+
function createMockModel(): Model<Api> {
|
|
14
|
+
return {
|
|
15
|
+
id: "claude-opus-4-6",
|
|
16
|
+
name: "Claude Opus 4.6",
|
|
17
|
+
api: "anthropic-messages" as Api,
|
|
18
|
+
provider: "anthropic",
|
|
19
|
+
baseUrl: "https://api.anthropic.com",
|
|
20
|
+
reasoning: false,
|
|
21
|
+
input: ["text"],
|
|
22
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
23
|
+
contextWindow: 200_000,
|
|
24
|
+
maxTokens: 16_384,
|
|
25
|
+
} as Model<Api>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createAssistantMessage(
|
|
29
|
+
stopReason: AssistantMessage["stopReason"],
|
|
30
|
+
contentText: string,
|
|
31
|
+
): AssistantMessage {
|
|
32
|
+
return {
|
|
33
|
+
role: "assistant",
|
|
34
|
+
content: [{ type: "text", text: contentText }],
|
|
35
|
+
api: "anthropic-messages",
|
|
36
|
+
provider: "anthropic",
|
|
37
|
+
model: "claude-opus-4-6",
|
|
38
|
+
usage: {
|
|
39
|
+
input: 100,
|
|
40
|
+
output: 100,
|
|
41
|
+
cacheRead: 0,
|
|
42
|
+
cacheWrite: 0,
|
|
43
|
+
totalTokens: 200,
|
|
44
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
45
|
+
},
|
|
46
|
+
stopReason,
|
|
47
|
+
timestamp: Date.now(),
|
|
48
|
+
errorMessage: stopReason === "error" ? contentText : undefined,
|
|
49
|
+
} as AssistantMessage;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function wait(ms: number): Promise<void> {
|
|
53
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function createHarness(overrides?: {
|
|
57
|
+
cancelResult?: boolean;
|
|
58
|
+
willRetry?: boolean;
|
|
59
|
+
hasQueuedMessages?: boolean;
|
|
60
|
+
}) {
|
|
61
|
+
const dir = mkdtempSync(join(tmpdir(), "compaction-orchestrator-test-"));
|
|
62
|
+
const sessionManager = SessionManager.create(dir, dir);
|
|
63
|
+
sessionManager.appendMessage({ role: "user", content: "First user message" } as any);
|
|
64
|
+
sessionManager.appendMessage(createAssistantMessage("stop", "First assistant message"));
|
|
65
|
+
sessionManager.appendMessage({ role: "user", content: "Second user message" } as any);
|
|
66
|
+
|
|
67
|
+
const emittedEvents: Array<Record<string, unknown>> = [];
|
|
68
|
+
const continueFn = mock.fn(async () => {});
|
|
69
|
+
const replaceMessages = mock.fn((nextMessages: unknown[]) => {
|
|
70
|
+
(agent.state.messages as unknown[]) = nextMessages;
|
|
71
|
+
});
|
|
72
|
+
const agent = {
|
|
73
|
+
state: {
|
|
74
|
+
messages: [
|
|
75
|
+
{ role: "user", content: "queued follow-up" },
|
|
76
|
+
createAssistantMessage("error", "context overflow"),
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
continue: continueFn,
|
|
80
|
+
replaceMessages,
|
|
81
|
+
hasQueuedMessages: () => overrides?.hasQueuedMessages ?? false,
|
|
82
|
+
} as unknown as Agent;
|
|
83
|
+
|
|
84
|
+
const extensionRunner = {
|
|
85
|
+
hasHandlers: mock.fn(() => true),
|
|
86
|
+
emit: mock.fn(async () => ({ cancel: overrides?.cancelResult ?? true })),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const deps: CompactionOrchestratorDeps = {
|
|
90
|
+
agent,
|
|
91
|
+
sessionManager,
|
|
92
|
+
settingsManager: {
|
|
93
|
+
getCompactionSettings: () => ({
|
|
94
|
+
enabled: true,
|
|
95
|
+
reserveTokens: 16_384,
|
|
96
|
+
keepRecentTokens: 1,
|
|
97
|
+
}),
|
|
98
|
+
} as any,
|
|
99
|
+
modelRegistry: {
|
|
100
|
+
isProviderRequestReady: () => true,
|
|
101
|
+
getApiKey: async () => undefined,
|
|
102
|
+
} as any,
|
|
103
|
+
getModel: () => createMockModel(),
|
|
104
|
+
getSessionId: () => "test-session",
|
|
105
|
+
getExtensionRunner: () => extensionRunner as any,
|
|
106
|
+
emit: (event) => emittedEvents.push(event as unknown as Record<string, unknown>),
|
|
107
|
+
disconnectFromAgent: () => {},
|
|
108
|
+
reconnectToAgent: () => {},
|
|
109
|
+
abort: async () => {},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
dir,
|
|
114
|
+
agent,
|
|
115
|
+
continueFn,
|
|
116
|
+
replaceMessages,
|
|
117
|
+
emittedEvents,
|
|
118
|
+
extensionRunner,
|
|
119
|
+
orchestrator: new CompactionOrchestrator(deps),
|
|
120
|
+
cleanup: () => rmSync(dir, { recursive: true, force: true }),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
describe("CompactionOrchestrator", () => {
|
|
125
|
+
it("overflow cancel keeps retry intent and resumes the agent (#3971)", async (t) => {
|
|
126
|
+
const harness = createHarness({ willRetry: true });
|
|
127
|
+
t.after(harness.cleanup);
|
|
128
|
+
|
|
129
|
+
await (harness.orchestrator as any)._runAutoCompaction("overflow", true);
|
|
130
|
+
await wait(150);
|
|
131
|
+
|
|
132
|
+
const endEvent = harness.emittedEvents.find((event) => event.type === "auto_compaction_end");
|
|
133
|
+
assert.ok(endEvent, "should emit auto_compaction_end");
|
|
134
|
+
assert.equal(endEvent?.aborted, true, "cancelled compaction should be marked aborted");
|
|
135
|
+
assert.equal(endEvent?.willRetry, true, "overflow cancel should preserve retry intent");
|
|
136
|
+
assert.equal(harness.continueFn.mock.callCount(), 1, "overflow cancel should resume the agent");
|
|
137
|
+
assert.equal(harness.replaceMessages.mock.callCount(), 1, "retry follow-up should trim the error message when present");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("threshold cancel stays non-retrying when no queued messages exist", async (t) => {
|
|
141
|
+
const harness = createHarness({ willRetry: false, hasQueuedMessages: false });
|
|
142
|
+
t.after(harness.cleanup);
|
|
143
|
+
|
|
144
|
+
await (harness.orchestrator as any)._runAutoCompaction("threshold", false);
|
|
145
|
+
await wait(150);
|
|
146
|
+
|
|
147
|
+
const endEvent = harness.emittedEvents.find((event) => event.type === "auto_compaction_end");
|
|
148
|
+
assert.ok(endEvent, "should emit auto_compaction_end");
|
|
149
|
+
assert.equal(endEvent?.aborted, true, "cancelled compaction should be marked aborted");
|
|
150
|
+
assert.equal(endEvent?.willRetry, false, "threshold cancel should stay non-retrying");
|
|
151
|
+
assert.equal(harness.continueFn.mock.callCount(), 0, "threshold cancel should not resume the agent without queued work");
|
|
152
|
+
assert.equal(harness.replaceMessages.mock.callCount(), 0, "non-retry cancel should not trim messages");
|
|
153
|
+
});
|
|
154
|
+
});
|