Skip to content

Session List and Title Management#20

Draft
MrOrz wants to merge 2 commits intomasterfrom
session-list-and-title-10403535399489104791
Draft

Session List and Title Management#20
MrOrz wants to merge 2 commits intomasterfrom
session-list-and-title-10403535399489104791

Conversation

@MrOrz
Copy link
Copy Markdown
Member

@MrOrz MrOrz commented Mar 15, 2026

Implemented database-backed session persistence and management of session titles as requested.

Key changes:

  1. Backend (ADK): Updated adk/cofacts_ai/agent.py to use DatabaseSessionService, which defaults to a local SQLite database but can be configured via DATABASE_URL. Wrapped the agent in the App class. Added necessary database driver dependencies (aiosqlite, asyncpg, aiomysql).
  2. Infrastructure: Updated service.template.yaml to include Cloud SQL instance annotations and environment variables.
  3. Frontend Logic: Updated sessions.functions.ts to allow passing initial state during session creation and added a PATCH-based update function. Defined title as the session state key for titles.
  4. Frontend UX: Updated the landing page to generate a title from the first message. Updated the sidebar to display titles from the session state and allow users to edit them inline.
  5. Tooling: Updated ESLint and Prettier configurations to ignore build/environment artifacts and handle CI/CD templates correctly.

Fixes #15


PR created automatically by Jules for task 10403535399489104791 started by @MrOrz

- Switched backend to use DatabaseSessionService (SQLite locally, Cloud SQL in prod).
- Added database driver dependencies to ADK.
- Updated service.template.yaml for Cloud SQL support.
- Implemented automatic session title generation from the first message.
- Added support for updating session state via PATCH.
- Implemented inline session title editing in the Sidebar.
- Updated ESLint/Prettier configs to handle monorepo environment and template files.

Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's session management capabilities by introducing persistent storage for user sessions and enabling dynamic, user-editable titles. These changes provide a more robust and user-friendly experience, allowing sessions to be saved and easily identified, while also improving the backend's database integration and frontend's interactive elements.

Highlights

  • Backend Session Persistence: Implemented database-backed session persistence using DatabaseSessionService in the ADK backend, configurable via DATABASE_URL and defaulting to SQLite for local development.
  • Infrastructure Updates: Updated service.template.yaml to support Cloud SQL instances and pass the DATABASE_URL environment variable to the backend service.
  • Frontend Session Management: Enhanced frontend logic to allow passing initial state during session creation and introduced a new PATCH-based function (updateSession) for modifying session state, specifically for titles.
  • Improved User Experience: The landing page now automatically generates a session title from the first user message, and the sidebar displays these titles, allowing users to edit them inline.
  • Tooling Configuration: Adjusted ESLint and Prettier configurations to ignore build artifacts and CI/CD templates, improving development workflow.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .prettierignore
    • Added service.template.yaml to ignored files.
  • README.md
    • Adjusted spacing for better readability in the 'This will:' and 'Staging Environment' sections.
  • adk/cofacts_ai/agent.py
    • Imported os, App, and DatabaseSessionService.
    • Initialized DatabaseSessionService using DATABASE_URL or a local SQLite database.
    • Wrapped the ai_writer agent within an App instance, integrating the new session service.
  • adk/pyproject.toml
    • Added new database driver dependencies: aiosqlite, sqlalchemy, asyncpg, and aiomysql.
  • docker-compose.yml
    • Updated port mapping and healthcheck command string literals to use single quotes for consistency.
  • eslint.config.js
    • Configured ESLint to ignore adk/.venv/** and adk/.adk/** directories.
  • package.json
    • Ensured the file ends with a newline character.
  • service.template.yaml
    • Added run.googleapis.com/cloudsql-instances annotation for Cloud SQL integration.
    • Included DATABASE_URL as an environment variable for the backend container.
  • src/components/Sidebar.tsx
    • Imported React hooks (useCallback, useEffect, useState) and useQueryClient.
    • Integrated SESSION_TITLE_KEY, listSessions, and updateSession for session title management.
    • Implemented state for inline editing of session titles (editingSessionId, editTitle).
    • Added handleStartEdit, handleCancelEdit, and handleSaveEdit functions to manage the editing lifecycle.
    • Modified the session list rendering to display an editable input field and an edit button when a session title is being edited.
  • src/components/ui/field.tsx
    • Updated equality check from == to === for uniqueErrors?.length.
  • src/hooks/useChat.ts
    • Removed the type keyword from ChatSessionState import.
  • src/hooks/useSessions.ts
    • Imported SESSION_TITLE_KEY for consistent title handling.
    • Modified getSessionTitle to first check for an explicit title in session state before deriving one from the first user message.
  • src/lib/adk.server.ts
    • Standardized string literal quotes and ensured consistent file endings.
  • src/lib/chatCache.ts
    • Removed redundant ESLint comments related to unnecessary conditions.
    • Simplified the logic for concatenating text in applyEventToState.
  • src/lib/sessions.functions.ts
    • Exported SESSION_TITLE_KEY for global use.
    • Updated createSession to accept an initialState object, allowing initial session data (like titles) to be set upon creation.
    • Introduced updateSession function, enabling PATCH requests to modify existing session state.
  • src/routes/_app/index.tsx
    • Imported SESSION_TITLE_KEY.
    • Modified handleSubmit to generate a session title from the first message and pass it as initialState during session creation.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/claude.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully implements database-backed session persistence and management of session titles. The changes span the backend, frontend, and infrastructure, including updates to use DatabaseSessionService, Cloud SQL integration, and new UI components for title display and editing. The implementation appears solid. I have a couple of minor suggestions regarding code clarity and configuration management to enhance maintainability.

session_service=session_service
)

root_agent = ai_writer
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The root_agent is redefined here after the app object has been created. This is confusing and likely redundant if the application server is configured to use the app object, which encapsulates the agent and session service. To improve clarity and maintainability, please consider removing this line if it's not strictly necessary for a specific execution path. If it is required, a comment explaining its purpose would be very helpful.

run.googleapis.com/container-dependencies: '{"ingress":["backend"]}'
autoscaling.knative.dev/minScale: "0"
autoscaling.knative.dev/maxScale: "3"
run.googleapis.com/cloudsql-instances: industrious-eye-145611:asia-east1:cofacts
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The Cloud SQL instance connection string appears to contain a hardcoded project ID (industrious-eye-145611). Hardcoding project-specific identifiers can make the configuration less portable and harder to manage across different environments (e.g., dev, staging, prod). It's recommended to use a variable that can be substituted during deployment, similar to other variables in this file.

        run.googleapis.com/cloudsql-instances: ${GCP_PROJECT_ID}:asia-east1:cofacts

- Switch ADK backend to DatabaseSessionService (SQLite local, Cloud SQL prod)
- Implement title generation from first message and storage in session state
- Add inline session title editing in the sidebar
- Refactor server functions and error handling to avoid client-side import errors
- Update infrastructure for Cloud SQL connectivity

Co-authored-by: MrOrz <108608+MrOrz@users.noreply.github.com>
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.

左側 session list

1 participant