Skip to content

Conversation

@leoisadev8
Copy link
Member

Summary

  • Remove unused imports, variables, and dead code across server and web packages
  • Standardize import ordering (external → internal) and separate type-only imports
  • Convert Type[] to Array<Type> syntax consistently per linter preference
  • Fix variable shadowing, remove unnecessary optional chaining, and clean up eslint-disable comments

Scope

  • web: 47 files (components, hooks, lib, routes, stores, UI primitives)
  • server: 3 files (convex functions)

Changes

Dead Code Removal

  • apps/server/convex/lib/redisRest.ts: Remove unused _executeCommand function
  • apps/server/convex/users.ts: Remove unused _userDoc validator
  • apps/server/convex/files.ts: Remove unused type imports

Lint Fixes

  • Import ordering: external packages before internal imports
  • Type-only imports separated (import type { Foo })
  • Array syntax: Type[]Array<Type>
  • Variable shadowing: openisDialogOpen, percentageclickPercentage, indexpartIndex, errorparsedError
  • Removed unnecessary ?. optional chaining where values are guaranteed
  • Removed eslint-disable comments where rules no longer trigger
  • ESLint config: added ignores for .output/, dist/, .vinxi/, *.config.js

Bug Fixes (minor)

  • SidebarProvider: Fixed stale conditional initialization in useEffect
  • PromptInputSpeechButton: Fixed fallback to webkitSpeechRecognition (was redundant after type guard)

Testing

  • bun check-types passes
  • bun check (oxlint) passes
  • vite build succeeds

- Remove unused imports, variables, and functions (redisRest._executeCommand, users._userDoc, files unused types)
- Standardize import ordering: external packages first, then internal
- Separate type-only imports from value imports
- Convert Type[] to Array<Type> syntax consistently
- Add eslint ignores for build output directories
- Remove unnecessary eslint-disable comments
- Remove redundant optional chaining where values are guaranteed
- Fix variable shadowing (open→isDialogOpen, percentage→clickPercentage, index→partIndex, error→parsedError)
- Fix SidebarProvider useEffect to avoid stale conditional initialization
- Use function property syntax for interface methods (SpeechRecognition)
@railway-app railway-app bot temporarily deployed to OpenChat / openchat-pr-553 January 23, 2026 23:07 Destroyed
@railway-app
Copy link

railway-app bot commented Jan 23, 2026

🚅 Deployed to the openchat-pr-553 environment in OpenChat

Service Status Web Updated (UTC)
web 🕒 Building (View Logs) Web Jan 23, 2026 at 11:13 pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 23, 2026

Greptile Summary

This PR cleans up lint warnings by standardizing import ordering, converting Type[] to Array<Type> syntax, fixing variable shadowing, and removing unused code. However, two critical bugs were introduced during cleanup.

Critical Issues Found:

  • prompt-input.tsx: Broke Safari speech recognition by removing webkitSpeechRecognition fallback
  • sidebar.tsx: Changed initialization logic now overrides persisted user preferences on every mount instead of only when undefined

Changes Made:

  • Dead code removal: Removed unused _executeCommand function, _userDoc validator, and unused type imports from server files
  • Import standardization: External packages before internal imports, type-only imports separated
  • Array syntax: Converted Type[] to Array<Type> consistently per linter preference
  • Variable shadowing fixes: Renamed openisDialogOpen, percentageclickPercentage, indexpartIndex, errorparsedError
  • Removed unnecessary optional chaining where values are guaranteed non-null
  • ESLint config: Added ignores for .output/, dist/, .vinxi/, *.config.js

Recommendations:

  1. Fix the speech recognition fallback immediately
  2. Revert the sidebar initialization logic to preserve user state
  3. Consider keeping the explicit !isStreaming check in chat-interface for clarity

Confidence Score: 1/5

  • This PR introduces critical runtime bugs that break core functionality
  • Two critical bugs were introduced: (1) Speech recognition completely broken in Safari/older browsers due to removed webkitSpeechRecognition fallback, and (2) User sidebar preferences are now reset on every mount, breaking state persistence. While most lint cleanup is safe, these bugs severely impact user experience.
  • apps/web/src/components/ai-elements/prompt-input.tsx and apps/web/src/components/ui/sidebar.tsx must be fixed before merging

