refactor: generate_title から app_name 生成を削除し session ID ベースに統一#84
refactor: generate_title から app_name 生成を削除し session ID ベースに統一#84mats16 wants to merge 4 commits into
Conversation
…ame handling - Updated the title generation logic to return both the generated title and a slugified app name. - Introduced a new `slugifyTitle` function to convert titles into a Databricks Apps-compatible format, ensuring they meet specific criteria (lowercase, hyphens, max length). - Modified the API response structure to include the app name alongside the title. - Updated related tests to validate the new functionality and ensure correct behavior across the application. These changes improve the user experience by providing a more consistent and user-friendly app name format derived from the session title.
- Refactored the title generation logic to return only the generated title, removing the app name from the response. - Eliminated the `slugifyTitle` function and related tests, streamlining the title handling process. - Updated API responses and service methods to reflect the changes, ensuring consistency across the application. - Adjusted tests to validate the new title generation behavior without app name handling. These changes enhance the clarity of the title generation process and reduce unnecessary complexity in the codebase.
コードレビューPR の目的(generate_title からの app_name 生成削除、MCP ツールから CLI コマンドへの移行)は理解できますが、いくつか気になる点があります。 セキュリティ:サンドボックス無効化最も懸念される変更です。createSession と sendMessageToSession の両方でサンドボックスが無効化されています(sandbox.enabled: true から false へ)。 これにより AI エージェントが制限なしに任意のコマンドを実行できる状態になります。
unknown フォールバックの問題apps/api/src/utils/system-prompt.helper.ts で appsOutcome.name のフォールバックとして unknown を使用しています。 appsOutcome.name が未設定の場合、AI エージェントには 提案:
コードの可読性title.ts のリネーム:変数名を title から result に変更していますが、result は汎用的すぎます。generatedTitle などの方が意図が明確です。 title.service.ts の簡素化:2行を1行にまとめていますが、機能的には同等で、元の2行の方が読みやすかったです。 良い点
まとめ
サンドボックスの無効化について明確な説明と対応方針を示していただければ、他の点は軽微です。DRAFT のまま保留されているのも、ローカルテスト未完了を示していますね。準備ができたらまた確認します。 |
- Updated the sandbox configuration in the createSession and sendMessageToSession functions to enable sandboxing. - Added options for auto-allowing bash commands and specifying allowed network domains, enhancing the flexibility and security of session operations. - These changes improve the functionality of session handling by allowing more robust execution environments for user interactions.
PR レビュー全体的には、title 生成と app_name 生成の責務を明確に分離する良いリファクタリングです。CLI ベースの指示へ移行するアーキテクチャ判断も理解できます。いくつか気になる点を挙げます。 要確認:mcp__apps__ がデッドコードになる可能性 apps/web/src/components/main/MainArea.tsx にて mcp__apps__ 系が disallowed_tools に残っています。createDbAppsMcpServer を削除した結果、apps プレフィックスの MCP サーバーはもう存在しないはずです。この disallow 指定は実質的にデッドコードになっていないか確認が必要です。system prompt 側では mcp__dbapps__ 系という別プレフィックスが使われていたので、意図的に別物として扱っていたなら問題ないですが、将来の混乱を招く可能性があります。 sendMessageToSession での unknown フォールバック apps/api/src/utils/system-prompt.helper.ts で appsOutcome.name ?? 'unknown' というフォールバックが使われています。createSession 側では outcomes に必ず name を設定するロジックがあるため、DB から読んだ outcomes には通常 name が設定されています。ただし理論上 name が未設定のまま unknown になる経路が残ります。Claude へのプロンプトで unknown というアプリ名になると不適切です。app-unknown のような形式や明示的なエラー処理の方が望ましいかもしれません。 apps/api/src/routes/title.ts の変数名 generateTitle の戻り値を result にリネームしていますが、title の方が意図が明確でした。return reply.send({ title: result }) と書くより、const title = await ... として return reply.send({ title }) の方がシンプルです。 title.service.ts の可読性 return (rawTitle ? cleanTitle(rawTitle) : FALLBACK_TITLE) || FALLBACK_TITLE; は機能的には元の2行と等価ですが、cleanTitle が空文字を返す可能性があるため二重チェックが必要という意図が、元の2行の方が伝わりやすかったです。 良い点
補足:3コミット目のサンドボックス変更について コミットメッセージに Enable sandbox features for session creation and messaging とありますが、今回の diff 上でその変更内容が明示的に確認できませんでした。サンドボックスの有効化はセキュリティ上重要な変更なので、意図した変更が正しく含まれているか確認をお勧めします。 |
- Updated the title generation logic to directly return the generated title variable, improving code clarity. - Refactored the title service to ensure consistent fallback handling for title generation, enhancing robustness. - These changes streamline the title generation process and improve maintainability of the codebase.
コードレビュー全体的に、MCP サーバー依存を排除して CLI ベースの操作に統一するというリファクタリングの方向性は明確で、コードが簡潔になっています。いくつか気になった点を挙げます。 ✅ 良い点
- const systemPromptConfig = buildSystemPromptConfig(session_context.outcomes);
+ const systemPromptConfig = buildSystemPromptConfig(outcomes);
フォールバックの保持 - name: `app-${sessionId.getSuffix()}`,
+ name: outcome.name || `app-${sessionId.getSuffix()}`,既存の
|
Summary
generate_titleAPI からapp_name(slugify したタイトル)を返す機能を削除し、アプリ名を常にapp-{sessionSuffix}形式(session ID から自動生成)に戻す。Changes
GenerateTitleResponseからapp_nameフィールドを削除TitleService.generateTitle()の戻り値を{ title, appName }→stringに簡素化slugifyTitle()関数と関連定数を削除generateTitle()をstring | nullに変更し、appNameの参照を除去session.service.tsの既存フォールバックapp-${sessionId.getSuffix()}が常に使用されるslugifyTitleテストとapp_nameアサーションを削除Test Plan
npm run type-checkpassesnpm run testpasses (500/500)npm run buildsucceedsChecklist
npm run type-checkpassesnpm run lintpassesnpm run buildsucceedsnpm run dev