Skip to content

fix: 브릿지 메시지 앱 버전 게이팅 도입 - #384

Merged
iOdiO89 merged 5 commits into
devfrom
fix/370-app-web-version
Jul 27, 2026
Merged

fix: 브릿지 메시지 앱 버전 게이팅 도입#384
iOdiO89 merged 5 commits into
devfrom
fix/370-app-web-version

Conversation

@iOdiO89

@iOdiO89 iOdiO89 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

작업 요약

  • 웹은 즉시 배포되지만 앱은 스토어 심사·업데이트가 느려 발생하는 버전 불일치를, 앱이 아직 지원하지 않는 네이티브 기능 호출을 사전에 막는 방식으로 대응합니다.

작업 내용

  • UA의 PIKI_APP/<version> 토큰에서 앱 버전을 추출/비교하는 유틸(getAppVersion, isAppVersionSupported)을 서버·클라이언트 공통으로 정리
  • 브릿지 메시지별 최소 지원 앱 버전과 차단 시 안내 노출 여부를 BRIDGE_GATE로 정의하고, WebBridge.postMessage가 전송 전 이를 검사하도록 변경 (전송 성공 여부를 boolean으로 반환)
  • 앱 응답을 기다리는 이미지 피커 호출부가 전송 차단 시 대기 상태를 정리하도록 수정
  • 소셜 로그인 관련 브릿지 메시지 키를 네이밍 규칙(WEB_REQ_*/APP_RES_*)에 맞게 정리 (배포된 앱과의 호환을 위해 와이어 값은 유지)
  • CLAUDE.md에 웹뷰 브릿지 작업 규칙 문서화

스크린샷

버전을 만족하지 않을 경우 토스트가 뜨는 예시

2026-07-25.7.40.36.mov

연관 이슈

closes #370

Summary by CodeRabbit

  • 새 기능

    • 앱 버전에 따라 웹뷰 기능 사용 가능 여부를 확인하고, 지원되지 않는 경우 앱 업데이트 안내를 제공합니다.
    • 웹뷰 메시지 전송 결과를 확인해 이미지 선택 등 요청 상태를 안정적으로 관리합니다.
    • 웹뷰 환경과 앱 버전 인식이 개선되었습니다.
  • 버그 수정

    • 소셜 로그인 요청 및 성공·실패 결과 처리를 앱과 웹 간 변경된 메시지 규격에 맞게 개선했습니다.
    • 메시지 전송이 차단되거나 실패했을 때 대기 상태가 남는 문제를 수정했습니다.
  • 문서

    • 웹뷰 브릿지 메시지 호환성, 버전 제한 및 보안 처리 기준을 문서화했습니다.

@iOdiO89 iOdiO89 self-assigned this Jul 25, 2026
@iOdiO89 iOdiO89 added fix Something isn't working APP Good for newcomers labels Jul 25, 2026
@iOdiO89 iOdiO89 linked an issue Jul 25, 2026 that may be closed by this pull request
7 tasks
@iOdiO89 iOdiO89 added the refactor Extra attention is needed label Jul 25, 2026
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
piki Ready Ready Preview, Comment Jul 27, 2026 1:34pm

@github-actions

Copy link
Copy Markdown

Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

웹뷰 브릿지 메시지 명칭을 방향별로 정리하고, 앱 버전 파싱·비교 및 최소 버전 게이트를 추가했습니다. postMessage는 전송 성공 여부를 반환하며, 관련 호출부는 실패 시 대기 상태를 정리합니다.

Changes

WebView 브릿지 호환성

Layer / File(s) Summary
브릿지 메시지 계약 정리
packages/core/src/consts/webBridge.ts, packages/core/src/types/login.ts, apps/app/..., apps/web/src/...
소셜 로그인 메시지 키를 WEB_REQ_*, APP_RES_* 명칭으로 변경하고 기존 메시지 값은 유지했습니다.
앱 버전 기반 브릿지 게이트
packages/core/src/consts/appVersion.ts, apps/web/src/utils/appVersion.ts, apps/web/src/utils/webBridge.ts, apps/web/src/hooks/useImagePicker.ts
UA에서 앱 버전을 추출·비교하고, 최소 버전을 충족하지 못한 브릿지 메시지를 차단하며 postMessage 결과를 boolean으로 반환합니다. 이미지 선택 요청은 전송 실패 시 pending 상태를 정리합니다.
웹뷰 환경 연동 및 문서화
apps/web/src/app/layout.tsx, apps/web/src/app/mypage/..., CLAUDE.md
공통 WebView 판별 유틸을 사용하고 앱 버전 유틸 경로를 통합했으며 브릿지 계약 및 pending 정리 규칙을 문서화했습니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WebClient
  participant WebBridge
  participant AppVersion
  participant BridgeGate
  participant NativeApp
  WebClient->>WebBridge: postMessage(message)
  WebBridge->>BridgeGate: read minAppVersion
  WebBridge->>AppVersion: getAppVersion()
  AppVersion-->>WebBridge: current app version
  WebBridge->>NativeApp: postMessage when supported
  WebBridge-->>WebClient: return true or false
Loading

