Repository navigation
fix(cli): send Jev a short name for each control - #38
Merged
Merged
Conversation
A posted control keeps its role and visible name. The field value, wrapped lines, and anything past 80 characters stay out of the request.
Stop the posted name at a comma, a new line, or 80 characters so a text field's contents cannot push the rank request over Jev's token limit.
The first comma is often inside a trait list such as (selected, settable). Cut at the renderer metadata suffix, then cap the first line at 80 characters.
Cut renderer suffixes in the accessibility parser, and keep trait commas in the name. criteria() only caps that name at 80 code points.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Jev rejected a rank of the Electron chat window after that window grew to 143 controls. The request was about 150KB. TypeSafe answered HTTP 400 with
{"detail":{"error_type":"max_tokens_exceeded"}}.criteria()was sending each control's full accessibility text, including the text inside a field and lines that wrap under it. That text is copied into the state and into two questions.The accessibility parser now keeps one visible name per row. It keeps the first line and drops a renderer suffix (
Value,Placeholder,Description,Text, orSecondary Actions). Darwin's barePlaceholder:is included: a leading space and no comma, used when the control has no name and no value. A trait list such as(selected, settable)stays, including on a single-word role, sobutton (selected, expanded) New NotekeepsNew Note.criteria()joins that role and name and stops at 80 code points.button New Noteis unchanged. The raw row stays online. The local suggestion uses the visible name, with no cap.disabledandsettableare read from that same trait list.(selected, disabled)disables the control. A field value that contains those words does not.Scope
parseTreeMovesinpackages/cli/src/intent/tree.tscriteriainpackages/cli/src/intent/evaluate.tstests/intent/tree.test.tsandtests/intent/evaluate.test.tsTradeoffs
The control list stays in the state and on both choice questions. Cutting each name is what brings a full 255-control request back under the limit. A second request after a token error would send the same oversized body again.
Jev sees the field's name. The text inside the field stays off the request. Two fields with the same name still look the same.
A text row whose renderer appends the value with a space and no suffix has no boundary to cut. The 80-code-point cap is the bound. Those rows stay out of the rank unless the role or a settable trait marks them clickable.
A visible name that itself contains
Placeholder:is cut at that mark. That is the same string Darwin writes for a bare placeholder.Blast Radius
This changes the text sent to Jev and the
clickablemap onjev.debug, because both callcriteria(). A short name such asbutton New Noteis the same string as before. Ranking of a window whose controls already had short names does not change.The suggestion label is the visible name. A field value that used to ride along in the label stays on
lineand in the snapshot text.A combined trait list now changes the flags.
button (selected, disabled) Formatis not clickable.button (selected, settable)is settable. A lone(disabled)trait behaves as before.Verification
pnpm exec vitest run --config vitest.workspace.ts tests/intentpassed 85 tests.pnpm --filter @crosshands/cli typecheckpassed.oxlintreported 0 warnings on the four edited files.The tests lock
button (selected, expanded) New Note, a barePlaceholder:, a 5000-character name, an emoji cap that stays on a code-point boundary, and a field value that says(disabled)without disabling the control.A request in the same shape as
liveEvaluator, with 255 names of 80 dense characters, was 68401 bytes.POST https://api.typesafe.ai/v1/systemonereturned HTTP 200 from modeljev-1.13.0withinput_tokens49439. The same shape at 150468 dense bytes had returned HTTP 400 and{"detail":{"error_type":"max_tokens_exceeded"}}. That measurement is from the earlier short-name payload. This parser move posts the same shape: one name of at most 80 code points, copied into the state and both choice questions.