Skip to content

[DONE] 끝이 잘린 코드를 붙이면 Lab 과 Live Editor 가 코드가 끝나기 전에 끊겼다고 말한다 - #148

Merged
patternflow-bot merged 4 commits into
devfrom
claude/lsh-pf-round49-djp1or
Oct 22, 2026
Merged

patternflow-bot merged 4 commits into
devfrom
claude/lsh-pf-round49-djp1or

Conversation

@patternflow-bot

@patternflow-bot patternflow-bot commented Oct 22, 2026 •

Copy link
Copy Markdown

lsh / https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs

붙인 패턴 코드가 중간에 끊기면 Lab 의 Code 패널과 Live Editor 가 사용자가 쓰지도 않은 return 이나 ) 를 탓했어요. 이제는 닫히지 않은 괄호 수와 마지막 줄을 보여 주고 붙여 넣다 끊겼느냐고 물어요. 머지하면 AI 가 만든 코드를 반만 붙인 사람이 무엇이 빠졌는지 바로 알아요.

좋아지는 것: 잘린 코드를 붙이면 끊겼다고 말한다 — 없는 글자를 찾아 헤매지 않는다

할 일

한 일

describePatternError(web/src/lib/pattern/harness.ts)가 문법 오류를 받으면 먼저 붙인 코드를 처음부터 끝까지 훑어요. 문자열, 주석, 템플릿, 정규식 안의 괄호는 세지 않아요. 끝에 (, [, {, 템플릿의 ${, 닫히지 않은 따옴표나 백틱, /* 가 남아 있으면 엔진의 글 대신 이렇게 말해요.

The code stops before it ends: 1 ( and 3 { never close. Was the paste cut off?
line 9 (the last): display.setPixel(x, y,

가운데가 깨진 코드는 엔진의 글을 그대로 둬요. 닫는 괄호가 다른 여는 괄호를 만나거나 문자열이 줄을 넘어가면 끊긴 게 아니라 틀린 거라서예요. Lab(PatternRuntime.loadCode)과 Live Editor(LedMatrixTexture.loadCode)가 둘 다 이 함수를 불러서 한 곳만 고쳤어요. 커뮤니티 카드가 쓰는 public/pattern-sandbox.html 은 npm run build:sandbox 로 다시 만들었어요.

시험은 새 web/src/lib/pattern/harness.test.ts 열 개예요. LedMatrixTexture.test.ts 의 「코드가 안 읽히는 동안 앞 패턴을 지킨다」 시험은 /^Unexpected/ 를 기대하고 있었어요. 그 시험이 넣는 코드가 바로 끊긴 코드(display.setPixel(0, 0,)라서 새 글을 기대하게 바꿨어요.

증거

고치기 전 dev 에서 넷을 붙여 본 글이에요.

--- cut mid-call
Unexpected token 'return'
--- last brace missing
Unexpected token ')'
--- paren missing mid
missing ) after argument list
--- cut in string
Invalid or unexpected token

고친 뒤예요. 가운데가 깨진 두 줄은 그대로예요.

--- cut mid-call
The code stops before it ends: 1 ( and 3 { never close. Was the paste cut off?
line 8 (the last): display.setPixel(x, y,
--- last brace missing
The code stops before it ends: 1 { never closes. Was the paste cut off?
line 10 (the last): }
--- paren missing mid
missing ) after argument list
--- cut in string
Invalid or unexpected token

새 시험을 dev 의 harness.ts 에 돌리면 끊긴 코드 시험 여섯과 Live Editor 시험 하나, 일곱이 빨개요.

$ npx vitest run src/lib/pattern/harness.test.ts src/components/3d/LedMatrixTexture.test.ts   # dev 의 harness.ts
      Tests  7 failed | 9 passed (16)
$ npx vitest run src/lib/pattern/harness.test.ts src/components/3d/LedMatrixTexture.test.ts src/components/sections/PatternPanel.test.tsx
      Tests  23 passed (23)

web/ 에서 다섯 검사의 끝줄이에요.

$ npm ci
added 794 packages in 23s
$ npm run lint -- --max-warnings=0
> eslint --max-warnings=0            (출력 없음, 0)
$ npm run typecheck
> tsc --noEmit && tsc --noEmit -p ../tools/virtual-panel            (출력 없음, 0)
$ npm run build
build exit 0
$ npm run check:ci
 Test Files  81 passed (81)
      Tests  850 passed (850)
skipped  links-absolute
skipped  roadmap
passed   virtual-panel
check:ci exit 0
$ npm run check:sandbox-sync
pattern-sandbox.html is up to date
$ npm run check:voice
check:voice: nothing found

빌드한 사이트에 끊긴 코드를 붙인 화면이에요. Lab 은 Paste 단추로, Live Editor 는 편집기에 Ctrl+V 로 붙였어요.

폰 390 · Pattern Lab
데스크톱 1440 · Pattern Lab
폰 390 · Live Editor
데스크톱 1440 · Live Editor

실행법

cd web
npx vitest run src/lib/pattern/harness.test.ts
npm run dev

/pattern-lab 의 Code 패널이나 /pattern 의 편집기에 패턴 코드를 반쯤 잘라 붙이면 편집기 위(Lab)나 아래(Live Editor)에 위 글이 떠요.

가정

  • 줄의 예시는 "2 { and 1 (" 차례였는데, 먼저 닫아야 하는 안쪽부터 적었어요. "1 ( and 3 {" 예요.
  • 줄은 "Last line: …" 꼴을 적었는데, 런타임 오류가 이미 쓰는 "line 6: …" 꼴에 맞춰 "line 9 (the last): …" 로 했어요. 긴 줄은 끊긴 자리가 보이게 앞을 줄이고 끝 79자를 남겨요.
  • / 가 정규식인지 나눗셈인지는 앞 글자로 가려요. x++ / 2 같은 드문 꼴은 정규식으로 잘못 읽어요. 이 검사는 이미 문법 오류가 난 코드에서만 돌고, 잘못 읽어 짝이 안 맞으면 엔진의 글로 돌아가요.
  • 끊기지 않은 문법 오류에 줄 번호가 없는 것(harness.ts 의 옛 :413 주석)은 이 줄의 고칠 곳이 아니라 그대로예요.
  • 이 컨테이너의 프록시가 cdn.jsdelivr.net 을 403 으로 막아서 Monaco 가 「Loading…」에 멈췄어요. 사진 스크립트에서만 그 주소를 node_modules/monaco-editor/min/(같은 0.55.1)으로 돌렸어요. 사이트는 그대로예요.
  • 표 밖: Lab Code 패널의 Paste 가 클립보드를 못 읽을 때 뜨는 window.prompt 글이 영어 쪽인데 한국어예요(app/pattern-lab/panels/CodePanel.tsx:94).

Changelog

Web

  • Pattern Lab and the Live Editor say when pasted code was cut off. Code that stopped inside a call reported "Unexpected token 'return'", and code missing its last } reported "Unexpected token ')'", tokens the author never typed. The message now counts the brackets that never close and quotes the last line.

경험

언제: 바퀴에서 Pattern Lab 이나 Live Editor 의 Monaco 편집기를 빌드한 사이트로 찍을 때
교훈: @monaco-editor/react 는 cdn.jsdelivr.net 에서 편집기를 받는데 컨테이너 프록시가 막으니, Playwright context.route 로 그 주소를 web/node_modules/monaco-editor/min/ 의 같은 판 파일로 돌려준다
근거: #148 에서 curl 이 「CONNECT tunnel failed, response 403」을 냈고 Lab Code 패널과 Live Editor 가 「Loading…」에 멈췄는데, 0.55.1 파일로 돌리자 두 편집기가 떠서 붙여 넣기까지 찍혔다

바퀴

바퀴 49 · 후보 5 「끝이 잘린 코드를 붙이면 Lab 과 Live Editor 가 코드가 끝나기 전에 끊겼다고 말한다」

다음 바퀴

  • 후보 6 「폰에서 Lab 의 Recent 와 Panels 메뉴가 화면 안에 열리고, 창 닫기 단추를 누르기 쉽다」. 390px 에서 Recent 메뉴가 x −105px 부터 열려 글이 잘려요.
  • 후보 7 「기기 주소 칸을 비우거나 http:// 를 붙여 넣어도 「Send over Wi-Fi」 링크가 그 보드로 간다」. 붙여 넣은 http://192.168.0.44 에선 링크의 호스트가 http 가 돼요.
  • 후보 8 「Lab 과 Live Editor 의 복사 단추가 복사에 실패하면 그렇다고 말한다」. Live Editor 는 복사가 안 돼도 됐다고 alert 를 띄워요.

https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs
@patternflow-bot patternflow-bot changed the title [WIP] pf 49바퀴 — 고를 후보를 읽는 중 [WIP] 끝이 잘린 코드를 붙이면 Lab 과 Live Editor 가 코드가 끝나기 전에 끊겼다고 말한다 Oct 22, 2026
…author never typed

Code cut inside a call reported "Unexpected token 'return'", and code missing its last } reported "Unexpected token ')'": the return compilePatternCode appends and the ) new Function closes with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShmHaiHWZwMYMhgK7tJvDs
@patternflow-bot patternflow-bot changed the title [WIP] 끝이 잘린 코드를 붙이면 Lab 과 Live Editor 가 코드가 끝나기 전에 끊겼다고 말한다 [DONE] 끝이 잘린 코드를 붙이면 Lab 과 Live Editor 가 코드가 끝나기 전에 끊겼다고 말한다 Oct 22, 2026
@patternflow-bot
patternflow-bot marked this pull request as ready for review October 22, 2026 01:33
@patternflow-bot
patternflow-bot merged commit 81ef339 into dev Oct 22, 2026
2 checks passed
@patternflow-bot
patternflow-bot deleted the claude/lsh-pf-round49-djp1or branch October 22, 2026 01:35
engmung pushed a commit to engmung/Patternflow that referenced this pull request Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants