Skip to content

feat: selected-text quote display with .env-driven configuration - #1

Merged
quiet-node merged 9 commits into
mainfrom
feature/selected-text-quote
Mar 31, 2026
Merged

feat: selected-text quote display with .env-driven configuration#1
quiet-node merged 9 commits into
mainfrom
feature/selected-text-quote

Conversation

@quiet-node

@quiet-node quiet-node commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Separate display content from Ollama prompt — the raw Context: "..." preamble no longer appears in user chat bubbles
  • Render selected text as a left-bordered quote block (Slack/Discord style) inside the user's chat bubble
  • Preserve multi-line formatting with intelligent truncation (formatQuotedText utility: 4-line / 300-char cap)
  • Clear selected context after first submit — quote is one-shot, not re-injected into follow-ups
  • Introduce .env-driven configuration via Vite's built-in env support (VITE_QUOTE_MAX_DISPLAY_LINES, VITE_QUOTE_MAX_DISPLAY_CHARS, VITE_QUOTE_MAX_CONTEXT_LENGTH) with validated fallback defaults
  • Add docs/configurations.md with full reference table, .env.example template, and README setup step
  • Enforce 100% test coverage requirement in CLAUDE.md
  • 134 tests, 100% code coverage across all files

Test Plan

  • Select text in any app, double-tap ⌘ — quote preview appears in AskBar with preserved line breaks
  • Submit a message — quote appears as a styled block in user bubble, raw Context: prefix is gone
  • Send a follow-up — AskBar shows no quote, no context sent to Ollama
  • Copy button on user message copies only the message text, not the quoted text
  • Override values in .env (e.g., VITE_QUOTE_MAX_DISPLAY_LINES=2), restart dev server — limits apply
  • Run bun run test:coverage — 134 tests pass, 100% coverage

🤖 Generated with Claude Code

@quiet-node
quiet-node force-pushed the feature/selected-text-quote branch from 79904dc to 0d4ce2d Compare March 31, 2026 19:15
quiet-node and others added 9 commits March 31, 2026 15:29
- Add `quotedText?: string` to the `Message` interface
- Separate display content from the Ollama prompt in `ask()` so the
  raw `Context: "..."` preamble no longer appears in the chat bubble
- Render a left-bordered italic quote block above the user's message
  text in `ChatBubble` when `quotedText` is present
- Clear `selectedContext` after the first submit so the quote is not
  re-injected into follow-up messages

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add formatQuotedText() utility to intelligently format quotes
- Preserve line breaks from multi-line selections (instead of collapsing to single line)
- Cap display at 4 lines or 300 characters total
- Add "..." truncation indicator when limits are exceeded
- Use white-space: pre-wrap to maintain formatting in UI
- Apply to both AskBar preview and chat bubble quote

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Update useOllama tests for new ask(displayContent, ollamaPrompt, quotedText?) signature
- Add tests for quotedText storage and separate ollamaPrompt forwarding
- Update AskBarView test for whitespace-pre-wrap (replaces line-clamp-2)
- Add ChatBubble tests for quote block rendering with quotedText prop
- Add formatQuotedText() unit tests covering truncation, line limits, edge cases
- All 121 tests pass with 100% coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
- Create .env with VITE_QUOTE_MAX_DISPLAY_LINES, VITE_QUOTE_MAX_DISPLAY_CHARS,
  and VITE_QUOTE_MAX_CONTEXT_LENGTH (defaults: 4, 300, 4096)
- Add src/config.ts with envInt() helper that reads Vite env vars with
  type-safe fallback defaults for invalid/missing values
- Type env vars in vite-env.d.ts via ImportMetaEnv interface
- Update AskBarView, ChatBubble, and App to consume config values
- Remove hardcoded MAX_CONTEXT_LENGTH from App.tsx
- Add config tests covering env overrides and edge cases (empty, NaN,
  negative, zero, decimal, Infinity)
- 133 tests passing, 100% coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
- Add .env to .gitignore and remove tracked .env from git
- Create .env.example as the committed reference template
- Create docs/configurations.md with full configuration reference
  table, validation rules, and Vite file precedence
