Skip to content

Refactor/chat context - #12

Open
masonomara wants to merge 72 commits into
mainfrom
refactor/chat-context
Open

Refactor/chat context#12
masonomara wants to merge 72 commits into
mainfrom
refactor/chat-context

Conversation

@masonomara

Copy link
Copy Markdown
Owner

No description provided.

- Add NewEnergyChart with smooth Catmull-Rom curves and time-aligned data positioning
- Add NewTimeContextToggle for 1day/3day/1week/1month/3month/1year views
- Implement time bucket aggregation with placeholder points for natural curves
- Add precise time label positioning with 23-notch hourly grid system
- Update data service with context-aware filtering and alignment logic
- Integrate new chart components into Home screen navigation
- Extract Chat functionality into dedicated Chat screen component
- Clean up Home.tsx by removing chat-related code (570→160 lines)
- Add useChatInputFocus hook for input focus management
- Configure Chat as formSheet modal in MainNavigator
- Maintain Home as background with energy chart and time context
- Remove unused imports and navigation listeners from Home
…ameters

- Add ChartDisplayContext with 29 exported parameters for chart display management
- Integrate time range shortcuts (1day, 3day, 1week, 1month, 3month, 1year)
- Implement smart date range calculations with timezone support
- Add formatted labels for ChartHeader (headerTopLabel, headerBottomLabel)
- Include special handling for 'today' view with different display options
- Fix month abbreviations to show 'Sept' instead of 'Sep'
- Update TimeDisplayToggle to use context with backward compatibility
- Modify ChartHeader to use context-provided formatted labels
- Wrap Home screen with ChartDisplayContextProvider

Provides centralized chart display logic with automatic dateStart/dateEnd
calculation from shortcuts, scalable for custom date ranges.
…edundant code

- Fix race conditions between TimeContext and ChartDisplayContext intervals
- Eliminate 60+ lines of duplicate astronomical calculation logic
- Create shared dateFormatters utility for consistent month formatting
- Implement reactive dependency pattern using timeInfo timestamp
- Consolidate formatMonthDay logic into reusable utility
- Simplify TimeDisplayToggle backward compatibility logic
- Add comprehensive refactoring documentation and validation report

Architecture improvement: Single source of truth pattern with TimeContext managing intervals and ChartDisplayContext reacting to changes.
…docs

- Complete modular architecture implementation
- Remove temporary ChartHeader-analysis.md file
- Consolidate chart display and time context improvements
- Maintain 86% code reduction in Home.tsx
- Preserve all functionality with cleaner separation of concerns
- Cut 402 to 225 lines by eliminating debug code and verbosity
- Remove console logs and debug styling (pink/red/lightblue backgrounds)
- Simplify category icon mapping and tool list rendering
- Consolidate StyleSheet definitions and remove redundant patterns
- Fix TypeScript errors with proper typing for toolsByCategory and icons
- Add missing matchedTriggers property to DetectedToolSuggestion
- Cut ChatContext from 330 to 205 lines by eliminating verbose patterns
- Fix ChatToolbar formatting and type annotations
- Maintain all functionality while improving readability and maintainability
…hooks and contexts

- Extract TideContext from ChatContext for tide-specific state management
- Add useChatMessaging hook to bridge all contexts for message handling
- Simplify ChatContext to focus on UI state (input, tools, toolbar)
- Create tideTypes for shared type definitions across contexts
- Remove agentCommandUtils in favor of centralized bridge pattern
- Update ChatInput to use new hook architecture for cleaner separation
- Implement message persistence and tide state management
- Streamline TimeContext with reduced complexity
- Add comprehensive documentation of implementation status

@gemini-code-assist gemini-code-assist 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.

Summary of Changes

Hello @masonomara, 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 delivers a substantial architectural overhaul, primarily focusing on enhancing the application's chat and data visualization capabilities. It introduces a more modular chat system tied to specific 'tides' (conversations), simplifies core data models for improved manageability, and implements a flexible new charting system for better data insights. These changes are supported by detailed design documents and a streamlined server environment configuration.

Highlights

  • Core Architecture Refactor: The application's core architecture has undergone a significant refactor, particularly in how chat interactions and data visualizations are managed. This includes a major overhaul of the ChatContext and the introduction of a new TideContext to centralize conversation management.
  • Simplified Data Models: The Tide data model has been streamlined by removing complex hierarchical properties and flow_type, indicating a shift towards a flatter, more manageable data structure. Corresponding changes are reflected across agent and MCP types.
  • Enhanced Data Visualization: The energy charting system has been completely revamped with a new NewEnergyChart component and a dedicated ChartDisplayContext. This provides flexible time range selections (1D, 3D, 1W, 1M, 3M, 1Y) and improved data presentation.
  • Streamlined Chat Experience: The chat input (ChatInput.tsx) has been heavily refactored to be more modular, leveraging new hooks and a dedicated ChatToolbar for tool suggestions and lists. This aims to provide a more intuitive and responsive conversational interface.
  • Consolidated Environment Setup: The dynamic server environment selection has been removed, and the MCP server URL is now hardcoded to a specific development environment (tides-006.mpazbot.workers.dev). This simplifies deployment and configuration for the current development phase.
  • New Documentation & Planning: Several new Markdown documents have been added to outline strategic architectural changes, refactor plans, and design decisions, providing clear guidance for future development and understanding of the system's evolution.
  • Localization Integration: The react-native-localize library has been integrated into the mobile application, laying the groundwork for future internationalization and improved user experience across different locales.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a comprehensive refactor of the Tides mobile app's architecture, focusing on the ChatContext and energy chart components. It aims to improve modularity, maintainability, and performance by separating concerns into distinct contexts and services. The changes include the addition of new components, refactoring existing ones, and updating dependencies. The review focuses on identifying potential issues related to correctness and maintainability, with a specific emphasis on high and critical severity issues.

Comment thread apps/mobile/App.tsx
<NavigationContainer>
<RootNavigator />
</NavigationContainer>
</ChatProvider>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The ServerEnvironmentProvider is no longer needed and should be removed as part of the context refactoring.

      <AuthProvider>

Comment on lines +166 to 169
if (lowerQuestion.includes(tide.name.toLowerCase())) {
return tide.id;
}
}

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 flow_type property is no longer present in the TideInfo interface, so this check is no longer needed and can be simplified to only check the name.

      for (const tide of tides) {
        if (lowerQuestion.includes(tide.name.toLowerCase())) {

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