Skip to content

feat(logs): add params column for image request data - #1255

Merged
steebchen merged 4 commits into
mainfrom
image-request-params
Nov 27, 2025
Merged

steebchen merged 4 commits into
mainfrom
image-request-params

Conversation

@steebchen

@steebchen steebchen commented Nov 26, 2025

Copy link
Copy Markdown
Member

Add a params JSON column to the log schema to track additional request parameters like image_config (aspect_ratio and image_size). The column stores {} when no image config is specified.

Changes

  • Added params JSON column to log schema
  • Updated createLogEntry function to populate params with image config data
  • Updated all 10 log creation calls in gateway to pass image_config parameter

Testing

  • Build successful
  • All tests pass
  • Code formatted with pnpm format

Summary by CodeRabbit

  • New Features

    • Dashboard log view now shows an "Additional Parameters" section to display extra log details (including nested values).
  • Chores

    • Logs now include image configuration details (aspect ratio and size) in stored entries.
    • Database schema updated to persist the new log parameters.
    • Client now omits default image settings when sending image configuration, reducing redundant data.

✏️ Tip: You can customize this high-level summary in your review settings.

steebchen and others added 2 commits November 27, 2025 00:11
Add a params JSON column to the log schema to track additional request
parameters like image_config (aspect_ratio and image_size). The params
field will be {} if no image config is specified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Propagates optional image configuration through chat logging: createLogEntry gains an imageConfig parameter, call sites in the gateway pass image_config, the log table gets a new params JSON column, and the UI displays log.params as "Additional Parameters".

Changes

Cohort / File(s) Change Summary
Chat logging propagation
apps/gateway/src/chat/chat.ts
Propagates image_config through multiple createLogEntry call sites and related logging paths so image configuration is included in log payloads.
Log entry function
apps/gateway/src/chat/tools/create-log-entry.ts
Adds optional imageConfig?: { aspect_ratio?: string; image_size?: string } parameter and returns a new params property set to { image_config: imageConfig } when present, otherwise null.
Database schema
packages/db/src/schema.ts
Adds optional params JSON column to the log table schema with nested { image_config?: { aspect_ratio?: string; image_size?: string } } typing.
Database migration
packages/db/migrations/1764175966_dear_silvermane.sql
Adds a new params JSON column to the log table in the migration.
Migration metadata
packages/db/migrations/meta/_journal.json
Appends a new journal entry for migration 1764175966_dear_silvermane (idx 73).
UI: log display
apps/ui/src/components/dashboard/log-card.tsx
Renders log.params as an "Additional Parameters" section with a recursive renderer that skips null/undefined and formats nested objects and arrays.
Playground client
apps/playground/src/components/playground/chat-page-client.tsx
Sends image_config only when fields deviate from defaults (omit default aspect_ratio "auto" and image_size "1K").

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Dashboard UI
  participant Playground as Playground Client
  participant Gateway as Gateway Chat
  participant Logger as createLogEntry
  participant DB as Log DB

  UI->>Playground: user sets image prefs (optional)
  Playground->>Gateway: Chat request (may include image_config)
  Gateway->>Logger: build log entry (..., imageConfig)
  Logger-->>Gateway: log entry (includes params.image_config)
  Gateway->>DB: insert log row (params JSON)
  DB-->>Gateway: insert result
  Gateway-->>Playground: response
  Playground->>UI: display response
  UI->>DB: query log (reads params)
  DB-->>UI: returns log with params
  UI-->>UI: render "Additional Parameters"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing attention:
    • All createLogEntry call sites in apps/gateway/src/chat/chat.ts for correct parameter ordering and values.
    • Migration vs. schema alignment (params nullability and JSON shape).
    • UI rendering in apps/ui/src/components/dashboard/log-card.tsx to ensure safe handling of unexpected or large nested params.

Possibly related PRs

Suggested labels

auto-merge

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a params column to store image request data (specifically image_config with aspect_ratio and image_size).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch image-request-params

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57a5d5b and 9fe57a8.

📒 Files selected for processing (2)
  • apps/playground/src/components/playground/chat-page-client.tsx (1 hunks)
  • apps/ui/src/components/dashboard/log-card.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Always use top-level import, never use require or dynamic imports
No unnecessary code comments

Files:

  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/ui/src/components/dashboard/log-card.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use cookies for user-settings which are not saved in the database to ensure SSR works