- Update README.md Getting Started with environment setup step

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
- Fix JSDoc formatting regression in useOllama.ts (restore standard /** * */ style)
- Update docs/configurations.md to reference correct path src/config/index.ts
- Add early return for empty string in formatQuotedText() for explicit intent
- Add test for empty string edge case

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
@quiet-node
quiet-node force-pushed the feature/selected-text-quote branch from defbe29 to 1b7a0f4 Compare March 31, 2026 20:30
@quiet-node quiet-node changed the title feat: display selected text as a quote block in chat bubbles feat: selected-text quote display with .env-driven configuration Mar 31, 2026
@quiet-node
quiet-node merged commit 01e76b8 into main Mar 31, 2026
4 checks passed
@quiet-node
quiet-node deleted the feature/selected-text-quote branch March 31, 2026 20:39
quiet-node added a commit that referenced this pull request Apr 10, 2026
* feat: display selected text as a quote block in chat bubbles

- Add `quotedText?: string` to the `Message` interface
- Separate display content from the Ollama prompt in `ask()` so the
  raw `Context: "..."` preamble no longer appears in the chat bubble
- Render a left-bordered italic quote block above the user's message
  text in `ChatBubble` when `quotedText` is present
- Clear `selectedContext` after the first submit so the quote is not
  re-injected into follow-up messages

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

* improve: preserve line breaks in quoted text display

- Add formatQuotedText() utility to intelligently format quotes
- Preserve line breaks from multi-line selections (instead of collapsing to single line)
- Cap display at 4 lines or 300 characters total
- Add "..." truncation indicator when limits are exceeded
- Use white-space: pre-wrap to maintain formatting in UI
- Apply to both AskBar preview and chat bubble quote

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

* test: update existing tests and add coverage for quote features

- Update useOllama tests for new ask(displayContent, ollamaPrompt, quotedText?) signature
- Add tests for quotedText storage and separate ollamaPrompt forwarding
- Update AskBarView test for whitespace-pre-wrap (replaces line-clamp-2)
- Add ChatBubble tests for quote block rendering with quotedText prop
- Add formatQuotedText() unit tests covering truncation, line limits, edge cases
- All 121 tests pass with 100% coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* feat: add .env-driven configuration for quote display limits

- Create .env with VITE_QUOTE_MAX_DISPLAY_LINES, VITE_QUOTE_MAX_DISPLAY_CHARS,
  and VITE_QUOTE_MAX_CONTEXT_LENGTH (defaults: 4, 300, 4096)
- Add src/config.ts with envInt() helper that reads Vite env vars with
  type-safe fallback defaults for invalid/missing values
- Type env vars in vite-env.d.ts via ImportMetaEnv interface
- Update AskBarView, ChatBubble, and App to consume config values
- Remove hardcoded MAX_CONTEXT_LENGTH from App.tsx
- Add config tests covering env overrides and edge cases (empty, NaN,
  negative, zero, decimal, Infinity)
- 133 tests passing, 100% coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: add .env.example, gitignore .env, add configuration docs

- Add .env to .gitignore and remove tracked .env from git
- Create .env.example as the committed reference template
- Create docs/configurations.md with full configuration reference
  table, validation rules, and Vite file precedence
- Update README.md Getting Started with environment setup step

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* refactor: move config.ts into src/config/ directory

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* fix: address code review findings

- Fix JSDoc formatting regression in useOllama.ts (restore standard /** * */ style)
- Update docs/configurations.md to reference correct path src/config/index.ts
- Add early return for empty string in formatQuotedText() for explicit intent
- Add test for empty string edge case

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: formatted code

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* docs: enforce 100% test coverage requirement in CLAUDE.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

---------

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
quiet-node added a commit that referenced this pull request Apr 10, 2026
* feat: display selected text as a quote block in chat bubbles

- Add `quotedText?: string` to the `Message` interface
- Separate display content from the Ollama prompt in `ask()` so the
  raw `Context: "..."` preamble no longer appears in the chat bubble
- Render a left-bordered italic quote block above the user's message
  text in `ChatBubble` when `quotedText` is present
- Clear `selectedContext` after the first submit so the quote is not
  re-injected into follow-up messages


* improve: preserve line breaks in quoted text display

- Add formatQuotedText() utility to intelligently format quotes
- Preserve line breaks from multi-line selections (instead of collapsing to single line)
- Cap display at 4 lines or 300 characters total
- Add "..." truncation indicator when limits are exceeded
- Use white-space: pre-wrap to maintain formatting in UI
- Apply to both AskBar preview and chat bubble quote


* test: update existing tests and add coverage for quote features

- Update useOllama tests for new ask(displayContent, ollamaPrompt, quotedText?) signature
- Add tests for quotedText storage and separate ollamaPrompt forwarding
- Update AskBarView test for whitespace-pre-wrap (replaces line-clamp-2)
- Add ChatBubble tests for quote block rendering with quotedText prop
- Add formatQuotedText() unit tests covering truncation, line limits, edge cases
- All 121 tests pass with 100% coverage


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* feat: add .env-driven configuration for quote display limits

