Skip to content

Feat/clean code#69

Merged
will-lp1 merged 7 commits intomainfrom
feat/clean-code
Aug 21, 2025
Merged

Feat/clean code#69
will-lp1 merged 7 commits intomainfrom
feat/clean-code

Conversation

@will-lp1
Copy link
Owner

@will-lp1 will-lp1 commented Aug 21, 2025

Summary by CodeRabbit

  • New Features

    • Emoji typing with inline suggestions in the editor.
    • Synonym overlay for quick word replacements.
    • Document Actions bar: preview changes, navigate versions, copy to clipboard, and saving indicator.
  • Improvements

    • Consolidated, document-centric workspace across editor, chat, and sidebar.
    • Header/hero buttons route to Documents if signed in, or to login with redirect.
    • Authenticated users can now access the home page without redirection.
    • Smoother version restore, create, and rename flows with clearer feedback.
  • Refactor

    • Removed legacy artifact-based toolbar and actions in favor of streamlined document controls.

…eneral improvements

Streamline document handling and remove unused context

- Removed the `use-document-context` and `use-document-utils` hooks to simplify document management.
- Introduced a unified `use-document` hook to handle document state and actions.
- Updated various components to utilize the new `use-document` hook, ensuring consistent document state management.
- Adjusted document creation and update logic to eliminate reliance on artifact kinds, setting kind to 'text' by default.
- Enhanced synonym overlay functionality in the editor, with its own react component
@coderabbitai
Copy link

coderabbitai bot commented Aug 21, 2025

Warning

Rate limit exceeded

@will-lp1 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0bb2471 and ab487b5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (52)
  • apps/snow-leopard/app/api/document/actions/create.ts (1 hunks)
  • apps/snow-leopard/app/documents/[id]/page.tsx (1 hunks)
  • apps/snow-leopard/app/documents/actions.ts (1 hunks)
  • apps/snow-leopard/app/documents/layout.tsx (3 hunks)
  • apps/snow-leopard/app/documents/page.tsx (1 hunks)
  • apps/snow-leopard/app/layout.tsx (1 hunks)
  • apps/snow-leopard/app/page.tsx (2 hunks)
  • apps/snow-leopard/artifacts/text/client.tsx (0 hunks)
  • apps/snow-leopard/artifacts/text/server.ts (0 hunks)
  • apps/snow-leopard/components/artifact-actions.tsx (0 hunks)
  • apps/snow-leopard/components/artifact.tsx (0 hunks)
  • apps/snow-leopard/components/chat/chat-header.tsx (2 hunks)
  • apps/snow-leopard/components/chat/chat.tsx (5 hunks)
  • apps/snow-leopard/components/chat/message.tsx (1 hunks)
  • apps/snow-leopard/components/chat/messages.tsx (1 hunks)
  • apps/snow-leopard/components/chat/multimodal-input.tsx (4 hunks)
  • apps/snow-leopard/components/create-artifact.tsx (0 hunks)
  • apps/snow-leopard/components/data-stream-handler.tsx (4 hunks)
  • apps/snow-leopard/components/document/actions.tsx (1 hunks)
  • apps/snow-leopard/components/document/document-tool.tsx (5 hunks)
  • apps/snow-leopard/components/document/document-workspace.tsx (10 hunks)
  • apps/snow-leopard/components/document/editor.tsx (4 hunks)
  • apps/snow-leopard/components/document/skeleton.tsx (0 hunks)
  • apps/snow-leopard/components/document/version-header.tsx (6 hunks)
  • apps/snow-leopard/components/highlight-blog-tool.tsx (0 hunks)
  • apps/snow-leopard/components/sidebar/sidebar-documents.tsx (4 hunks)
  • apps/snow-leopard/components/sidebar/sidebar-user-nav.tsx (1 hunks)
  • apps/snow-leopard/components/suggestion-overlay-provider.tsx (6 hunks)
  • apps/snow-leopard/components/synonym-overlay.tsx (1 hunks)
  • apps/snow-leopard/components/toolbar.tsx (0 hunks)
  • apps/snow-leopard/hooks/use-artifact.ts (0 hunks)
  • apps/snow-leopard/hooks/use-document-context.tsx (0 hunks)
  • apps/snow-leopard/hooks/use-document.ts (13 hunks)
  • apps/snow-leopard/lib/ai/document-helpers.ts (1 hunks)
  • apps/snow-leopard/lib/ai/prompts.ts (1 hunks)
  • apps/snow-leopard/lib/ai/tools/create-document.ts (1 hunks)
  • apps/snow-leopard/lib/ai/tools/document-streaming.ts (1 hunks)
  • apps/snow-leopard/lib/ai/tools/update-document.ts (0 hunks)
  • apps/snow-leopard/lib/artifacts/server.ts (0 hunks)
  • apps/snow-leopard/lib/auth.ts (2 hunks)
  • apps/snow-leopard/lib/db/queries.ts (3 hunks)
  • apps/snow-leopard/lib/editor/basic-schema.ts (1 hunks)
  • apps/snow-leopard/lib/editor/config.ts (1 hunks)
  • apps/snow-leopard/lib/editor/editor-plugins.ts (1 hunks)
  • apps/snow-leopard/lib/editor/emoji-plugin.ts (0 hunks)
  • apps/snow-leopard/lib/editor/functions.tsx (1 hunks)
  • apps/snow-leopard/lib/editor/synonym-plugin.ts (3 hunks)
  • apps/snow-leopard/middleware.ts (1 hunks)
  • apps/snow-leopard/package.json (2 hunks)
  • apps/snow-leopard/types/document.ts (2 hunks)
  • apps/snow-leopard/types/metadata.ts (1 hunks)
  • package.json (1 hunks)

