コミットを比較

..
作成者 SHA1 メッセージ 日付
Codex Night Worker 820e4ac828 WIP: preserve failed Codex job issue-242-hhdxc839 2026-11-15 13:46:32 +09:00
テツノニジカとCodex Night Worker e13a52db9a AI: #454 広場のタグ検索,スマホ版だとサゼストが途中で見切れる問題 (#456)
Refs #454

## Automated implementation (requires human review)
[SidebarComponent.tsx](frontend/src/components/layout/SidebarComponent.tsx) の1行を修正しました。`overflow-y-auto` を `md` 以上に限定し、スマホでサゼストがサイドバーの領域外で切られる原因を取り除きました。

差分を確認済みです。指定に従い、テスト・lint・ビルドは未実行です。実画面でのスマホ表示とPC表示の確認も未実施です。

## Automated review (not a guarantee of correctness)
```text
The change restricts sidebar scrolling to medium and larger viewports. No actionable regression was identified in the current diff.

```

## Verification
- Tests/builds/migrations were not authorized and were not invoked by the controller.
- Codex was instructed not to run them; its command transcript should be inspected.
- Do not merge before manual acceptance and required checks.

---------

Co-authored-by: Codex Night Worker <codex-night@localhost>
Reviewed-on: #456
Co-authored-by: テツノニジカ <969+codex-bot@noreply.localhost>
2026-11-14 17:09:38 +09:00
9個のファイルの変更、57行の追加、42行の削除
+5
ファイルの表示
@@ -0,0 +1,5 @@
class AddPostCountIndexToTags < ActiveRecord::Migration[8.0]
def change
add_index :tags, :post_count
end
end
生成ファイル
+2 -1
ファイルの表示
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_10_15_010000) do
ActiveRecord::Schema[8.0].define(version: 2026_11_15_000000) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -630,6 +630,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_10_15_010000) do
t.integer "post_count", default: 0, null: false
t.integer "version_no", null: false
t.index ["deprecated_at"], name: "index_tags_on_deprecated_at"
t.index ["post_count"], name: "index_tags_on_post_count"
t.check_constraint "(`deprecated_at` is null) or (`category` <> _utf8mb4'nico')", name: "chk_tags_deprecated_at_not_nico"
t.check_constraint "`version_no` > 0", name: "chk_tags_version_no_positive"
end
+13
ファイルの表示
@@ -2,6 +2,19 @@ require 'rails_helper'
RSpec.describe Tag, type: :model do
include WikiRecords
describe 'post_count index' do
it 'has a non-unique index on post_count alone' do
indexes = described_class.connection.indexes(described_class.table_name)
expect(indexes).to include(
have_attributes(
name: 'index_tags_on_post_count',
columns: ['post_count'],
unique: false))
end
end
describe '#has_description?' do
let(:tag) { create(:tag) }
+2 -8
ファイルの表示
@@ -36,13 +36,10 @@ const replaceToken = (value: string, start: number, end: number, text: string) =
type Props = Omit<ComponentPropsWithoutRef<'textarea'>, 'value' | 'onChange' | 'onBlur'> & {
tags: string
setTags: (tags: string) => void
label?: ReactNode
errors?: ReactNode[] }
const PostFormTagsArea: FC<Props> = (
{ tags, setTags, label: fieldLabel, errors, ...rest },
) => {
const PostFormTagsArea: FC<Props> = ({ tags, setTags, errors, ...rest }) => {
const { label } = useUITranslation ('navigation')
const locale = useLocale ()
const ref = useRef<HTMLTextAreaElement> (null)
@@ -120,10 +117,7 @@ const PostFormTagsArea: FC<Props> = (
}, [locale])
return (
<FormField
className="relative w-full"
label={fieldLabel ?? label ('tags')}
messages={errors}>
<FormField className="relative w-full" label={label ('tags')} messages={errors}>
{({ describedBy, invalid }) => (
<>
<TextArea
+10
ファイルの表示
@@ -70,6 +70,16 @@ describe ('SidebarComponent', () => {
vi.spyOn (HTMLElement.prototype, 'hasPointerCapture').mockReturnValue (true)
})
it ('limits sidebar scrolling to desktop to avoid clipping mobile suggestions', () => {
renderSidebar ()
// jsdom has no layout; guard the responsive classes responsible for clipping.
const sidebar = screen.getByText ('Sidebar body')
expect (sidebar).not.toHaveClass ('overflow-y-auto')
expect (sidebar).toHaveClass ('md:overflow-y-auto')
})
it ('uses maxWidth without applying the container main-width reserve twice', async () => {
localStorage.setItem ('sidebar:test-sidebar:left:width', '700')
const onWidthChange = vi.fn ()
+1 -1
ファイルの表示
@@ -339,7 +339,7 @@ const SidebarComponent: FC<Props> = ({
</style>
</Helmet>
<div className="h-full overflow-y-auto p-4 sidebar">
<div className="h-full md:overflow-y-auto p-4 sidebar">
{children}
</div>
+3 -22
ファイルの表示
@@ -162,13 +162,12 @@ describe ('NicoTagListPage', () => {
})
})
it ('saves links after completing the tag at the cursor', async () => {
it ('updates links from a tag card', async () => {
api.apiGet
.mockResolvedValueOnce ({
tags: [buildNicoTag ({ id: 7, name: 'nico:source' })],
count: 1,
})
.mockResolvedValueOnce ([buildTag ({ id: 8, name: '連携先', postCount: 3 })])
.mockResolvedValueOnce ({
tags: [
buildNicoTag ({
@@ -184,24 +183,8 @@ describe ('NicoTagListPage', () => {
renderPage ()
fireEvent.click (await screen.findByRole ('button', { name: '編集' }))
const textarea = screen.getByLabelText ('連携する広場タグ')
fireEvent.change (textarea, { target: { value: '既存 連携\n後続' } })
fireEvent.focus (textarea)
fireEvent.select (textarea, {
target: { selectionStart: 4, selectionEnd: 4 } })
await waitFor (() => {
expect (api.apiGet).toHaveBeenCalledWith (
'/tags/autocomplete',
{ locale: 'ja', params: { q: '連携', nico: '0' },
signal: expect.any (AbortSignal) })
})
fireEvent.mouseDown (await screen.findByText ('連携先'))
expect (textarea).toHaveValue ('既存 連携先 \n後続')
await waitFor (() => {
expect ((textarea as HTMLTextAreaElement).selectionStart).toBe (7)
expect ((textarea as HTMLTextAreaElement).selectionEnd).toBe (7)
fireEvent.change (screen.getByLabelText ('連携する広場タグ'), {
target: { value: '連携先' },
})
fireEvent.click (screen.getByRole ('button', { name: '保存' }))
@@ -212,8 +195,6 @@ describe ('NicoTagListPage', () => {
{ locale: 'ja', headers: { 'Content-Type': 'multipart/form-data' } },
)
})
const payload = api.apiPut.mock.calls[0][1] as FormData
expect (payload.get ('tags')).toBe ('既存 連携先 \n後続')
expect (await screen.findByText ('1 件')).toBeInTheDocument ()
})
+12 -8
ファイルの表示
@@ -6,10 +6,11 @@ import { useLocation } from 'react-router-dom'
import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import TagLink from '@/components/TagLink'
import SortHeader from '@/components/SortHeader'
import PostFormTagsArea from '@/components/PostFormTagsArea'
import FieldError from '@/components/common/FieldError'
import FormField from '@/components/common/FormField'
import PageTitle from '@/components/common/PageTitle'
import Pagination from '@/components/common/Pagination'
import TextArea from '@/components/common/TextArea'
import useDialogue from '@/lib/dialogues/useDialogue'
import MainArea from '@/components/layout/MainArea'
import { toast } from '@/components/ui/use-toast'
@@ -356,18 +357,21 @@ const NicoTagListPage: FC<Props> = ({ user }) => {
dark:bg-rose-950/30">
<td colSpan={editable ? 5 : 4} className="p-3">
<div className="space-y-2">
<PostFormTagsArea
<label htmlFor={`nico-links-${ tag.id }`}
className="block text-sm font-semibold">
{label ('nico.tagsToLink')}
</label>
<TextArea
id={`nico-links-${ tag.id }`}
label={label ('nico.tagsToLink')}
aria-label={message ('nico.tagsToLink').text}
tags={rawTags[tag.id] ?? ''}
errors={errors}
value={rawTags[tag.id] ?? ''}
invalid={(errorsByTagId[tag.id] ?? []).length > 0}
className="min-h-24 resize-y"
placeholder={message ('nico.tagsPlaceholder').text}
lang={message ('nico.tagsPlaceholder').language}
setTags={value => setRawTags (rawTags => ({
onChange={e => setRawTags (rawTags => ({
...rawTags,
[tag.id]: value}))}/>
[tag.id]: e.target.value}))}/>
<FieldError messages={errors}/>
<div className="flex justify-end gap-2">
<button
type="button"
+9 -2
ファイルの表示
@@ -35,6 +35,10 @@ const renderPage = () =>
describe ('TagDetailPage', () => {
beforeEach (() => {
vi.clearAllMocks ()
tagsApi.fetchTag.mockReset ()
api.apiPut.mockReset ()
api.isApiError.mockReset ()
toastApi.toast.mockReset ()
api.isApiError.mockReturnValue (false)
})
@@ -51,8 +55,11 @@ describe ('TagDetailPage', () => {
})
it ('submits edited tag fields', async () => {
tagsApi.fetchTag.mockResolvedValueOnce (buildTag ({ id: 7, name: 'old' }))
api.apiPut.mockResolvedValueOnce (buildTag ({ id: 7, name: 'new', aliases: ['alias'] }))
const updatedTag = buildTag ({ id: 7, name: 'new', aliases: ['alias'] })
tagsApi.fetchTag
.mockResolvedValue (updatedTag)
.mockResolvedValueOnce (buildTag ({ id: 7, name: 'old' }))
api.apiPut.mockResolvedValueOnce (updatedTag)
renderPage ()