Possibly related PRs

  • TeamPiKi/client#328: 소셜 로그인 WebView-네이티브 메시지 수신 및 가드 처리 영역에서 연결됩니다.

Suggested labels: WEB

Suggested reviewers: kanghaeun, soyeong0115

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 브릿지 메시지에 앱 버전 게이팅을 도입한 핵심 변경을 간결하게 잘 요약합니다.
Linked Issues check ✅ Passed 앱 버전 판별, 브릿지 전송 전 게이팅, 실패 시 대기 상태 정리, 규칙 문서화까지 직접 이슈 목표를 충족합니다.
Out of Scope Changes check ✅ Passed 소셜 로그인 키 정리, 공통 앱 버전 유틸 정리, 브릿지 가드 문서화 등은 모두 게이팅 작업과 직접 연관됩니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/370-app-web-version

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@iOdiO89

iOdiO89 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/src/app/login/_components/LoginButtons.tsx (1)

73-81: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

브릿지 전송 실패 시 네이티브 로그인 대기 상태를 해제하세요.

WebBridge.postMessage는 이제 boolean을 반환하지만, 현재 코드는 반환값을 무시하고 항상 true를 반환합니다. 앱 버전 게이트가 요청을 차단하면 nativePendingProvider가 남아 로그인 버튼이 계속 비활성화되고 웹 로그인 fallback도 실행되지 않습니다.

isSentfalse이면 setNativePendingProvider(null)false를 반환하도록 수정하세요.

수정 예시
     setNativePendingProvider(provider);
-    WebBridge.postMessage({
+    const isSent = WebBridge.postMessage({
       type: WEBBRIDGE_MESSAGE_TYPE.WEB_REQ_SOCIAL_LOGIN,
       payload: { provider },
     });
-    return true;
+    if (!isSent) {
+      setNativePendingProvider(null);
+      return false;
+    }
+    return true;

As per coding guidelines, postMessage 반환값을 확인하고 차단 시 pending 상태를 정리해야 합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/app/login/_components/LoginButtons.tsx` around lines 73 - 81,
Update postNativeMessage to capture the boolean returned by
WebBridge.postMessage; when it is false, clear the pending provider with
setNativePendingProvider(null) and return false, while preserving the existing
true return for successfully sent requests.

Source: Coding guidelines

🧹 Nitpick comments (1)
apps/web/src/utils/webBridge.ts (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

타입 전용 import를 분리하세요.

WebBridgeMessageT는 런타임 값으로 사용되지 않습니다. 저장소 규칙대로 import type으로 분리하세요.

수정 예시
-import { BRIDGE_GATE, WEBVIEW_UA_TOKEN, type WebBridgeMessageT } from '`@piki/core`';
+import { BRIDGE_GATE, WEBVIEW_UA_TOKEN } from '`@piki/core`';
+import type { WebBridgeMessageT } from '`@piki/core`';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/utils/webBridge.ts` at line 1, Update the import in webBridge.ts
to separate WebBridgeMessageT into a type-only import, while keeping BRIDGE_GATE
and WEBVIEW_UA_TOKEN in the regular runtime import from `@piki/core`.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/web/src/app/login/_components/LoginButtons.tsx`:
- Around line 73-81: Update postNativeMessage to capture the boolean returned by
WebBridge.postMessage; when it is false, clear the pending provider with
setNativePendingProvider(null) and return false, while preserving the existing
true return for successfully sent requests.

---

Nitpick comments:
In `@apps/web/src/utils/webBridge.ts`:
- Line 1: Update the import in webBridge.ts to separate WebBridgeMessageT into a
type-only import, while keeping BRIDGE_GATE and WEBVIEW_UA_TOKEN in the regular
runtime import from `@piki/core`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3392ab3f-eb95-4ae4-976c-c9d299e3834b

📥 Commits

Reviewing files that changed from the base of the PR and between 389f046 and 1901666.

📒 Files selected for processing (15)
  • CLAUDE.md
  • apps/app/app/index.tsx
  • apps/app/hooks/useSocialLogin.ts
  • apps/web/src/app/layout.tsx
  • apps/web/src/app/login/_components/LoginButtons.tsx
  • apps/web/src/app/mypage/_components/AppVersionFooter.tsx
  • apps/web/src/app/mypage/_utils/appVersion.ts
  • apps/web/src/hooks/useImagePicker.ts
  • apps/web/src/hooks/useNativeLoginResult.ts
  • apps/web/src/utils/appVersion.ts
  • apps/web/src/utils/webBridge.ts
  • packages/core/src/consts/appVersion.ts
  • packages/core/src/consts/webBridge.ts
  • packages/core/src/index.ts
  • packages/core/src/types/login.ts
💤 Files with no reviewable changes (1)
  • apps/web/src/app/mypage/_utils/appVersion.ts

@iOdiO89
iOdiO89 merged commit 53ed8f4 into dev Jul 27, 2026
7 checks passed
@iOdiO89
iOdiO89 deleted the fix/370-app-web-version branch July 27, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APP Good for newcomers fix Something isn't working refactor Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 앱/웹 버전 불일치로 인한 에러 대응

1 participant