Walkthrough

Removes artifact-based modules and migrates the app to a document-centric model. Introduces new document actions/workspace, streaming helpers, editor schema/plugins (emoji, synonym overlay), and refactors hooks and components to use useDocument. Updates AI tools, DB queries, auth Stripe gating, middleware, and packages. Adds new overlays and parsing/serialization via Markdown-it.

Changes

Cohort / File(s) Summary
Artifact removal
apps/snow-leopard/components/artifact.tsx, .../components/artifact-actions.tsx, .../artifacts/text/*, .../hooks/use-artifact.ts, .../components/toolbar.tsx, .../components/highlight-blog-tool.tsx, .../lib/artifacts/server.ts
Deletes artifact system (UI, hooks, text artifact client/server, toolbar, highlight tool) and server handlers/mappings.
Document-centric hook and context
apps/snow-leopard/hooks/use-document.ts, .../hooks/use-document-context.tsx
Adds useDocument with CurrentDocument and setters/handlers; removes legacy context/provider and artifact utils.
Document workspace and actions
apps/snow-leopard/components/document/document-workspace.tsx, .../components/document/actions.tsx, .../components/document/version-header.tsx, .../components/document/skeleton.tsx, .../components/document/document-tool.tsx
Replaces artifact workspace/actions with document equivalents; adds inline create/rename flows; updates headers, skeleton, and tool components to document model.
Data stream refactor
apps/snow-leopard/components/data-stream-handler.tsx
Migrates stream handling to document state; updates delta types and events; routes navigation and save events by documentId.
Editor schema/plugins and functions
apps/snow-leopard/lib/editor/basic-schema.ts, .../lib/editor/config.ts, .../lib/editor/emoji-plugin.ts, .../lib/editor/editor-plugins.ts, .../lib/editor/functions.tsx, .../components/document/editor.tsx, .../lib/editor/synonym-plugin.ts
Adds shared schema with diff mark, integrates emoji plugin and overlay, switches to Markdown-it parsing/serialization, wires synonym overlay via events.
AI helpers and tools
apps/snow-leopard/lib/ai/document-helpers.ts, .../lib/ai/tools/document-streaming.ts, .../lib/ai/tools/create-document.ts, .../lib/ai/tools/update-document.ts, .../lib/ai/prompts.ts
Adds create/update text document helpers; simplifies streaming to a single text path; removes kind selection and kind in returns; loosens prompt type from enum to string
App pages and layout
apps/snow-leopard/app/layout.tsx, .../app/documents/layout.tsx, .../app/page.tsx, .../app/documents/page.tsx, .../app/documents/[id]/page.tsx, .../app/api/document/actions/create.ts
Moves providers (SuggestionOverlayProvider relocated into documents layout), updates CTA logic, switches imports to document workspace, and adjusts create payload kind typing.
Chat and sidebar updates
apps/snow-leopard/components/chat/*, .../components/sidebar/sidebar-documents.tsx, .../components/sidebar/sidebar-user-nav.tsx, .../components/suggestion-overlay-provider.tsx
Refactors to useDocument, aligns IDs/titles/content usage, updates sign-out redirect, and suggestion provider to documentId.
Types
apps/snow-leopard/types/document.ts, .../types/metadata.ts
Renames Artifact* types to Document*; adds UIDocument interface.
DB, auth, middleware
apps/snow-leopard/lib/db/queries.ts, .../lib/auth.ts, .../middleware.ts
Makes kind optional in DB saves; consolidates Stripe gating with broader enable flag; allows authenticated users to access '/'.
Overlays (new)
apps/snow-leopard/components/emoji-overlay.tsx, .../components/synonym-overlay.tsx
Adds emoji and synonym overlays with keyboard navigation and event-driven control.
Package updates
apps/snow-leopard/package.json, /package.json
Adds editor/emoji/markdown deps, Tailwind stack, workspace db; reorders Next entries.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as DocumentWorkspace/UI
  participant Tool as streamingDocument (tool)
  participant AI as createTextDocument
  participant DS as DataStream
  participant Router as Next Router

  User->>UI: Create document (title)
  UI->>Tool: execute({ title })
  Tool->>AI: createTextDocument({ title, dataStream })
  AI-->>DS: text-delta/id/finish events (stream)
  DS-->>UI: text-delta → update content (streaming)
  DS-->>Router: id → navigate /documents/{id}
  DS-->>UI: finish → status idle, force-save
Loading
sequenceDiagram
  autonumber
  participant PM as ProseMirror (synonym plugin)
  participant Win as window
  participant Overlay as SynonymOverlay (React)
  participant Editor as Document Editor

  PM->>Win: dispatch 'synonym-overlay:open' { synonyms, pos, from, to, view }
  Win->>Overlay: render(isOpen=true, data)
  Overlay->>Editor: replace text [from,to] with choice
  Overlay->>Win: onClose → dispatch 'synonym-overlay:close'
  Win->>Overlay: unmount/isOpen=false
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120+ minutes

Possibly related PRs

Poem

A rabbit taps keys with delight and glee,
Bye-bye artifacts, docs run free.
Emojis pop in with a wink and a grin,
Synonyms swirl as the edits begin.
Streams hum softly, titles take flight—
Snow Leopard purrs: “All documents, right!” 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/clean-code

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Aug 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
cursorforwriting-wkur Error Error Aug 21, 2025 11:00pm

@will-lp1 will-lp1 merged commit 9692e21 into main Aug 21, 2025
3 of 4 checks passed
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