**/*.{ts,tsx,js,jsx}: Always use tabs for indentation
No unnecessary code comments

Files:

  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/ui/src/components/dashboard/log-card.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use Drizzle ORM with latest object syntax for database operations
For database reads: Use db().query.<table>.findMany() or db().query.<table>.findFirst()

**/*.{ts,tsx}: Never use any or as any unless absolutely necessary in TypeScript code
Always use top-level import, never use require or dynamic imports
Use cookies for user-settings which are not saved in the database to ensure SSR works
Use Drizzle ORM with latest object syntax for database operations
For database reads: Use db().query.<table>.findMany() or db().query.<table>.findFirst()

Files:

  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/ui/src/components/dashboard/log-card.tsx
apps/{ui,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use next/link for links and next/navigation's router for programmatic navigation

Files:

  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/ui/src/components/dashboard/log-card.tsx
apps/{ui,playground}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use next/link for links and next/navigation's router for programmatic navigation in Next.js

Files:

  • apps/playground/src/components/playground/chat-page-client.tsx
  • apps/ui/src/components/dashboard/log-card.tsx
apps/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Next.js App Router with React Server Components for frontend development

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
🧬 Code graph analysis (1)
apps/ui/src/components/dashboard/log-card.tsx (1)
packages/db/src/schema.ts (1)
  • log (378-486)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test / run
  • GitHub Check: build / run
  • GitHub Check: generate / run
  • GitHub Check: lint / run
  • GitHub Check: autofix
  • GitHub Check: e2e-shards (1)
  • GitHub Check: e2e-shards (5)
  • GitHub Check: e2e-shards (2)
  • GitHub Check: e2e-shards (3)
  • GitHub Check: e2e-shards (4)
🔇 Additional comments (2)
apps/playground/src/components/playground/chat-page-client.tsx (1)

225-228: LGTM! Clean refactoring to avoid default-value noise.

The conditional property inclusion correctly ensures that only non-default values are sent in image_config. The logic handles all edge cases properly—when both values are default, imageConfig becomes undefined and won't be included in the request body (line 242), and when only one value is non-default, only that field is included. This aligns perfectly with the PR objective of reducing noise in logs and stored params.

apps/ui/src/components/dashboard/log-card.tsx (1)

634-641: log.params section wiring looks good.

The “Additional Parameters” block is correctly guarded to skip empty {} params and reuses renderParams(log.params) in a simple grid layout; this aligns with the new params JSON shape from the schema and should behave as intended.


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 and usage tips.

Add recursive rendering of params object in log card UI. Display
"Additional Parameters" section below "Model Parameters" with
nicely formatted fields for each value in the object.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abeb54e and 57a5d5b.

📒 Files selected for processing (1)
  • apps/ui/src/components/dashboard/log-card.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Always use top-level import, never use require or dynamic imports
No unnecessary code comments

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use cookies for user-settings which are not saved in the database to ensure SSR works

**/*.{ts,tsx,js,jsx}: Always use tabs for indentation
No unnecessary code comments

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use Drizzle ORM with latest object syntax for database operations
For database reads: Use db().query.<table>.findMany() or db().query.<table>.findFirst()

**/*.{ts,tsx}: Never use any or as any unless absolutely necessary in TypeScript code
Always use top-level import, never use require or dynamic imports
Use cookies for user-settings which are not saved in the database to ensure SSR works
Use Drizzle ORM with latest object syntax for database operations
For database reads: Use db().query.<table>.findMany() or db().query.<table>.findFirst()

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
apps/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Next.js App Router with React Server Components for frontend development

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
apps/{ui,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use next/link for links and next/navigation's router for programmatic navigation

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
apps/{ui,playground}/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use next/link for links and next/navigation's router for programmatic navigation in Next.js

Files:

  • apps/ui/src/components/dashboard/log-card.tsx
🧬 Code graph analysis (1)
apps/ui/src/components/dashboard/log-card.tsx (1)
packages/db/src/schema.ts (1)
  • log (378-486)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: build / run
  • GitHub Check: test / run
  • GitHub Check: lint / run
  • GitHub Check: generate / run
  • GitHub Check: e2e-shards (5)
  • GitHub Check: e2e-shards (2)
  • GitHub Check: e2e-shards (1)
  • GitHub Check: e2e-shards (3)
  • GitHub Check: e2e-shards (4)
  • GitHub Check: autofix
🔇 Additional comments (1)
apps/ui/src/components/dashboard/log-card.tsx (1)

639-646: LGTM!

The "Additional Parameters" section is well-implemented with proper conditional rendering and consistent styling that matches other detail sections.

Comment on lines +50 to +82
// Recursively render params object
const renderParams = (
obj: Record<string, any>,
depth = 0,
): React.ReactNode => {
return Object.entries(obj).map(([key, value]) => {
const formattedKey = key
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());

if (value === null || value === undefined) {
return null;
}

if (typeof value === "object" && !Array.isArray(value)) {
return (
<div key={key} className="contents">
<div className="text-muted-foreground col-span-2 font-medium mt-2 first:mt-0">
{formattedKey}
</div>
{renderParams(value, depth + 1)}
</div>
);
}

return (
<div key={key} className="contents">
<div className="text-muted-foreground">{formattedKey}</div>
<div>{Array.isArray(value) ? value.join(", ") : String(value)}</div>
</div>
);
});
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Replace any type and remove unused parameter.

Two issues with this function:

  1. The use of Record<string, any> violates the coding guideline that prohibits any types unless absolutely necessary. Replace with Record<string, unknown> for better type safety.

  2. The depth parameter is declared but never used in the function logic.

Apply this diff:

-	const renderParams = (
-		obj: Record<string, any>,
-		depth = 0,
-	): React.ReactNode => {
+	const renderParams = (obj: Record<string, unknown>): React.ReactNode => {
 		return Object.entries(obj).map(([key, value]) => {
 			const formattedKey = key
 				.replace(/_/g, " ")
 				.replace(/\b\w/g, (l) => l.toUpperCase());

 			if (value === null || value === undefined) {
 				return null;
 			}

 			if (typeof value === "object" && !Array.isArray(value)) {
 				return (
 					<div key={key} className="contents">
 						<div className="text-muted-foreground col-span-2 font-medium mt-2 first:mt-0">
 							{formattedKey}
 						</div>
-						{renderParams(value, depth + 1)}
+						{renderParams(value as Record<string, unknown>)}
 					</div>
 				);
 			}

 			return (
 				<div key={key} className="contents">
 					<div className="text-muted-foreground">{formattedKey}</div>
 					<div>{Array.isArray(value) ? value.join(", ") : String(value)}</div>
 				</div>
 			);
 		});
 	};

As per coding guidelines, avoid any types in TypeScript code.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Recursively render params object
const renderParams = (
obj: Record<string, any>,
depth = 0,
): React.ReactNode => {
return Object.entries(obj).map(([key, value]) => {
const formattedKey = key
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());
if (value === null || value === undefined) {
return null;
}
if (typeof value === "object" && !Array.isArray(value)) {
return (
<div key={key} className="contents">
<div className="text-muted-foreground col-span-2 font-medium mt-2 first:mt-0">
{formattedKey}
</div>
{renderParams(value, depth + 1)}
</div>
);
}
return (
<div key={key} className="contents">
<div className="text-muted-foreground">{formattedKey}</div>
<div>{Array.isArray(value) ? value.join(", ") : String(value)}</div>
</div>
);
});
};
// Recursively render params object
const renderParams = (obj: Record<string, unknown>): React.ReactNode => {
return Object.entries(obj).map(([key, value]) => {
const formattedKey = key
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());
if (value === null || value === undefined) {
return null;
}
if (typeof value === "object" && !Array.isArray(value)) {
return (
<div key={key} className="contents">
<div className="text-muted-foreground col-span-2 font-medium mt-2 first:mt-0">
{formattedKey}
</div>
{renderParams(value as Record<string, unknown>)}
</div>
);
}
return (
<div key={key} className="contents">
<div className="text-muted-foreground">{formattedKey}</div>
<div>{Array.isArray(value) ? value.join(", ") : String(value)}</div>
</div>
);
});
};
🤖 Prompt for AI Agents
In apps/ui/src/components/dashboard/log-card.tsx around lines 50 to 82, replace
the permissive any type and remove the unused depth parameter: change the
function signature to accept obj: Record<string, unknown> (drop the depth
parameter), update runtime checks to guard against null (e.g. typeof value ===
"object" && value !== null && !Array.isArray(value)) and when recursing cast the
value to Record<string, unknown> (or narrow it) before passing to renderParams;
ensure return types stay the same and remove any references to depth.

- Flatten nested objects in params to show only leaf values
- Don't include aspect_ratio when set to "auto"
- Don't include image_size when set to default "1K"
- Use conditional spread to only include non-default values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@steebchen
steebchen enabled auto-merge November 27, 2025 10:58
@steebchen
steebchen added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit 16d9d03 Nov 27, 2025
13 of 14 checks passed
@steebchen
steebchen deleted the image-request-params branch November 27, 2025 11:05
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.

1 participant