- Create .env with VITE_QUOTE_MAX_DISPLAY_LINES, VITE_QUOTE_MAX_DISPLAY_CHARS,
  and VITE_QUOTE_MAX_CONTEXT_LENGTH (defaults: 4, 300, 4096)
- Add src/config.ts with envInt() helper that reads Vite env vars with
  type-safe fallback defaults for invalid/missing values
- Type env vars in vite-env.d.ts via ImportMetaEnv interface
- Update AskBarView, ChatBubble, and App to consume config values
- Remove hardcoded MAX_CONTEXT_LENGTH from App.tsx
- Add config tests covering env overrides and edge cases (empty, NaN,
  negative, zero, decimal, Infinity)
- 133 tests passing, 100% coverage


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: add .env.example, gitignore .env, add configuration docs

- Add .env to .gitignore and remove tracked .env from git
- Create .env.example as the committed reference template
- Create docs/configurations.md with full configuration reference
  table, validation rules, and Vite file precedence
- Update README.md Getting Started with environment setup step


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* refactor: move config.ts into src/config/ directory


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* fix: address code review findings

- Fix JSDoc formatting regression in useOllama.ts (restore standard /** * */ style)
- Update docs/configurations.md to reference correct path src/config/index.ts
- Add early return for empty string in formatQuotedText() for explicit intent
- Add test for empty string edge case


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: formatted code

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* docs: enforce 100% test coverage requirement in CLAUDE.md


Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

---------

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
quiet-node added a commit that referenced this pull request Apr 11, 2026
* feat: display selected text as a quote block in chat bubbles

- Add `quotedText?: string` to the `Message` interface
- Separate display content from the Ollama prompt in `ask()` so the
  raw `Context: "..."` preamble no longer appears in the chat bubble
- Render a left-bordered italic quote block above the user's message
  text in `ChatBubble` when `quotedText` is present
- Clear `selectedContext` after the first submit so the quote is not
  re-injected into follow-up messages

* improve: preserve line breaks in quoted text display

- Add formatQuotedText() utility to intelligently format quotes
- Preserve line breaks from multi-line selections (instead of collapsing to single line)
- Cap display at 4 lines or 300 characters total
- Add "..." truncation indicator when limits are exceeded
- Use white-space: pre-wrap to maintain formatting in UI
- Apply to both AskBar preview and chat bubble quote

* test: update existing tests and add coverage for quote features

- Update useOllama tests for new ask(displayContent, ollamaPrompt, quotedText?) signature
- Add tests for quotedText storage and separate ollamaPrompt forwarding
- Update AskBarView test for whitespace-pre-wrap (replaces line-clamp-2)
- Add ChatBubble tests for quote block rendering with quotedText prop
- Add formatQuotedText() unit tests covering truncation, line limits, edge cases
- All 121 tests pass with 100% coverage

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* feat: add .env-driven configuration for quote display limits

- Create .env with VITE_QUOTE_MAX_DISPLAY_LINES, VITE_QUOTE_MAX_DISPLAY_CHARS,
  and VITE_QUOTE_MAX_CONTEXT_LENGTH (defaults: 4, 300, 4096)
- Add src/config.ts with envInt() helper that reads Vite env vars with
  type-safe fallback defaults for invalid/missing values
- Type env vars in vite-env.d.ts via ImportMetaEnv interface
- Update AskBarView, ChatBubble, and App to consume config values
- Remove hardcoded MAX_CONTEXT_LENGTH from App.tsx
- Add config tests covering env overrides and edge cases (empty, NaN,
  negative, zero, decimal, Infinity)
- 133 tests passing, 100% coverage

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: add .env.example, gitignore .env, add configuration docs

- Add .env to .gitignore and remove tracked .env from git
- Create .env.example as the committed reference template
- Create docs/configurations.md with full configuration reference
  table, validation rules, and Vite file precedence
- Update README.md Getting Started with environment setup step

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* refactor: move config.ts into src/config/ directory

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* fix: address code review findings

- Fix JSDoc formatting regression in useOllama.ts (restore standard /** * */ style)
- Update docs/configurations.md to reference correct path src/config/index.ts
- Add early return for empty string in formatQuotedText() for explicit intent
- Add test for empty string edge case

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* chore: formatted code

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

* docs: enforce 100% test coverage requirement in CLAUDE.md

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>

---------

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.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.

1 participant