Commit 2f57cf6
refactor(copilot): quality pass over the parser and its tests
Four changes from a reuse/simplification/efficiency/altitude review. No behaviour
change; 162 tests unchanged.
blankJsonStringLiterals returns the body untouched when it contains no quote. No
quote means no string literal, so the loop was copying the body to itself
character by character. unclosedTagCannotResolve had learned to short-circuit
before calling it; literalTextReason had not, and blanked unconditionally on
every already-rejected tag on every later chunk. Putting the guard inside the
helper fixes both callers at once.
inspectWithin and inspectFrom were near-duplicates added at different times. One
function with an optional start expresses both, and keeps the property the second
one existed for: slice once, already bounded, never `content.slice(bodyStart)`
first and bound after.
The frame-replay property was 1727ms — 95% of the file's test time — because it
parses every prefix, so message length multiplies into parse count, and the
fragment pool included a 6KB filler. Retraction happens AT a frame boundary, not
as a function of message size, so that property now draws from the short
fragments; the window-crossing filler still gets coverage from the properties
that parse each message once. 1727ms to 205ms, same seeds, same assertions. It
also now calls replayFrames instead of hand-rolling the stepping loop it already
had a helper for.
Deferred deliberately, each with a reason:
- Collapsing `prose-nested-marker` into `nested-marker`. Its own docstring names
the simplification and defers it; it is a behaviour change and wants its own
commit and test, which is the pattern the rest of this branch follows.
- Bounding hasSpecialTagMarker on the prose path. Costs tens of microseconds on
a long reasoning body, but a marker past the bound would flip that body from
released to suppressed — a retraction, which is the bug two commits back.
- Splitting the parser out of this `'use client'` file. The strongest structural
finding: the file cannot be imported by server code, which is why the inbox
executor carries its own thinking-strip regex. It is a mechanical move with no
logic change and deserves its own PR, not commit 25 of this one.
- Generalising the backtick sanitizer past `workspace_resource`, and replacing it
with parser-owned backtick consumption. Same reasoning: real, and not here.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ced378a commit 2f57cf6
2 files changed
Lines changed: 31 additions & 29 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags
Lines changed: 20 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | | - | |
| 826 | + | |
827 | 827 | | |
828 | | - | |
| 828 | + | |
829 | 829 | | |
830 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
831 | 843 | | |
832 | 844 | | |
833 | 845 | | |
| |||
876 | 888 | | |
877 | 889 | | |
878 | 890 | | |
879 | | - | |
| 891 | + | |
880 | 892 | | |
881 | 893 | | |
882 | 894 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
| 895 | + | |
| 896 | + | |
887 | 897 | | |
888 | 898 | | |
889 | 899 | | |
890 | 900 | | |
891 | | - | |
| 901 | + | |
892 | 902 | | |
893 | | - | |
894 | | - | |
| 903 | + | |
| 904 | + | |
895 | 905 | | |
896 | 906 | | |
897 | 907 | | |
| |||
Lines changed: 11 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
554 | 559 | | |
555 | 560 | | |
556 | 561 | | |
| |||
810 | 815 | | |
811 | 816 | | |
812 | 817 | | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
831 | 823 | | |
832 | 824 | | |
833 | 825 | | |
| |||
972 | 964 | | |
973 | 965 | | |
974 | 966 | | |
975 | | - | |
| 967 | + | |
976 | 968 | | |
977 | 969 | | |
978 | 970 | | |
| |||
0 commit comments