Important Files Changed

Filename Overview
apps/web/src/components/ai-elements/prompt-input.tsx Import reordering and array syntax updates. CRITICAL BUG: broke webkitSpeechRecognition fallback for Safari
apps/web/src/components/ui/sidebar.tsx Import reordering. CRITICAL BUG: initialization now overrides persisted user preferences on every mount
apps/web/src/components/chat-interface.tsx Import reordering, variable shadowing fixes, removed unnecessary optional chaining. Minor style issue with redundant condition removal
apps/web/src/stores/model.ts Import reordering, Type[] to Array syntax, renamed models export to defaultModels, improved grouping logic with ??=
apps/web/src/hooks/use-persistent-chat.ts Import reordering, array syntax updates, removed unnecessary optional chaining, variable shadowing fix (error to parsedError)

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Lint as Linter/Formatter
    participant Code as Codebase
    participant Tests as Type Check & Build
    
    Dev->>Lint: Run oxlint + check-types
    Lint->>Code: Identify issues (imports, array syntax, dead code)
    
    Note over Code: Import Reordering
    Code->>Code: Move external imports before internal
    Code->>Code: Separate type-only imports
    
    Note over Code: Syntax Standardization
    Code->>Code: Convert Type[] to Array<Type>
    Code->>Code: Fix variable shadowing
    Code->>Code: Remove unnecessary optional chaining
    
    Note over Code: Dead Code Removal
    Code->>Code: Remove unused _executeCommand function
    Code->>Code: Remove unused _userDoc validator
    Code->>Code: Remove unused type imports
    
    Note over Code: Bug Introduced ⚠️
    Code->>Code: Remove webkitSpeechRecognition fallback
    Code->>Code: Change sidebar initialization logic
    
    Dev->>Tests: Run bun check-types && bun check
    Tests-->>Dev: ✅ All checks pass
    
    Note over Tests,Dev: Type checks pass, but runtime bugs<br/>not caught by static analysis
    
    Dev->>Code: Create PR
    Code->>Tests: Vite build succeeds
    
    Note right of Code: Speech recognition broken<br/>in Safari browsers
    Note right of Code: User preferences reset<br/>on every mount
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

50 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

("SpeechRecognition" in window || "webkitSpeechRecognition" in window)
) {
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const SpeechRecognition = window.SpeechRecognition;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Broke webkitSpeechRecognition fallback. The conditional at line 1120 checks for both SpeechRecognition OR webkitSpeechRecognition, but this line assumes window.SpeechRecognition always exists, breaking Safari/older browsers.

Suggested change
const SpeechRecognition = window.SpeechRecognition;
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;

wasStreamingRef.current = true;
hasAutoCollapsedRef.current = false;
} else if (
wasStreamingRef.current &&
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Removed !isStreaming check creates redundant condition. Line 360-365 already handles the isStreaming === true case, so the else-if at line 366 will only execute when isStreaming === false. The explicit !isStreaming check was not redundant—it made the logic clearer.

Suggested change
wasStreamingRef.current &&
} else if (
wasStreamingRef.current &&
!isStreaming &&
hasTextContent &&
!hasAutoCollapsedRef.current
) {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines 54 to 55
setSidebarOpen(defaultOpen);
setSidebarCollapsed(defaultCollapsed);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Changed initialization to always override store state on every render. The old code only set defaults when store was undefined, preserving user's saved state. The new code resets to defaults every time the component mounts, ignoring persisted user preferences.

Suggested change
setSidebarOpen(defaultOpen);
setSidebarCollapsed(defaultCollapsed);
if (sidebarOpen === undefined) {
setSidebarOpen(defaultOpen);
}
if (sidebarCollapsed === undefined) {
setSidebarCollapsed(defaultCollapsed);
}

@railway-app railway-app bot temporarily deployed to OpenChat / openchat-pr-553 January 23, 2026 23:13 Destroyed
@leoisadev8 leoisadev8 merged commit 0641f02 into main Jan 23, 2026
2 of 3 checks passed
@leoisadev8 leoisadev8 deleted the chore/lint-cleanup branch January 23, 2026 23:13
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.

2 participants