Skip to content

Commit 4250fd6

Browse files
committed
feat: enable async token counting with piscina workers
Port tokenizer logic into a Piscina worker pool so token counting no longer blocks the main thread and exposes async APIs across IPC. Render live token estimates in chat input with Suspense fallback and tighten defensive assertions while adapting tests to the new async flow.
1 parent 1202238 commit 4250fd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1446
-1445
lines changed

.github/workflows/chromatic.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ jobs:
3636
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
3737
exitZeroOnChanges: true
3838
onlyChanged: true
39-

.github/workflows/publish-npm.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- main
77
tags:
8-
- 'v*'
8+
- "v*"
99
workflow_dispatch:
1010

1111
permissions:
@@ -24,12 +24,12 @@ jobs:
2424

2525
- uses: ./.github/actions/setup-cmux
2626
with:
27-
install-imagemagick: 'true'
27+
install-imagemagick: "true"
2828

2929
# Sets up .npmrc with the auth token
3030
- uses: actions/setup-node@v4
3131
with:
32-
registry-url: 'https://registry.npmjs.org'
32+
registry-url: "https://registry.npmjs.org"
3333

3434
- run: sudo npm i -g npm@latest
3535

@@ -38,10 +38,10 @@ jobs:
3838
run: |
3939
# Get base version from package.json
4040
BASE_VERSION=$(node -p "require('./package.json').version")
41-
41+
4242
# Generate git describe version
4343
GIT_DESCRIBE=$(git describe --tags --always --dirty 2>/dev/null || echo "unknown")
44-
44+
4545
if [[ $GITHUB_REF == refs/tags/* ]]; then
4646
# For tags, use the base version as-is (stable release)
4747
NPM_VERSION="${BASE_VERSION}"
@@ -56,13 +56,13 @@ jobs:
5656
NPM_TAG="next"
5757
echo "Publishing pre-release: ${NPM_VERSION}"
5858
fi
59-
59+
6060
echo "version=${NPM_VERSION}" >> $GITHUB_OUTPUT
6161
echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT
62-
62+
6363
# Update package.json with the new version
6464
node -e "const fs = require('fs'); const pkg = JSON.parse(fs.readFileSync('package.json')); pkg.version = '${NPM_VERSION}'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
65-
65+
6666
echo "Updated package.json to version ${NPM_VERSION}"
6767
6868
- name: Generate version file
@@ -76,7 +76,7 @@ jobs:
7676
run: |
7777
PACKAGE_NAME=$(node -p "require('./package.json').name")
7878
VERSION="${{ steps.version.outputs.version }}"
79-
79+
8080
if npm view "${PACKAGE_NAME}@${VERSION}" version &>/dev/null; then
8181
echo "exists=true" >> $GITHUB_OUTPUT
8282
echo "Version ${VERSION} already exists on npm"
@@ -95,7 +95,7 @@ jobs:
9595
PACKAGE_NAME=$(node -p "require('./package.json').name")
9696
VERSION="${{ steps.version.outputs.version }}"
9797
TAG="${{ steps.version.outputs.tag }}"
98-
98+
9999
echo "Version ${VERSION} already published, updating dist-tag to ${TAG}"
100100
npm dist-tag add "${PACKAGE_NAME}@${VERSION}" "${TAG}"
101101

.github/workflows/terminal-bench.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ on:
44
workflow_dispatch:
55
inputs:
66
dataset:
7-
description: 'Terminal-Bench dataset to use'
7+
description: "Terminal-Bench dataset to use"
88
required: false
9-
default: 'terminal-bench-core==0.1.1'
9+
default: "terminal-bench-core==0.1.1"
1010
type: string
1111
concurrency:
12-
description: 'Number of concurrent tasks (--n-concurrent)'
12+
description: "Number of concurrent tasks (--n-concurrent)"
1313
required: false
14-
default: '4'
14+
default: "4"
1515
type: string
1616
livestream:
17-
description: 'Enable livestream mode'
17+
description: "Enable livestream mode"
1818
required: false
1919
default: true
2020
type: boolean
2121
sample_size:
22-
description: 'Number of random tasks to run (empty = all tasks)'
22+
description: "Number of random tasks to run (empty = all tasks)"
2323
required: false
2424
type: string
2525
extra_args:
26-
description: 'Additional arguments to pass to terminal-bench'
26+
description: "Additional arguments to pass to terminal-bench"
2727
required: false
2828
type: string
2929

@@ -69,4 +69,3 @@ jobs:
6969
terminal-bench-results/
7070
*.json
7171
if-no-files-found: warn
72-

.storybook/mocks/version.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ export const VERSION = {
66
git_describe: "v1.0.0",
77
buildTime: "2024-01-24T17:41:00Z", // 9:41 AM PST
88
};
9-

bun.lock

Lines changed: 65 additions & 0 deletions
Large diffs are not rendered by default.

chromatic.config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66
"exitOnceUploaded": true,
77
"autoAcceptChanges": false
88
}
9-

codecov.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ coverage:
1414
# Project coverage status - informational only
1515
project:
1616
default:
17-
target: auto # Compare to base commit
18-
threshold: 5% # Allow 5% drop without changing status
19-
informational: true # Won't block PRs
17+
target: auto # Compare to base commit
18+
threshold: 5% # Allow 5% drop without changing status
19+
informational: true # Won't block PRs
2020

21-
# Patch coverage status - informational only
21+
# Patch coverage status - informational only
2222
patch:
2323
default:
24-
target: auto # Compare to base commit
25-
threshold: 5% # Allow 5% drop without changing status
26-
informational: true # Won't block PRs
24+
target: auto # Compare to base commit
25+
threshold: 5% # Allow 5% drop without changing status
26+
informational: true # Won't block PRs
2727

2828
# Flag configuration to track unit vs integration test coverage
2929
flags:

components.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
"utils": "@/lib/utils"
1616
}
1717
}
18-

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"lru-cache": "^11.2.2",
7070
"markdown-it": "^14.1.0",
7171
"minimist": "^1.2.8",
72+
"piscina": "^5.1.3",
7273
"rehype-harden": "^1.1.5",
7374
"shescape": "^2.1.6",
7475
"source-map-support": "^0.5.21",

public/manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@
3232
}
3333
]
3434
}
35-

0 commit comments

Comments
 (0)