@alumbwe/anvil 1.0.42 → 1.0.49
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/bin/anvil.js +18 -0
- package/package.json +13 -6
- package/src/agents/bundled-agents.generated.ts +1 -1
- package/src/index.tsx +27 -4
- package/src/login/plain-login.ts +60 -0
- package/src/login/supabase-auth.ts +346 -0
- package/src/utils/anvil-client.ts +4 -0
- package/src/utils/auth.ts +16 -4
- package/src/utils/config-dir.ts +1 -1
- package/vendor/@anvil/common/src/constants/deepseek-direct.ts +30 -1
- package/vendor/@anvil/common/src/util/project-ignore.ts +4 -3
- package/vendor/@anvil/sdk/dist/index.cjs +46 -10
- package/vendor/@anvil/sdk/dist/index.mjs +46 -10
- package/src/commands/__tests__/anvil-command-aliases.test.ts +0 -56
- package/src/commands/__tests__/bash-command.test.ts +0 -445
- package/src/commands/__tests__/command-args.test.ts +0 -349
- package/src/commands/__tests__/copy-conversation-clipboard.test.ts +0 -108
- package/src/commands/__tests__/copy-conversation.test.ts +0 -226
- package/src/commands/__tests__/diagnostics-command.test.ts +0 -35
- package/src/commands/__tests__/image.test.ts +0 -99
- package/src/commands/__tests__/init.test.ts +0 -456
- package/src/commands/__tests__/new-command-rotates-chat.test.ts +0 -91
- package/src/commands/__tests__/process-diagnostics.test.ts +0 -54
- package/src/commands/__tests__/prompt-builders.test.ts +0 -28
- package/src/commands/__tests__/router-input.test.ts +0 -298
- package/src/components/__tests__/ad-banner.test.tsx +0 -83
- package/src/components/__tests__/anvil-landing-heading-row.test.tsx +0 -91
- package/src/components/__tests__/anvil-model-selector.test.tsx +0 -519
- package/src/components/__tests__/anvil-offer-invariants.test.ts +0 -54
- package/src/components/__tests__/anvil-takeover-prompt.test.tsx +0 -212
- package/src/components/__tests__/chat-input-bar.test.tsx +0 -130
- package/src/components/__tests__/grid-layout.integration.test.tsx +0 -304
- package/src/components/__tests__/grid-layout.test.tsx +0 -1051
- package/src/components/__tests__/message-block.completion.test.tsx +0 -104
- package/src/components/__tests__/message-block.streaming.test.tsx +0 -78
- package/src/components/__tests__/message-with-agents.test.tsx +0 -579
- package/src/components/__tests__/multiline-input.test.tsx +0 -1132
- package/src/components/__tests__/queue-panel.test.tsx +0 -398
- package/src/components/__tests__/selectable-list.test.ts +0 -232
- package/src/components/__tests__/status-bar.test.tsx +0 -44
- package/src/components/__tests__/status-indicator.test.tsx +0 -204
- package/src/components/__tests__/terminal-thinking-orb.test.tsx +0 -111
- package/src/components/__tests__/user-error-banner.test.tsx +0 -102
- package/src/components/ask-user/__tests__/multiple-choice-form.test.ts +0 -432
- package/src/components/ask-user/__tests__/validation.test.ts +0 -213
- package/src/components/tools/__tests__/apply-patch.test.tsx +0 -84
- package/src/components/tools/__tests__/code-search.test.tsx +0 -45
- package/src/components/tools/__tests__/gravity-index.test.ts +0 -76
- package/src/components/tools/__tests__/render-ui.test.tsx +0 -92
- package/src/components/tools/__tests__/run-terminal-command.test.ts +0 -233
- package/src/contexts/__tests__/chat-runtime-context.test.tsx +0 -149
- package/src/data/slash-commands.test.ts +0 -24
- package/src/hooks/__tests__/holds-live-anvil-slot.test.ts +0 -49
- package/src/hooks/__tests__/session-fetch-signal.test.ts +0 -63
- package/src/hooks/__tests__/use-activity-query.test.ts +0 -1000
- package/src/hooks/__tests__/use-ask-user-bridge.test.ts +0 -176
- package/src/hooks/__tests__/use-auth-query.test.ts +0 -21
- package/src/hooks/__tests__/use-chat-input-remount.test.tsx +0 -66
- package/src/hooks/__tests__/use-clipboard.test.tsx +0 -73
- package/src/hooks/__tests__/use-connection-status.test.ts +0 -112
- package/src/hooks/__tests__/use-directory-browser.test.ts +0 -203
- package/src/hooks/__tests__/use-gravity-ad.test.ts +0 -73
- package/src/hooks/__tests__/use-grid-layout.test.ts +0 -349
- package/src/hooks/__tests__/use-input-history.test.ts +0 -699
- package/src/hooks/__tests__/use-message-queue-editing.test.tsx +0 -209
- package/src/hooks/__tests__/use-message-queue.test.tsx +0 -71
- package/src/hooks/__tests__/use-path-tab-completion.test.ts +0 -315
- package/src/hooks/__tests__/use-queue-controls.test.ts +0 -68
- package/src/hooks/__tests__/use-queue-ui.test.tsx +0 -83
- package/src/hooks/__tests__/use-searchable-list.test.ts +0 -359
- package/src/hooks/__tests__/use-send-message-timer.test.ts +0 -146
- package/src/hooks/__tests__/use-suggestion-engine-mention.test.ts +0 -361
- package/src/hooks/__tests__/use-suggestion-engine.test.ts +0 -485
- package/src/hooks/__tests__/use-terminal-focus.test.ts +0 -66
- package/src/hooks/__tests__/use-terminal-layout.test.ts +0 -675
- package/src/hooks/__tests__/use-timeout.test.ts +0 -330
- package/src/hooks/__tests__/use-usage-query.test.ts +0 -502
- package/src/hooks/__tests__/use-user-details-query.test.ts +0 -195
- package/src/hooks/helpers/__tests__/send-message.test.ts +0 -1918
- package/src/init/__tests__/init-direnv.test.ts +0 -526
- package/src/state/__tests__/chat-store-focus.test.ts +0 -22
- package/src/state/__tests__/feedback-store.test.ts +0 -257
- package/src/utils/__tests__/active-run.test.ts +0 -140
- package/src/utils/__tests__/activity-tracker.test.ts +0 -440
- package/src/utils/__tests__/agent-display.test.ts +0 -139
- package/src/utils/__tests__/analytics-client.test.ts +0 -262
- package/src/utils/__tests__/anonymous-id.test.ts +0 -74
- package/src/utils/__tests__/anvil-api.test.ts +0 -578
- package/src/utils/__tests__/anvil-instance-owner.test.ts +0 -69
- package/src/utils/__tests__/anvil-model-navigation.test.ts +0 -102
- package/src/utils/__tests__/anvil-premium-reset.test.ts +0 -79
- package/src/utils/__tests__/anvil-referral-cache.test.ts +0 -116
- package/src/utils/__tests__/anvil-session-api.test.ts +0 -215
- package/src/utils/__tests__/anvil-session-display.test.ts +0 -23
- package/src/utils/__tests__/anvil-streak-line.test.ts +0 -217
- package/src/utils/__tests__/arrays.test.ts +0 -264
- package/src/utils/__tests__/bash-context-processor.test.ts +0 -38
- package/src/utils/__tests__/block-processor.test.ts +0 -810
- package/src/utils/__tests__/chat-history.test.ts +0 -203
- package/src/utils/__tests__/chat-input-key-intercept.test.ts +0 -40
- package/src/utils/__tests__/chat-meta.test.ts +0 -130
- package/src/utils/__tests__/clipboard-linux.test.ts +0 -359
- package/src/utils/__tests__/clipboard.test.ts +0 -910
- package/src/utils/__tests__/code-search-summary.test.ts +0 -84
- package/src/utils/__tests__/collapse-helpers.test.ts +0 -1109
- package/src/utils/__tests__/error-handling.test.ts +0 -658
- package/src/utils/__tests__/exit-cleanly.test.ts +0 -110
- package/src/utils/__tests__/feedback-helpers.test.ts +0 -444
- package/src/utils/__tests__/feedback-submission.test.ts +0 -26
- package/src/utils/__tests__/fetch-usage.test.ts +0 -355
- package/src/utils/__tests__/fingerprint.test.ts +0 -144
- package/src/utils/__tests__/fixtures/terminal-command-broker-child.ts +0 -7
- package/src/utils/__tests__/fixtures/terminal-command-broker-entry.ts +0 -3
- package/src/utils/__tests__/fixtures/terminal-command-broker-owner.ts +0 -33
- package/src/utils/__tests__/format-elapsed-time.test.ts +0 -103
- package/src/utils/__tests__/format-timeout.test.ts +0 -87
- package/src/utils/__tests__/image-dimensions.test.ts +0 -249
- package/src/utils/__tests__/image-processor.test.ts +0 -209
- package/src/utils/__tests__/implementor-helpers.test.ts +0 -1458
- package/src/utils/__tests__/keyboard-actions.test.ts +0 -660
- package/src/utils/__tests__/layout-helpers.test.ts +0 -36
- package/src/utils/__tests__/lazy-response-ads.test.ts +0 -167
- package/src/utils/__tests__/log-shipper.test.ts +0 -53
- package/src/utils/__tests__/markdown-renderer.test.tsx +0 -421
- package/src/utils/__tests__/message-block-helpers.test.ts +0 -1263
- package/src/utils/__tests__/message-updater.test.ts +0 -645
- package/src/utils/__tests__/osc-timeout-scenarios.test.ts +0 -172
- package/src/utils/__tests__/pending-attachments.test.ts +0 -277
- package/src/utils/__tests__/polling-backoff.test.ts +0 -51
- package/src/utils/__tests__/queue-panel-actions.test.ts +0 -148
- package/src/utils/__tests__/run-state-storage.test.ts +0 -919
- package/src/utils/__tests__/safe-json.test.ts +0 -77
- package/src/utils/__tests__/sdk-event-handlers.test.ts +0 -685
- package/src/utils/__tests__/send-message-helpers.test.ts +0 -1898
- package/src/utils/__tests__/send-message-timer.test.ts +0 -64
- package/src/utils/__tests__/settings.test.ts +0 -99
- package/src/utils/__tests__/strings.test.ts +0 -192
- package/src/utils/__tests__/terminal-color-detection.test.ts +0 -425
- package/src/utils/__tests__/terminal-command-broker.test.ts +0 -528
- package/src/utils/__tests__/terminal-enter-detection.test.ts +0 -77
- package/src/utils/__tests__/terminal-io.test.ts +0 -137
- package/src/utils/__tests__/terminal-protocol-controller.test.ts +0 -119
- package/src/utils/__tests__/text-layout.test.ts +0 -82
- package/src/utils/__tests__/theme-platform-detection.test.ts +0 -125
- package/src/utils/__tests__/think-tag-parser.test.ts +0 -159
- package/src/utils/__tests__/trace-writer.test.ts +0 -223
- package/src/utils/__tests__/trim-chat-logs.test.ts +0 -78
- package/src/utils/__tests__/usage-banner-state.test.ts +0 -298
- package/src/utils/__tests__/validation-error-formatting.test.ts +0 -126
- package/src/utils/__tests__/windows-terminal-health.test.ts +0 -101
- package/src/utils/__tests__/write-file-atomic.test.ts +0 -127
- package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +0 -846
- package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +0 -101
- package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +0 -1408
- package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +0 -258
- package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +0 -48
- package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +0 -282
- package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +0 -526
- package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +0 -68
- package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +0 -132
- package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +0 -422
- package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +0 -167
- package/vendor/@anvil/common/src/__tests__/env-process.test.ts +0 -145
- package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +0 -234
- package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +0 -379
- package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +0 -807
- package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +0 -154
- package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +0 -246
- package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +0 -77
- package/vendor/@anvil/common/src/__tests__/model-config.test.ts +0 -89
- package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +0 -298
- package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +0 -116
- package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +0 -167
- package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +0 -132
- package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +0 -72
- package/vendor/@anvil/common/src/__tests__/user-state.test.ts +0 -30
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +0 -63
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +0 -246
- package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +0 -106
- package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +0 -351
- package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +0 -169
- package/vendor/@anvil/common/src/testing/errors.ts +0 -33
- package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +0 -334
- package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +0 -6
- package/vendor/@anvil/common/src/testing/index.ts +0 -84
- package/vendor/@anvil/common/src/testing/mock-modules.ts +0 -53
- package/vendor/@anvil/common/src/testing/mock-types.ts +0 -123
- package/vendor/@anvil/common/src/testing/mocks/analytics.ts +0 -261
- package/vendor/@anvil/common/src/testing/mocks/child-process.ts +0 -93
- package/vendor/@anvil/common/src/testing/mocks/crypto.ts +0 -218
- package/vendor/@anvil/common/src/testing/mocks/database.ts +0 -337
- package/vendor/@anvil/common/src/testing/mocks/fetch.ts +0 -219
- package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +0 -166
- package/vendor/@anvil/common/src/testing/mocks/index.ts +0 -101
- package/vendor/@anvil/common/src/testing/mocks/logger.ts +0 -135
- package/vendor/@anvil/common/src/testing/mocks/stream.ts +0 -313
- package/vendor/@anvil/common/src/testing/mocks/timers.ts +0 -132
- package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +0 -127
- package/vendor/@anvil/common/src/testing/setup.ts +0 -282
- package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +0 -34
- package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +0 -213
- package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +0 -47
- package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +0 -65
- package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +0 -49
- package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +0 -20
- package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +0 -26
- package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +0 -122
- package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +0 -102
- package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +0 -143
- package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +0 -202
- package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +0 -193
- package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +0 -140
- package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +0 -148
- package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +0 -115
- package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +0 -57
- package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +0 -774
- package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +0 -206
- package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +0 -173
- package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +0 -60
- package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +0 -31
- package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +0 -1252
- package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +0 -505
- package/vendor/@anvil/common/src/util/__tests__/path.test.ts +0 -22
- package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +0 -90
- package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +0 -325
- package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +0 -28
- package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +0 -130
- package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +0 -1008
- package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +0 -289
- package/vendor/@anvil/common/src/util/__tests__/string.test.ts +0 -239
- package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +0 -70
- package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +0 -108
- package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +0 -180
- package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +0 -24
- package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +0 -88
- package/vendor/@anvil/common/src/util/skills.test.ts +0 -44
- package/vendor/@anvil/sdk/dist/index.cjs.map +0 -440
- package/vendor/@anvil/sdk/dist/index.mjs.map +0 -440
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test, mock } from 'bun:test'
|
|
2
|
-
|
|
3
|
-
import { createSendMessageTimerController } from '../send-message-timer'
|
|
4
|
-
|
|
5
|
-
describe('createSendMessageTimerController', () => {
|
|
6
|
-
test('emits start and stop events with elapsed time', () => {
|
|
7
|
-
let nowValue = 1000
|
|
8
|
-
const events: any[] = []
|
|
9
|
-
const mainAgentTimer = {
|
|
10
|
-
start: mock(() => {}),
|
|
11
|
-
stop: mock(() => {}),
|
|
12
|
-
pause: mock(() => {}),
|
|
13
|
-
resume: mock(() => {}),
|
|
14
|
-
isPaused: false,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const controller = createSendMessageTimerController({
|
|
18
|
-
mainAgentTimer: mainAgentTimer as unknown as Parameters<typeof createSendMessageTimerController>[0]['mainAgentTimer'],
|
|
19
|
-
onTimerEvent: (event) => events.push(event),
|
|
20
|
-
now: () => nowValue,
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
controller.start('msg-1')
|
|
24
|
-
nowValue = 1600
|
|
25
|
-
const result = controller.stop('success')
|
|
26
|
-
|
|
27
|
-
expect(result?.elapsedMs).toBe(600)
|
|
28
|
-
expect(events).toHaveLength(2)
|
|
29
|
-
expect(events[0]).toMatchObject({ type: 'start', messageId: 'msg-1' })
|
|
30
|
-
expect(events[1]).toMatchObject({
|
|
31
|
-
type: 'stop',
|
|
32
|
-
messageId: 'msg-1',
|
|
33
|
-
elapsedMs: 600,
|
|
34
|
-
outcome: 'success',
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('ignores repeated starts and tracks active state', () => {
|
|
39
|
-
let nowValue = 0
|
|
40
|
-
const mainAgentTimer = {
|
|
41
|
-
start: mock(() => {}),
|
|
42
|
-
stop: mock(() => {}),
|
|
43
|
-
pause: mock(() => {}),
|
|
44
|
-
resume: mock(() => {}),
|
|
45
|
-
isPaused: false,
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const controller = createSendMessageTimerController({
|
|
49
|
-
mainAgentTimer: mainAgentTimer as unknown as Parameters<typeof createSendMessageTimerController>[0]['mainAgentTimer'],
|
|
50
|
-
onTimerEvent: () => {},
|
|
51
|
-
now: () => nowValue,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
controller.start('msg-1')
|
|
55
|
-
controller.start('msg-1')
|
|
56
|
-
|
|
57
|
-
expect(mainAgentTimer.start).toHaveBeenCalledTimes(1)
|
|
58
|
-
expect(controller.isActive()).toBe(true)
|
|
59
|
-
|
|
60
|
-
nowValue = 25
|
|
61
|
-
controller.stop('error')
|
|
62
|
-
expect(controller.isActive()).toBe(false)
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import os from 'os'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
|
|
5
|
-
import { afterEach, describe, expect, spyOn, test } from 'bun:test'
|
|
6
|
-
import {
|
|
7
|
-
FALLBACK_ANVIL_MODEL_ID,
|
|
8
|
-
ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
|
|
9
|
-
ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
|
|
10
|
-
ANVIL_GLM_V52_MODEL_ID,
|
|
11
|
-
ANVIL_MIMO_V25_MODEL_ID,
|
|
12
|
-
ANVIL_MINIMAX_M3_MODEL_ID,
|
|
13
|
-
} from '@anvil/common/constants/anvil-models'
|
|
14
|
-
|
|
15
|
-
import * as auth from '../auth'
|
|
16
|
-
import {
|
|
17
|
-
loadAnvilModelPreference,
|
|
18
|
-
saveAnvilModelPreference,
|
|
19
|
-
} from '../settings'
|
|
20
|
-
|
|
21
|
-
let testConfigDir: string | undefined
|
|
22
|
-
let getConfigDirSpy: ReturnType<typeof spyOn> | undefined
|
|
23
|
-
|
|
24
|
-
afterEach(() => {
|
|
25
|
-
getConfigDirSpy?.mockRestore()
|
|
26
|
-
getConfigDirSpy = undefined
|
|
27
|
-
if (testConfigDir) {
|
|
28
|
-
fs.rmSync(testConfigDir, { recursive: true, force: true })
|
|
29
|
-
testConfigDir = undefined
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
describe('anvil model preference', () => {
|
|
34
|
-
test('referral-only GLM does not replace the remembered picker model', () => {
|
|
35
|
-
testConfigDir = fs.mkdtempSync(
|
|
36
|
-
path.join(os.tmpdir(), 'anvil-settings-test-'),
|
|
37
|
-
)
|
|
38
|
-
getConfigDirSpy = spyOn(auth, 'getConfigDir').mockReturnValue(testConfigDir)
|
|
39
|
-
|
|
40
|
-
saveAnvilModelPreference(FALLBACK_ANVIL_MODEL_ID)
|
|
41
|
-
saveAnvilModelPreference(ANVIL_GLM_V52_MODEL_ID)
|
|
42
|
-
|
|
43
|
-
expect(loadAnvilModelPreference()).toBe(FALLBACK_ANVIL_MODEL_ID)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test('steers a saved superseded pick to its replacement on every load', () => {
|
|
47
|
-
testConfigDir = fs.mkdtempSync(
|
|
48
|
-
path.join(os.tmpdir(), 'anvil-settings-test-'),
|
|
49
|
-
)
|
|
50
|
-
getConfigDirSpy = spyOn(auth, 'getConfigDir').mockReturnValue(testConfigDir)
|
|
51
|
-
|
|
52
|
-
// A preference saved before Flash overtook MiniMax M3. Written directly so
|
|
53
|
-
// it has no migration marker, exactly like a real pre-upgrade settings file.
|
|
54
|
-
fs.writeFileSync(
|
|
55
|
-
path.join(testConfigDir, 'settings.json'),
|
|
56
|
-
JSON.stringify({ anvilModel: ANVIL_MINIMAX_M3_MODEL_ID }),
|
|
57
|
-
)
|
|
58
|
-
expect(loadAnvilModelPreference()).toBe(
|
|
59
|
-
ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
// Re-picking M3 does NOT make it the standing default again: the next
|
|
63
|
-
// session steers back to Flash. Selecting it still works for the session
|
|
64
|
-
// the user is in — this only governs what a fresh launch opens on.
|
|
65
|
-
saveAnvilModelPreference(ANVIL_MINIMAX_M3_MODEL_ID)
|
|
66
|
-
expect(loadAnvilModelPreference()).toBe(
|
|
67
|
-
ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
// Same for the limited tier's other pick, MiMo 2.5.
|
|
71
|
-
saveAnvilModelPreference(ANVIL_MIMO_V25_MODEL_ID)
|
|
72
|
-
expect(loadAnvilModelPreference()).toBe(
|
|
73
|
-
ANVIL_DEEPSEEK_V4_FLASH_MODEL_ID,
|
|
74
|
-
)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('leaves a saved DeepSeek V4 Pro pick alone', () => {
|
|
78
|
-
testConfigDir = fs.mkdtempSync(
|
|
79
|
-
path.join(os.tmpdir(), 'anvil-settings-test-'),
|
|
80
|
-
)
|
|
81
|
-
getConfigDirSpy = spyOn(auth, 'getConfigDir').mockReturnValue(testConfigDir)
|
|
82
|
-
|
|
83
|
-
// Pro was steered off until its 08/13 GA build overtook Flash again. A user
|
|
84
|
-
// who deliberately picks the deep-reasoning model must now still be on it
|
|
85
|
-
// next launch, migration marker or not.
|
|
86
|
-
fs.writeFileSync(
|
|
87
|
-
path.join(testConfigDir, 'settings.json'),
|
|
88
|
-
JSON.stringify({ anvilModel: ANVIL_DEEPSEEK_V4_PRO_MODEL_ID }),
|
|
89
|
-
)
|
|
90
|
-
expect(loadAnvilModelPreference()).toBe(
|
|
91
|
-
ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
saveAnvilModelPreference(ANVIL_DEEPSEEK_V4_PRO_MODEL_ID)
|
|
95
|
-
expect(loadAnvilModelPreference()).toBe(
|
|
96
|
-
ANVIL_DEEPSEEK_V4_PRO_MODEL_ID,
|
|
97
|
-
)
|
|
98
|
-
})
|
|
99
|
-
})
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
truncateToLines,
|
|
5
|
-
MAX_COLLAPSED_LINES,
|
|
6
|
-
createTextPasteHandler,
|
|
7
|
-
createPasteHandler,
|
|
8
|
-
LONG_TEXT_THRESHOLD,
|
|
9
|
-
} from '../strings'
|
|
10
|
-
|
|
11
|
-
import type { InputValue } from '../../types/store'
|
|
12
|
-
|
|
13
|
-
describe('MAX_COLLAPSED_LINES', () => {
|
|
14
|
-
test('is set to 3', () => {
|
|
15
|
-
expect(MAX_COLLAPSED_LINES).toBe(3)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('truncateToLines', () => {
|
|
20
|
-
test('returns empty string unchanged', () => {
|
|
21
|
-
expect(truncateToLines('', 3)).toBe('')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('returns falsy values unchanged', () => {
|
|
25
|
-
expect(truncateToLines(null, 3)).toBe(null)
|
|
26
|
-
expect(truncateToLines(undefined, 3)).toBe(undefined)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test('returns single line unchanged', () => {
|
|
30
|
-
expect(truncateToLines('single line', 3)).toBe('single line')
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('returns text with fewer lines than max unchanged', () => {
|
|
34
|
-
const text = 'line 1\nline 2'
|
|
35
|
-
expect(truncateToLines(text, 3)).toBe('line 1\nline 2')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('returns text with exact max lines unchanged', () => {
|
|
39
|
-
const text = 'line 1\nline 2\nline 3'
|
|
40
|
-
expect(truncateToLines(text, 3)).toBe('line 1\nline 2\nline 3')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('truncates text exceeding max lines and adds ellipsis', () => {
|
|
44
|
-
const text = 'line 1\nline 2\nline 3\nline 4'
|
|
45
|
-
expect(truncateToLines(text, 3)).toBe('line 1\nline 2\nline 3...')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('truncates text with many lines', () => {
|
|
49
|
-
const text = 'line 1\nline 2\nline 3\nline 4\nline 5\nline 6'
|
|
50
|
-
expect(truncateToLines(text, 3)).toBe('line 1\nline 2\nline 3...')
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('handles maxLines of 1', () => {
|
|
54
|
-
const text = 'line 1\nline 2\nline 3'
|
|
55
|
-
expect(truncateToLines(text, 1)).toBe('line 1...')
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('trims trailing whitespace before adding ellipsis', () => {
|
|
59
|
-
const text = 'line 1\nline 2 \nline 3\nline 4'
|
|
60
|
-
expect(truncateToLines(text, 2)).toBe('line 1\nline 2...')
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
test('handles text with empty lines', () => {
|
|
64
|
-
const text = 'line 1\n\nline 3\nline 4'
|
|
65
|
-
expect(truncateToLines(text, 3)).toBe('line 1\n\nline 3...')
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('handles text ending with newline', () => {
|
|
69
|
-
const text = 'line 1\nline 2\nline 3\n'
|
|
70
|
-
// 4 lines when split (last is empty), but only 3 visible lines of content
|
|
71
|
-
expect(truncateToLines(text, 3)).toBe('line 1\nline 2\nline 3...')
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
describe('createTextPasteHandler - ANSI stripping', () => {
|
|
76
|
-
test('strips ANSI escape sequences from pasted text', () => {
|
|
77
|
-
let result: InputValue | null = null
|
|
78
|
-
const handler = createTextPasteHandler('', 0, (value) => { result = value })
|
|
79
|
-
|
|
80
|
-
handler('\x1b[31mred text\x1b[0m')
|
|
81
|
-
|
|
82
|
-
expect(result).not.toBeNull()
|
|
83
|
-
expect(result!.text).toBe('red text')
|
|
84
|
-
expect(result!.cursorPosition).toBe(8)
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
test('passes through plain text unchanged', () => {
|
|
88
|
-
let result: InputValue | null = null
|
|
89
|
-
const handler = createTextPasteHandler('', 0, (value) => { result = value })
|
|
90
|
-
|
|
91
|
-
handler('plain text')
|
|
92
|
-
|
|
93
|
-
expect(result).not.toBeNull()
|
|
94
|
-
expect(result!.text).toBe('plain text')
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
test('strips complex ANSI sequences (bold, 256-color)', () => {
|
|
98
|
-
let result: InputValue | null = null
|
|
99
|
-
const handler = createTextPasteHandler('', 0, (value) => { result = value })
|
|
100
|
-
|
|
101
|
-
handler('\x1b[1m\x1b[38;5;196mbold colored\x1b[0m')
|
|
102
|
-
|
|
103
|
-
expect(result).not.toBeNull()
|
|
104
|
-
expect(result!.text).toBe('bold colored')
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
test('does not insert when text is only ANSI codes (empty after stripping)', () => {
|
|
108
|
-
let result: InputValue | null = null
|
|
109
|
-
const handler = createTextPasteHandler('', 0, (value) => { result = value })
|
|
110
|
-
|
|
111
|
-
handler('\x1b[31m\x1b[0m')
|
|
112
|
-
|
|
113
|
-
expect(result).toBeNull()
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test('inserts stripped text at cursor position in existing text', () => {
|
|
117
|
-
let result: InputValue | null = null
|
|
118
|
-
const handler = createTextPasteHandler('hello world', 5, (value) => { result = value })
|
|
119
|
-
|
|
120
|
-
handler('\x1b[32m pasted\x1b[0m')
|
|
121
|
-
|
|
122
|
-
expect(result).not.toBeNull()
|
|
123
|
-
expect(result!.text).toBe('hello pasted world')
|
|
124
|
-
expect(result!.cursorPosition).toBe(12)
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
describe('createPasteHandler - ANSI stripping', () => {
|
|
129
|
-
test('strips ANSI from eventText for regular text paste', () => {
|
|
130
|
-
let result: InputValue | null = null
|
|
131
|
-
const handler = createPasteHandler({
|
|
132
|
-
text: '',
|
|
133
|
-
cursorPosition: 0,
|
|
134
|
-
onChange: (value) => { result = value },
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
handler('\x1b[31mhello\x1b[0m')
|
|
138
|
-
|
|
139
|
-
expect(result).not.toBeNull()
|
|
140
|
-
expect(result!.text).toBe('hello')
|
|
141
|
-
expect(result!.cursorPosition).toBe(5)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
test('strips ANSI from eventText before checking long text threshold', () => {
|
|
145
|
-
let longTextResult: string | null = null
|
|
146
|
-
const handler = createPasteHandler({
|
|
147
|
-
text: '',
|
|
148
|
-
cursorPosition: 0,
|
|
149
|
-
onChange: () => {},
|
|
150
|
-
onPasteLongText: (text) => { longTextResult = text },
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
// Create text that is over threshold BEFORE stripping but under AFTER
|
|
154
|
-
const ansiOverhead = '\x1b[31m'.repeat(400) + '\x1b[0m'.repeat(400)
|
|
155
|
-
const shortContent = 'a'.repeat(100)
|
|
156
|
-
handler(ansiOverhead + shortContent)
|
|
157
|
-
|
|
158
|
-
// Should NOT be treated as long text since stripped content is short
|
|
159
|
-
expect(longTextResult).toBeNull()
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
test('strips ANSI but preserves plain text content', () => {
|
|
163
|
-
let result: InputValue | null = null
|
|
164
|
-
const handler = createPasteHandler({
|
|
165
|
-
text: 'existing ',
|
|
166
|
-
cursorPosition: 9,
|
|
167
|
-
onChange: (value) => { result = value },
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
handler('\x1b[1m\x1b[34mblue bold text\x1b[0m')
|
|
171
|
-
|
|
172
|
-
expect(result).not.toBeNull()
|
|
173
|
-
expect(result!.text).toBe('existing blue bold text')
|
|
174
|
-
expect(result!.cursorPosition).toBe(23)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
test('long text handler receives stripped text', () => {
|
|
178
|
-
let longTextResult: string | null = null
|
|
179
|
-
const handler = createPasteHandler({
|
|
180
|
-
text: '',
|
|
181
|
-
cursorPosition: 0,
|
|
182
|
-
onChange: () => {},
|
|
183
|
-
onPasteLongText: (text) => { longTextResult = text },
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
const longContent = 'x'.repeat(LONG_TEXT_THRESHOLD + 1)
|
|
187
|
-
handler(`\x1b[31m${longContent}\x1b[0m`)
|
|
188
|
-
|
|
189
|
-
expect(longTextResult).not.toBeNull()
|
|
190
|
-
expect(longTextResult!).toBe(longContent)
|
|
191
|
-
})
|
|
192
|
-
})
|