Repository: stable-diffusion-webui
Issue: [Bug]: Checkpoints and Loras don't show up if "Show cards for models in hidden directories" is set to "Never"
Labels: bug-report

### Checklist

- [ ] The issue exists after disabling all extensions
- [ ] The issue exists on a clean installation of webui
- [X] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [X] The issue exists in the current version of the webui
- [X] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

If `Show cards for models in hidden directories` is set to `Never` the model list isn't populated.

### Steps to reproduce the problem

1. Set `Show cards for models in hidden directories` to `Never`
2. Apply, restart the program
3. Go to checkpoint/lora tab
4. See "Error" there

### What should have happened?

Should show the model cards normally

### What browsers do you use to access the UI ?

Brave

### Sysinfo

There's plenty of API keys in it so I'm not sharing unless really needed

### Console logs

```Shell
Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]                                                                                                                             
Version: v1.8.0                                                                                                                                                                       
Commit hash: bef51aed032c0aaa5cfd80445bc4cf0d85b408b5                                                                                                                                 
Installing requirements                                                                                                                                                               
Launching Web UI with arguments: --port=7863 --listen --xformers --no-half-vae --enable-insecure-extension-access --api
2024-03-03 00:03:46.377005: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off erro
rs from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-03 00:03:46.395807: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operati
ons.                                                                                                                                                                                  
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.                                                 
2024-03-03 00:03:46.711218: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.                              
[-] ADetailer initialized. version: 24.3.0, num models: 10                                                                                                                            
ControlNet preprocessor location: /home/rkfg/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads
2024-03-03 00:03:51,144 - ControlNet - INFO - ControlNet v1.1.441                                                                                                                     
2024-03-03 00:03:51,227 - ControlNet - INFO - ControlNet v1.1.441
Loading weights [bff4610d23] from /home/rkfg/stable-diffusion-webui/models/Stable-diffusion/realistic/epicrealism_naturalSin.safetensors
2024-03-03 00:03:51,289 - AnimateDiff - INFO - Injecting LCM to UI.
2024-03-03 00:03:51,517 - AnimateDiff - INFO - Hacking i2i-batch.
2024-03-03 00:03:51,562 - ControlNet - INFO - ControlNet UI callback registered.
Creating model from config: /home/rkfg/stable-diffusion-webui/configs/v1-inference.yaml
*Deforum ControlNet support: enabled*
*** Error executing callback ui_tabs_callback for /home/rkfg/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts/deforum.py
    Traceback (most recent call last):
      File "/home/rkfg/stable-diffusion-webui/modules/script_callbacks.py", line 180, in ui_tabs_callback
        res += c.callback() or []
      File "/home/rkfg/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts/deforum_helpers/ui_right.py", line 92, in on_ui_tabs
        deforum_gallery, generation_info, html_info, _ = create_output_panel("deforum", opts.outdir_img2img_samples)
    TypeError: cannot unpack non-iterable OutputPanel object

---
Running on local URL:  http://0.0.0.0:7863
Applying attention optimization: xformers... done.
Model loaded in 1.3s (load weights from disk: 0.3s, create model: 0.6s, apply weights to model: 0.3s).

To create a public link, set `share=True` in `launch()`.
2024-03-03 00:03:54,445 - AnimateDiff - INFO - Hacking i2i-batch is already done.
2024-03-03 00:03:54,448 - AnimateDiff - INFO - Hacking i2i-batch is already done.
Startup time: 13.0s (prepare environment: 3.6s, import torch: 2.2s, import gradio: 0.3s, setup paths: 0.7s, other imports: 0.2s, list SD models: 0.2s, load scripts: 2.6s, create ui: 
0.7s, gradio launch: 2.1s, add APIs: 0.4s).
Traceback (most recent call last):
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/gradio/blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/gradio/blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/mnt/2Tb/sd-local/lib/python3.10/site-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 703, in pages_html
    create_html()
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 699, in create_html
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 699, in <listcomp>
    ui.pages_contents = [pg.create_html(ui.tabname) for pg in ui.stored_extra_pages]
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 547, in create_html
    "tree_html": self.create_tree_view_html(tabname),
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 472, in create_tree_view_html
    item_html = self.create_tree_dir_item_html(tabname, k, _build_tree(v))
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 465, in _build_tree
    _dir_li.append(self.create_tree_dir_item_html(tabname, k, _build_tree(v)))
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 465, in _build_tree
    _dir_li.append(self.create_tree_dir_item_html(tabname, k, _build_tree(v)))
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 465, in _build_tree
    _dir_li.append(self.create_tree_dir_item_html(tabname, k, _build_tree(v)))
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 463, in _build_tree
    _file_li.append(self.create_tree_file_item_html(tabname, k, v.item))
  File "/home/rkfg/stable-diffusion-webui/modules/ui_extra_networks.py", line 395, in create_tree_file_item_html
    item_html_args["copy_path_button"],
TypeError: string indices must be integers
```


### Additional information

It works if the option is set to `When searched` or `Always`. However, my use case assumes private loras that shouldn't be visible unless the user knows the exact name. Also the new UI doesn't seem to hide the hidden directories (that start with a dot) in the tree view even when the option is set to `When searched`. I think it should, as well as when it's set to `Never` (when it's fixed to work).

This UI also works if the `Lora` built-in extension is disabled (even when the option in question is set to `Never`). But then, obviously, Loras can't be used as the tab with them is missing. That's why I selected the checkboxes in the beginning like that. I also disabled all extensions except the built-in ones and it was still reproducible until I disabled the Lora one.